2.3.1. Smart Contract Structure
A smart contract is executable code running on a designed blockchain, prepared to facilitate the terms of an agreement between parties experiencing a mutual trust problem, to execute and execute transactions. It can be thought of as a system that allows digital asset transactions to all or some of the relevant parties after the predefined rules in smart contracts are fulfilled by the parties [29]. Compared to traditional contracts, smart contracts do not allow a trusted third party to operate, resulting in low transaction costs. Prepared smart contracts will be assigned to a unique address of 20 bytes. Once the smart contract is paired with a blockchain, the code assigned to the contract cannot be changed. In order for a contract to be run, it is sufficient for users to send the transaction they want to perform to the address of the contract. The requested transaction is then evaluated by each consensus node in the network to arrive at a consensus. The status of the contract will then be updated based on the result achieved [30].
The consensus algorithms used largely determine the performance of the distributed system for blockchains, with variables such as throughput, latency, node scalability [31]. In the prepared smart contract, the initLedger method is run to perform the initial settings that need to be made at the start of the ledger. Before new data is written to the Ledger, it is checked whether there is data with the same id. When a positive answer is received, a new object is created and the ledger registration process is started and the new record is returned at the end of the process. GetAllAsset method can be executed to read the records. After the necessary permissions are checked, the data registered in the ledger can be read and listed with the help of an iterator. The pseudo code of the smart contract created in Algorithm 1 is shown.