Introduction
What is a smart contract
In the field of blockchain & cryptocurrency, smart contracts are applications defined on the blockchain.
Smart contracts are executed through the blockchain's contract call function or certain trigger conditions, and the execution result is fed back to the blockchain.
How smart contracts are executed
The operation of the blockchain is inseparable from verifying and packaging transactions by miners (i.e. SR). The transaction in the traditional sense refers to the transfer of tokens. In the context of Blockchain 2.0, transactions are broad, which can be any data or operation recognized by various miners, enter the blockchain through consensus, and affect the state of the blockchain.
The broadening of the transaction concept leads to transactions related to smart contracts, including the creation, triggering, deployment, destruction, Etc.
The author can publish the smart contract on the blockchain after the code is done, that is, save the contract code on the blockchain. It is possible to initialize several contract states at the same time.
When the user calls a function in the contract, the SR will load the specific code of the contract through the smart contract virtual machine(i.e. TVM), execute related function calls, and complete the modification or query of the state on the blockchain.
For public chain platforms, nodes obtain miner fees or block rewards through packaging transactions and executing contract codes. Due to the supervision of other nodes, the correctness of contract execution is guaranteed.
Updated over 4 years ago