Smart Contract
A Smart Contract is a registration of the service logic developed by a DApp developer on the network. When users execute the Contract, they change or query the State of that Contract. The State changed by the user is guaranteed to function without tampering according to the Contract Logic and State registered on the blockchain. It is a Turing complete system.
Compiling Contract
When you compile a Smart Contract, you obtain Bytecode, OPCODE, and ABI.
When deploying the Contract to the network, Bytecode is necessary. To calculate Gas when executing the Contract, OPCODE is needed. Using ABI, you can communicate with the Contract from the Client through a predefined Interface.
Accessing Contract
To access a Smart Contract, you need the Contract Address and ABI. Through these, you can call functions in the Smart Contract code within the DApp.
Communication in Contract
Calling
There are two ways when a user calls a Contract function:
- First, when calling a query function (when there is no state change), this request is not recorded on the blockchain (i.e. no network).
- Second, when calling a modifying function (when there is a state change), a Transaction for the modification on the blockchain is recorded.
Intercommunication
Communication between Contracts occurs through Internal Transactions, which are not recorded on the blockchain.
- It is possible to retrieve information using
trace_block
. - However, the Transaction of the DApp user who initiated the call is recorded on the blockchain.
- Functions like
delegate call
,staticcall
,call
,transfer
,selfdestruct
, etc., facilitate this communication. - This forms the fundamental concept of an Upgradeable (Proxy) Contract.