6 On-chain and off-chain data

 

This chapter covers

  • Exploring different kinds of on-chain data: blocks, transactions, receipts, and state
  • Defining, emitting, and logging events
  • Accessing event logs from transaction receipts to support Dapp operations
  • Designing and developing Dapps with on-chain and off-chain data
  • Demonstrating on-chain and off-chain data using ASK and blind auction Dapps

This is it. This is what distinguishes blockchain application development from that of non-blockchain applications: on-chain data. Do you wonder where the data associated with a Dapp is stored? Some are stored on the blockchain infrastructure (on-chain), and others in traditional databases and files (off-chain). In this chapter, you’ll learn first about the concept of on-chain data introduced by the inclusion of blockchain features in an application. Then you’ll learn to design and develop Dapps that deal with a combination of on-chain and off-chain data.

So what exactly are these two types of data in the context of blockchain programming? In general, any data stored on the blockchain is called on-chain data, and anything else is off-chain.

Let’s analyze this concept further. In a traditional system, the results of function executions in an application are persisted in a local filesystem or a central database. A blockchain application stores the following on the blockchain node (on-chain):

6.1 On-chain data

6.2 Blind auction use case

6.2.1 On-chain event data

6.2.2 Blind auction with events

6.2.3 Testing with the web UI

6.2.4 Accessing on-chain data using the web3 API

6.3 Off-chain data: External data sources

6.4 ASK airline system

6.4.1 ASK concept

6.4.2 Airlines smart contract

6.4.3 ASK on-chain data

6.4.4 ASK off-chain data

6.4.5 ASK Dapp development process

6.4.6 ASK web user interface

sitemap