Examining smart contract execution under the hood
When interacting with smart contracts on the Ethereum blockchain, the Ethereum Web3 API or JSON-API interface uses the contract’s application binary interface (ABI) as the standard way to encode and decode the methods we call, as well as the input and output data. The same applies to calls from outside of the blockchain and calls between contracts. Data is encoded according to its type, as described in the ABI specification.
All the functions and events within the smart contract can be described using JSON descriptors, as shown in the following screenshot. A JSON description of the deposit
( the _tenant
string memory) method is shown in the red box, while the RentPaid
event is shown in the purple box:
Figure 6.23 – ABI for the Rent contract
When the deposit
method is called, it will generate a function selector, which is calculated as the first 4 bytes of the keccak256
hash of the deposit...