Principles and Architecture of Interacting with Smart Contracts

Published by Mario Oettler on

dApp development consists of two pillars:

  • Coding and deploying smart contracts. (You can find a Solidity coding course here.)
  • Coding a user interface or a backend that interacts with a smart contract via a full node.

Here, we focus on creating a user interface and backend that interacts with a the blockchain and smart contracts through a full node.

There are two ways to implement this.

  1. The communication is done via a server.
Interacting with a blockchain via a server.

The basic flow is:

  1. The browser requests a website from the server
  2. The server delivers the website to the browser
  3. The user interface sends the user data to the server
  4. The server creates a transaction and signs it with a private key
  5. The server sends the transaction to a blockchain node
  6. The blockchain node propagates the transaction to the blockchain network
  7. The blockchain node receives information from the blockchain network
  8. The blockchain node sends information to the server
  9. The server sends information to the browser

One downside of this architecture is that the private key lies on the server. This means, the end user cannot control its coins. Instead they need to trust the server to treat the private key and the funds faithfully.

Another way to build an interface is this one:

Interacting directly with the blockchain via a wallet.

Here, the browser communicates via a wallet (e.g. MetaMask) with the blockchain node. The server itself is not involved in the transactions. This makes it easier to keep the private key of the end user secret.

Categories: