thien k phan

Solidity Function Signature

1. What is function signature?

Function signature is the part of bytes code which EVM decides to run in compiled smart contracts.

2. How it is calculated:

In this example, I use Remix IDE to compile the contract, take a look at the Compilation Details:
notion image
list(bytes32, uint256) is the function get called, with the hashed signature 345c550f
The hash is the first 8 bytes after 0x. It’s calculated through keccak256
 
Here is the transaction hash after we executed the function:
notion image
 

3. Implementations in web3 and ethers.js

 
➡️ Ether.js
➡️ Web3.js