Smart contracts

From wiki
Jump to navigation Jump to search

Smart contracts are blockchain transactions that hold some code. As they are on a blockchain the code and data is immutable and known to all blockchain validator at least.

In Ethereum some coins (ETH) must be spend to cover the resources needed to execute the code. This is called 'gas'.

Smart contracts are on the blockchain and therefor reside on a specific address and can have assets and data. Sending some fee (gas) to a smart contract executes it (on Ethereum in the Ethereum Virtual Machine).

A smart contract blockchain is not just a ledger but a state machine that holds all data and code of the smart contracts.

A simple contract has 3 roles:

  1. client (who wants something)
  2. supplier (who delivers something)
  3. deployer (the intermediary)

Once implemented the workflow will be:

  1. Client and Supplier agree on the deliveries and reward
  2. Client sends the reward for suppliers service to the contract
  3. Supplier sends ready message to the contract
  4. Client sends confirmation to the contract
  5. Deployer transfers the reward to supplier

The deployer can be programmed to do any number of checks before the reward is paid.

Some part of this contract needs real world data, that is not on the blockchain and can still be a source of legal dispute (what is the work, what is the definition of done).

With Ethereum you can use oracles that store real world data on the blockchain or send blockchain data (e.g. contract state) to the real world. This enables contracts without any human intervention. An oracle can monitor some real world data and store that in the blockchain, it can update the smart contract by sending a transaction to it.

The size of a smart contract is limited (on Ethereum it is currently only 24KB). You will have to create several contracts to make a more complex Decentralized Application (dapp) or Decentralized Antonymous Organization (DAO)