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!