Skip to Content
Courses

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ā€

ethereum-blockchain-developer-image

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!

ethereum-blockchain-developer-image

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):

ethereum-blockchain-developer-image

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):

ethereum-blockchain-developer-image

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.

ethereum-blockchain-developer-image

Have a look what happens when you interact with ā€œmyStringā€:

  1. Deploy the Contract
  2. hit the ā€œmyStringā€ button
  3. 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!

ethereum-blockchain-developer-image

Let’s have a look into Debugging Smart Contracts next!

Last updated on