Skip to main content

ABI

An Application Binary Interface defines how external software encodes calls to and decodes results from a smart contract.

Definition

An Application Binary Interface defines how external software encodes calls to and decodes results from a smart contract.

Why it matters

Smart-contract concepts are essential for understanding programmable blockchain applications.

How it works

The ABI is represented as a JSON file generated by the compiler during contract compilation. When a transaction is sent, the function name and parameters are hashed using the Keccak-256 algorithm based on the ABI specifications. The resulting data is then appended to the transaction, telling the smart contract exactly which function to run.

Real-world example

When you interact with a Uniswap v3 pool via their website, the site uses an ABI to format your trade request into a transaction that the Uniswap smart contract can understand.

Advantages

  • Enables communication between front-end and blockchain
  • Standardizes data encoding and decoding processes
  • Simplifies dApp integration with smart contracts

Limitations

  • Can be bulky for complex contracts
  • Requires strict version management
  • Potential for errors if ABI mismatch occurs

Common misconceptions

  • Many people think the ABI is part of the contract code itself, but it is actually a metadata file stored externally.
  • Others believe the ABI is required for on-chain execution, but it is only necessary for off-chain tools to communicate with the contract.

Canonical knowledge ID: glossary:abi