Interact with External World Patterns

Disclaimer: This is a summary of patterns we have observed during our research and should not be considered any form of technical or investment advice. Also, the given “known examples” do not imply they are the best implementations of the said pattern or any superior to any other implementation of the pattern not listed.

Due to the unique properties and limitations of blockchains, a major architectural consideration for blockchain-based software applications is what data and executable code (smart contract) should be kept on-chain, and what should be kept off-chain. Two factors need particular attention, namely performance and privacy. Performance highly depends on the type of deployment of the blockchain. For example, a consortium blockchain can be configured to achieve much better performance than a public blockchain.

As a component of a large software system, blockchain needs to communicate data with other components within the software system. In such a system, blockchain is responsible for storing and sharing data and executing smart contracts. The blockchain component might also have tokens as digital currencies or representing other assets. Due to the limitations of privacy and performance, off-chain auxiliary databases could be used in the system. First, private data are stored in an internal database. Second, large size data are stored in a separate data storage such as a cloud service. Blockchain also interacts with other off-chain components. Following patterns present several ways a blockchain can communicate with off-chain components:

Pattern Collections

  • Oracle – Introduce the state of external systems into the closed blockchain execution environment through a third-party service
  • Decentralised Oracle – Introduce the state of external systems into the closed blockchain execution environment through multiple third-party services
  • Reverse Oracle – Off-chain components of an existing system rely on smart contracts running on a blockchain to check required conditions and provide requested data
  • Voting – When the data reported by/to a decentralised oracle is debatable, users can vote for one of the proposed data values or a new value until the consensus is achieved
  • Legal and Smart Contract Pair – A bidirectional binding is established between a legal agreement and a corresponding smart contract