The ABI (Application Binary Interface) in Solidity is a standard way to describe how to interact with a smart contract. The ABI acts as a bridge between the bytecode and applications that want to use it.
The ABI specifies the contract's public and external functions, including their names, input parameters (types and order), return types, and whether they modify state (payable, view, pure). It also includes events that the contract emits and custom error definitions.
To make a function call on a contract from a web3 library (like ethers.js or web3.js), the contract address and the ABI must be provided. The library uses the ABI to know how to format the function call correctly and encode it into the bytecode that the EVM understands. When the contract returns data, the ABI tells the library how to decode it back into readable values.
When a Solidity smart contract is compiled with tools like Foundry, Hardhat or Truffle, the compiler automatically generates the ABI and saves it alongside your bytecode. This is represented as a JSON artifact that can be used in frontends or other tools.
Top comments (0)