6 On-chain and off-chain data
This chapter covers
· Kinds of data stored on-chain: blocks, transactions, receipts, and state
· Events: defining, emitting, and on-chain logging
· Accessing event logs from transaction receipts to support Dapp operations
· Designing 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 first learn 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 on the blockchain node (on-chain)