Understanding the ABI Array
Letās consider the following - very simple - Smart Contract:
//SPDX-License-Identifier: MIT
pragma solidity ^0.5.13;
contract MyContract {
string public myString = 'hello world!';
}
Add this contract to Remix and head over to the āSolidity Compilerā, then click the āCompilation Detailsā
View the Bytecode of the Contract
If you open the āBytecodeā section, youāll see the bytecode, as well as the opcodes from this smart contract. More on that a little bit later!
View the Function Hashes
If you open the āFunction Hashesā section, youāll see the function signatures of the Smart Contract.
Remember, the function signature is a keccak hash of the function string (i.e. keccak256('myString()')
) and from that the first 4 bytes (8 hex characters):
If you run the web3-sha3 hash on the Remix terminal youāll get the same result (just take the first 8 characters after the 0x):
Letās see what happens if we interact with the Smart Contract - youāll see the same function hash againā¦
Deploy and Interact with the Smart Contract
Letās head over to the āDeploy and Run Transaction Tabā and deploy the Smart Contract.
Have a look what happens when you interact with āmyStringā:
- Deploy the Contract
- hit the āmyStringā button
- Observe the Transaction window.
If you open the Transaction Details and pay close attention to the input field (or copy the value somewhere - it should be ā0x492bfa18ā), youāll see the exact same function signature. Because thatās how the EVM determines which part of the code to run, based on the data field of the transaction!
Letās have a look into Debugging Smart Contracts next!