Smart Contracts

Smart Contracts allow users to add business logic to blockchains to make them useful for several business use-cases.

Blockchains are decentralized. Each node in a blockchain network validates and processes all the transactions and stores the copy of the data. Transactions are used to propose updates to the state of the blockchain.

Transactions are initiated using function calls on the blockchain node. For example, in the Bitcoin blockchain, the node software exposes a function called ‘transfer’ which the users can call to transfer bitcoin from one account to another. This function call basically becomes a transfer transaction initiated by the user. Internally, the function, when executed, validates the user’s signature, checks their balance, and does the balance updates to transfer the indicated amount. When the transaction representing this function call is included in a block, all other nodes of the blockchain execute this function individually. This process is followed for each and every transaction. In essence, transactions are function calls and these functions execute business logic.

Smart Contracts allow users to extend the business logic of blockchains. Just the transfer of bitcoin and ether might only help with a subset of financial use cases and cryptocurrencies. For blockchains to be useful in more scenarios, they should be able to execute any kind of business logic and not just transfer of cryptocurrency. This is exactly what smart contracts provide — execution of any kind of business logic on the chain.

In simple terms, a Smart Contract is a collection of functions written in code — just like any other software. They are then deployed on the blockchain by using special transactions that take compiled code of the smart contract as input. Once deployed, users could call smart contract functions just like they would initiate any other transaction on the chain.

For example, a supply-chain smart contract could have a function for recording the location and/or temperature of a shipping container. It could have logic that when the reported temperature goes below a certain value or when the location is within a geo-fence, some amount of cryptocurrency should be transferred from one account to another on the blockchain. This would then allow two parties to track a shipping container and settle payments based on its location and temperature, in the most trustless way possible. Hence making blockchains more useful than just balance transfers.

Music: https://www.purple-planet.com
© 2020 Block Shots