Contract ABI (Application Binary Interface)
The description of a contract's functions and types, needed to build a valid call and read the reply.
Basically
A contract ABI tells your wallet or app how to talk to an Ethereum smart contract. It turns your request into data the contract can read and turns the reply back into readable information.
Key Takeaways
- A contract ABI is a JSON specification that describes a smart contract's external interface: its functions, events, errors, and their parameter types. Without it, applications cannot encode transactions or decode responses.
- ABI encoding converts human-readable function calls into raw calldata. It combines a 4-byte function selector, derived from the keccak-256 hash of the function signature, with encoded arguments padded to 32-byte boundaries.
- Every wallet, dApp, and developer tool depends on the ABI to construct transactions, parse event logs, and interpret revert errors. Sending a transaction with the wrong ABI can lead to reverts, silent failures, or unintended state changes.
What Is a Contract ABI?
A contract ABI (Application Binary Interface) is the standard way to interact with smart contracts in the Ethereum ecosystem. It acts as a translation layer between human-readable function calls and the raw bytecode that the Ethereum Virtual Machine (EVM) executes. You can think of it as an API specification for a smart contract: it tells external software exactly which functions exist, what parameters they accept, and what they return.
The ABI is generated automatically when Solidity source code is compiled. The compiler analyses every public and external function, event, error, and the constructor, then outputs a JSON array describing each interface element. Wallets, dApps, block explorers, and developer libraries use this JSON to interact with deployed contracts, but the ABI captures only the external interface and contains no implementation logic, storage layout, or private function details.
You would need to construct raw hexadecimal calldata manually without an ABI: computing function selectors, padding arguments to 32-byte boundaries, and decoding return values byte by byte. The ABI makes this process automatic and reliable.
How It Works
ABI encoding follows a precise specification maintained in the Solidity documentation. The process converts a function call into a byte sequence that the EVM can execute.
Function Selectors
Every function call begins with a 4-byte function selector. The selector is computed by taking the first 4 bytes of the keccak-256 hash of the function's canonical signature. The canonical signature uses the function name followed by parenthesised parameter types, separated by commas with no spaces.
The EVM reads the first 4 bytes of calldata when a transaction hits a contract and compares them against a dispatch table compiled into the contract bytecode. Execution jumps to that function's code if a match is found. The contract's fallback function executes if no match is found, or the transaction reverts if no fallback exists.
Parameter Encoding
Function arguments are ABI-encoded as a tuple after the 4-byte selector. Every value is padded to 32-byte (256-bit) word boundaries. The encoding distinguishes between static and dynamic types.
A call to transfer(address,uint256) with a recipient address and an amount of 100 tokens produces calldata structured as follows. The resulting calldata contains the selector followed by the encoded recipient address and amount.
ABI Entry Types
The ABI JSON array contains different entry types, each describing a distinct part of the contract interface. Together, these entries describe the contract's external interface.
Each function entry includes a stateMutability field indicating whether it reads state (view), modifies state (nonpayable), accepts Ether (payable), or does neither (pure). The field tells wallets whether to send a transaction or make a free read-only call.
ABI JSON Example
A simple ERC-20 token's ABI includes entries like these. Each entry describes part of the token's external interface.
Event Log Decoding
Events are a key part of the ABI. When a contract emits an event, the EVM writes log entries with up to four "topics" and a data field. The first topic is the keccak-256 hash of the event signature unless the event is declared anonymous, while indexed parameters become additional topics and non-indexed parameters are ABI-encoded together in the data field.
dApps use the ABI to decode these logs into structured data. For example, when monitoring ERC-20 transfers, an application matches the Transfer event signature hash against topics[0], extracts the sender and recipient from topics[1] and topics[2], and decodes the transfer amount from the data field.
From Source Code to ABI
The ABI is a byproduct of compiling Solidity (or Vyper) source code. The compiler extracts the external interface and outputs it as a JSON artifact alongside the contract bytecode. Common toolchains generate ABIs automatically.
You can retrieve a deployed contract's ABI from block explorers if the source code was verified. You can also reverse-engineer it from the deployed bytecode by analysing the function dispatch table. Reverse-engineered ABIs lose parameter names since those are not stored on-chain.
How Wallets and dApps Use the ABI
Every interaction between a user and a smart contract flows through the ABI. Developer libraries like ethers.js and web3.js abstract this process into simple JavaScript calls.
The ABI also enables wallets to show you meaningful information before you sign. Instead of displaying raw hexadecimal calldata, a wallet with the contract's ABI can decode the calldata and show: "Transfer 100 USDC to 0x5B38...". Transaction simulation uses the same decoding to predict the effects of pending transactions before execution.
Token approvals are another common ABI-driven interaction. When you approve a DeFi protocol to spend your tokens, the wallet encodes an approve(address,uint256) call using the ERC-20 ABI. Without the correct ABI, the wallet cannot construct this call properly, and you cannot interact with the protocol.
DeFi Protocol Integration
DeFi applications depend on ABIs to compose interactions across multiple contracts, and a single swap on a decentralised exchange might require encoding calls to a router contract, a liquidity pool, and one or more token contracts. Each call uses the respective contract's ABI to construct the correct calldata. Protocol aggregators and DEX aggregators maintain ABI libraries for hundreds of contracts to route transactions optimally.
Block Explorer Verification
Developers can verify their contract source code on block explorers like Etherscan, which compile the code and publish the resulting ABI. Anyone can then read the contract's functions, call view methods directly from the explorer, and decode historical transactions and event logs. Verified ABIs are a cornerstone of blockchain transparency.
Wallet Transaction Decoding
Modern wallets use ABIs to protect users from blind signing. A registry of known contract ABIs lets wallets decode incoming transaction requests and display human-readable descriptions. EIP-7896 (proposed in 2025) aims to formalise this by letting dApps attach ABI JSON directly to transaction requests, enabling wallets to decode any transaction without needing a pre-existing ABI registry.
Cross-Chain Applications
The ABI specification originated on Ethereum but is used across all EVM-compatible chains. Applications interacting with smart contracts on networks like Solana (via Neon EVM) or rollups like Arbitrum and Optimism use the same ABI encoding standard. The shared standard makes cross-chain development more consistent for EVM-based ecosystems.
ABI Mismatch and Stale ABIs
An incorrect or outdated ABI is one of the most common sources of failed transactions. A contract upgraded behind a proxy can cause problems if the dApp still uses the old implementation's ABI: function selectors may not match, parameters may be misaligned, or new functions may be invisible. The transaction either reverts or, worse, executes an unintended function whose selector happens to collide.
Selector Collisions
Function selectors are only 4 bytes, giving roughly 4.3 billion possible values, so different function signatures can produce the same selector. The Solidity compiler prevents collisions within a single contract, but malicious contracts can deliberately create functions with selectors that match common operations like transfer. Attackers can exploit this in phishing attacks where a transaction appears to do one thing but actually executes a different function.
Blind Signing Without ABI
A wallet without the ABI for a contract cannot decode the transaction calldata. You see only raw hexadecimal data and must either trust the dApp or refuse to sign. Attackers have used this "blind signing" problem in numerous phishing attacks, where malicious dApps trick users into signing token approvals or other dangerous transactions disguised as benign operations.
ABI Does Not Guarantee Safety
The ABI describes what a contract's functions look like, not what they do, so a function named claimRewards could internally drain the caller's tokens. Transaction simulation and smart contract audits are needed to verify actual behaviour because the ABI exposes the interface, not the implementation. You need to understand the ABI as a first step, but wallet security requires multiple layers of defence.
Why It Matters
The contract ABI is foundational infrastructure for the entire EVM ecosystem, and every token transfer, swap, NFT mint, and governance vote flows through ABI encoding. As decentralised applications grow more complex and traditional finance converges with DeFi, the ABI remains the critical bridge between user intent and on-chain execution. Builders working across Bitcoin and Ethereum ecosystems need to understand ABIs to design interoperable payment flows and contract interactions.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.