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)

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

6.4.7   Putting it all together

6.4.8   Interacting with ASK Dapp

6.5       Wrapping it up

6.6       Best practices

6.7       Summary

sitemap