Network
Launch Date
Consensus
Note
Sepolia
Oct 2021
PoW
Like-for-like representation of Ethereum
Görli
Jan 2019
PoA
Proof-of-Authority
Kiln
Mar 2022
PoS
Post-Merge (for ETH2), shadow fork of the mainnet
Kintsugi
Dec 2021
PoS
DEPRECATED, use Kiln; post-Merge (for ETH2)
Ropsten
Nov 2016
PoW
DEPRECATED, use Sepolia; the Merge to happen on Jun 8, 2022
Rinkeby
Apr 2017
PoA
DEPRECATED, use Görli and Görli Faucet
Kovan
Mar 2017
PoA
DEPRECATED, use Sepolia or Görli
List of active and deprecated Ethereum testnets, including Kintsugi.
Features
Optimistic rollup 
ZK-rollup 
Proof
Uses fraud proofs to prove transaction validity. 
Uses validity (zero-knowledge) proofs to prove transaction validity. 
Capital efficiency
Requires waiting through a 1-week delay (dispute period) before withdrawing funds. 
Users can withdraw funds immediately because validity proofs provide incontrovertible evidence of the authenticity of off-chain transactions. 
Data compression
Publishes full transaction data as calldata to Ethereum Mainnet, which increases rollup costs. 
Doesn't need to publish transaction data on Ethereum because ZK-SNARKs and ZK-STARKs already guarantee the accuracy of the rollup state. 
EVM compatibility
Uses a simulation of the Ethereum Virtual Machine (EVM), which allows it to run arbitrary logic and support smart contracts. 
Doesn't widely support EVM computation, although a few EVM-compatible ZK-rollups have appeared. 
Rollup costs
Reduces costs since it publishes minimal data on Ethereum and doesn't have to post proofs for transactions, except in special circumstances. 
Faces higher overhead from costs involved in generating and verifying proofs for every transaction block. ZK proofs require specialized, expensive hardware to create and have high on-chain verification costs. 
Trust assumptions
Doesn't require a trusted setup. 
Requires a trusted setup to work. 
Liveness requirements
Verifiers are needed to keep tabs on the actual rollup state and the one referenced in the state root to detect fraud. 
Users don't need someone to watch the L2 chain to detect fraud. 
Security properties 
Relies on cryptoeconomic incentives to assure users of rollup security. 
Relies on cryptographic guarantees for security. 
Start building
on Alchemy.
Sign up for free
Start building on Optimism.
Sign up for free
Start building on Arbitrum.
Sign up for free
Start building on Ethereum.
Sign up for free
Start building on Polygon.
Sign up for free
Start building on Starknet.
Sign up for free
Start building on Flow.
Sign up for free
kiln faucet
Get free Kiln ETH.
Start building today
Goerli faucet
Get free Goerli ETH.
Start building today
SEPOLIA FAUCET
Get free Sepolia ETH.
Start Building Today
mumbai faucet
Get free Mumbai Matic.
Start building today
rinkeby faucet
Get free Rinkeby
ETH.
Start building today
Start building on Ethereum.
Get started for free
Start building on Ethereum.
Get started for free
Start building on Flow.
Get started for free
Start building on Polygon.
Get started for free
Start building on Starknet.
Get started for free
Start building on Optimism.
Get started for free
Start building on Solana.
Get started for free
Start building on Solana.
Sign up for beta access
Start building on Solana.
Join the waitlist
Arbitrum logo
Start building on Arbitrum.
Get started for free
Build with Alchemy's
Gas Manager & Bundler APIs
Learn
Solidity at
Alchemy
University
Get started today
Build with Alchemy's
Gas Manager & Bundler APIs
curl 
https://release.solana.com/v1.10.32/solana-install-init-x86_64-pc-windows-msvc.exe 
--output 
C:\solana-install-tmp\solana-install-init.exe 
--create-dirs
Learn Solidity
‍SOLIDITY ABI OVERVIEW

What is the Solidity ABI (Application Binary Interface)?

Everything You Need to Know About Solidity's Application Binary Interface (ABI)
Last Updated:
October 4, 2022
Table of Contents
Table of Contents
Table of Contents

{{learn-solidity}}

Ethereum developers use the Solidity programming language to write smart contract code for the Ethereum network. But how does Solidity work and interact with the Ethereum Virtual Machine (EVM)? It all begins with compiling smart contracts. 

This article explains:

  • What the Solidity ABI is through introducing the necessity of smart contract compilation
  • How the ABI works as the Solidity compiler
  • What bytecode is and its function in the process of compilation
  • What the Solidity ABI is and how it is different from an API.
  • How ABIs work (with examples)

What is smart contract compilation?

Smart contract compilation is the process that converts the Solidity smart contract code into a language compatible with the Ethereum Virtual Machine language. 

Developers write smart contracts in Solidity, a high-level programming language that is readable and understandable by humans only. The EVM cannot understand Solidity. Since the virtual machine cannot understand Solidity, compilation converts the human-understandable Solidity code into a machine-readable language. The Ethereum ecosystem uses the Solidity compiler to compile its smart contracts. 

What is the Solidity Compiler?

The Solidity compiler, also known as solc, compiles Solidity-based smart contracts into EVM understandable bytecode and the Application Binary Interface (ABI). The bytecode and Solidity contract ABI are the primary components for interacting with Ethereum smart contracts.  

What is bytecode?

The bytecode is the smart contract information in a binary format on the Ethereum Virtual Machine. The bytecode is not human-readable and can only be read by a machine (EVM). In other words, Solidity gets compiled and translated into machine-readable bytecode so that EVM can carry out the necessary functions. 

The bytecode contains a series of machine-understandable instructions called opcodes, each one-byte (eight bits) long. Thus, a bytecode is an amalgamation of one-byte opcodes. 

Bytecode is divided into two types:

  1. Creation bytecode
  2. Runtime bytecode

What is creation bytecode?

Smart contract compilation generates the creation bytecode, containing the constructor logic and constructor parameters of smart contracts. The creation bytecode is responsible for generating the runtime bytecode.

When you click on ‘compilation details’ for a smart contract on any Integrated Development Environment (IDE) platform, you see the creation bytecode. Creation bytecode is executed only once during deployment. 

To retrieve the on-chain creation bytecode, use:



type (ContractName). creationCode 

To retrieve the creation bytecode off-chain by JSON RPC call, use this method: getTransactionByHash.  

What is runtime bytecode?

The runtime bytecode is the compiled smart contract data that is stored on-chain as the permanent executable code. Unlike creation bytecode, the runtime bytecode does not contain constructor logic and constructor parameters. 

To retrieve the on-chain runtime bytecode, use:



type (ContractName). runtimeCode

To retrieve runtime bytecode off-chain by JSON RPC call, use this method: getCode

How to Interact with Bytecode

Smart contract data is stored on the EVM in machine-readable bytecode, and stored on external applications in Javascript and other smart contracts in human-readable Solidity language because they cannot communicate with bytecode. This is where the second component of smart contract compilation, the Application Binary Interface (ABI), makes the interaction possible. 

What is the Application Binary Interface (ABI) in Solidity?

The Application Binary Interface (ABI) is an interpreter that facilitates communication with the EVM bytecode. The Solidity ABI is a human-readable list of methods on a smart contract for executing particular functions. You can use the ABI with a library like ethers.js to interact with smart contracts.   

An ABI in Solidity is similar to, but also different from, an API (Application Program Interface).

What is the difference between the Solidity ABI and an API?

In web2, APIs facilitate the interaction between web applications and centralized servers, and the Solidity ABI provides smart contract data to applications and other contracts. When an application uses an API to request data from a server, the API feeds it, whereas ABIs access smart contract data in binary bytecode format known as Solidity Binaries.

In the next section, we explain what Solidity Binaries are. 

What are Solidity Binaries?

Solidity Binaries are a unique data storage infrastructure for smart contracts in the Ethereum ecosystem.  

Developers cannot deploy the human-readable Solidity code on the Ethereum blockchain. Instead, the Solidity smart contract data is stored as raw bytecode in binary format (i.e. a long string of hexadecimal characters). This is known as Solidity Binaries, which makes it cost-efficient to store data on the blockchain.

But how does the ABI access Solidity Binaries? It does so by a process called ABI encoding.     

What is Solidity ABI encoding?

The ABI calls the smart contract with function signatures and variable declarations that the EVM-based bytecode can understand. This is known as ABI encoding where the ABI encodes the necessary information for the machine-readable bytecode to process. In most cases, ABI encoding is automated and done by smart contract compilers. 

What is ABI decoding?

When the EVM-bytecode executes an instruction and returns a result, it is in a raw hexadecimal format, and the ABI decodes the hexadecimal format, which isn't human-readable, into a human-readable language. This is known as ABI decoding.

You get the Solidity code from the ABI, and basically the ABI acts as the interface for encoding/decoding data into and out of the machine code. 

How does Solidity code map to EVM opcodes?

EVM bytecode is made up of a number of opcodes. When ABI encoding calls a function, it refers to a particular opcode. After processing the transaction, the opcode returns a result, which the ABI decodes for the user. 

How do ABIs work in Solidity?

An ABI specifies which function to invoke (encoding), and executes the function to return data to the user (decoding). A smart contract contains several functions which are deployed on the EVM as bytecode, and each smart contract has its own ABI which is required to get the results. 

Since smart contracts are stored in binary format, the ABI defines the structures and methods to interact with the binary contract. Post-compilation smart contract generates an ABI represented in Solidity JSON ABI format.

Certain IDEs like Remix automatically generate the contract ABI. However, you can also manually create the ABI using the Solidity Compiler NPM package.

Solidity JSON ABI generates the following components:

  • Type - defines the nature of the function (receive, fallback, constructor) 
  • Name - defines the name of the function
  • Inputs - array of objects with name, type, components
  • Outputs - array of objects similar to inputs
  • stateMutability - defines the mutability of the function (pure, view, non-payable or payable

How does a transaction work with an ABI?

A transaction works with a Solidity ABI file in 3 steps:

  1. The ABI of a smart contract is provided to the frontend library like EtherJS.
  2. The frontend library translates the method call and arguments into calldata which is provided as part of a transaction to an Ethereum node.
  3. After a transaction is validated it generates a receipts trie containing the detailed logs and gas (transaction fees) used.

What is a receipts trie? 

An Ethereum transaction generates a receipt called ‘receipts trie’ which records the outcome of a successful transaction. A receipts trie consists of four types of information:

  1. State of the transaction
  2. Cumulative gas used
  3. Set of logs created during execution
  4. Bloom filter composed from the logs

To better understand how a transaction works, consider the following example.    

ERC-20 Token Transfer Example 

For instance, you want to transfer an ERC-20 token from one wallet to another. The following code instructs the ABI to send a message to the EVM-based bytecode. 



transfer (address to, uint amount) external;

ABI encoding ensures that the bytecode recognizes the function and executes the transaction. After generating a result, ABI decoding translates the result into a human-readable format. The user gets a receipt that ERC-20 tokens have been transferred from one address to the other.

Learn More About Solidity's ABI

While learning Solidity, you will understand that ABI is the cornerstone of Ethereum smart contracts. ABIs facilitate transactions in the blockchain ecosystem. Despite the importance of ABIs in smart contract technology, ABIs are often overlooked in developer tutorials. While beyond the scope of this article, knowing what the Solidity interface is will further your understanding of how contracts interact with each other. 

An in-depth understanding of ABI is the stepping stone towards developing robust smart contracts and dApps, and becoming a Solidity dev.

ALCHEMY SUPERNODE - ETHEREUM NODE API

Scale to any size, without any errors

Alchemy Supernode finally makes it possible to scale blockchain applications without all the headaches. Plus, our legendary support will guide you every step of the way.

Get started for free
Supernode footer
Learn Solidity
‍SOLIDITY ABI OVERVIEW

What is the Solidity ABI (Application Binary Interface)?

Everything You Need to Know About Solidity's Application Binary Interface (ABI)
Last Updated:
October 4, 2022
Last Updated:
March 14, 2023
Don't miss an update
Sign up for our newsletter to get alpha, key insights, and killer resources.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Table of Contents

Talk to an Expert

Learn how Alchemy's blockchain developer tools can help your business succeed in web3!
Valid number
Thank you! An Alchemy expert will be in touch with you shortly!
Oops! Something went wrong while submitting the form.

{{learn-solidity}}

Ethereum developers use the Solidity programming language to write smart contract code for the Ethereum network. But how does Solidity work and interact with the Ethereum Virtual Machine (EVM)? It all begins with compiling smart contracts. 

This article explains:

  • What the Solidity ABI is through introducing the necessity of smart contract compilation
  • How the ABI works as the Solidity compiler
  • What bytecode is and its function in the process of compilation
  • What the Solidity ABI is and how it is different from an API.
  • How ABIs work (with examples)

What is smart contract compilation?

Smart contract compilation is the process that converts the Solidity smart contract code into a language compatible with the Ethereum Virtual Machine language. 

Developers write smart contracts in Solidity, a high-level programming language that is readable and understandable by humans only. The EVM cannot understand Solidity. Since the virtual machine cannot understand Solidity, compilation converts the human-understandable Solidity code into a machine-readable language. The Ethereum ecosystem uses the Solidity compiler to compile its smart contracts. 

What is the Solidity Compiler?

The Solidity compiler, also known as solc, compiles Solidity-based smart contracts into EVM understandable bytecode and the Application Binary Interface (ABI). The bytecode and Solidity contract ABI are the primary components for interacting with Ethereum smart contracts.  

What is bytecode?

The bytecode is the smart contract information in a binary format on the Ethereum Virtual Machine. The bytecode is not human-readable and can only be read by a machine (EVM). In other words, Solidity gets compiled and translated into machine-readable bytecode so that EVM can carry out the necessary functions. 

The bytecode contains a series of machine-understandable instructions called opcodes, each one-byte (eight bits) long. Thus, a bytecode is an amalgamation of one-byte opcodes. 

Bytecode is divided into two types:

  1. Creation bytecode
  2. Runtime bytecode

What is creation bytecode?

Smart contract compilation generates the creation bytecode, containing the constructor logic and constructor parameters of smart contracts. The creation bytecode is responsible for generating the runtime bytecode.

When you click on ‘compilation details’ for a smart contract on any Integrated Development Environment (IDE) platform, you see the creation bytecode. Creation bytecode is executed only once during deployment. 

To retrieve the on-chain creation bytecode, use:



type (ContractName). creationCode 

To retrieve the creation bytecode off-chain by JSON RPC call, use this method: getTransactionByHash.  

What is runtime bytecode?

The runtime bytecode is the compiled smart contract data that is stored on-chain as the permanent executable code. Unlike creation bytecode, the runtime bytecode does not contain constructor logic and constructor parameters. 

To retrieve the on-chain runtime bytecode, use:



type (ContractName). runtimeCode

To retrieve runtime bytecode off-chain by JSON RPC call, use this method: getCode

How to Interact with Bytecode

Smart contract data is stored on the EVM in machine-readable bytecode, and stored on external applications in Javascript and other smart contracts in human-readable Solidity language because they cannot communicate with bytecode. This is where the second component of smart contract compilation, the Application Binary Interface (ABI), makes the interaction possible. 

What is the Application Binary Interface (ABI) in Solidity?

The Application Binary Interface (ABI) is an interpreter that facilitates communication with the EVM bytecode. The Solidity ABI is a human-readable list of methods on a smart contract for executing particular functions. You can use the ABI with a library like ethers.js to interact with smart contracts.   

An ABI in Solidity is similar to, but also different from, an API (Application Program Interface).

What is the difference between the Solidity ABI and an API?

In web2, APIs facilitate the interaction between web applications and centralized servers, and the Solidity ABI provides smart contract data to applications and other contracts. When an application uses an API to request data from a server, the API feeds it, whereas ABIs access smart contract data in binary bytecode format known as Solidity Binaries.

In the next section, we explain what Solidity Binaries are. 

What are Solidity Binaries?

Solidity Binaries are a unique data storage infrastructure for smart contracts in the Ethereum ecosystem.  

Developers cannot deploy the human-readable Solidity code on the Ethereum blockchain. Instead, the Solidity smart contract data is stored as raw bytecode in binary format (i.e. a long string of hexadecimal characters). This is known as Solidity Binaries, which makes it cost-efficient to store data on the blockchain.

But how does the ABI access Solidity Binaries? It does so by a process called ABI encoding.     

What is Solidity ABI encoding?

The ABI calls the smart contract with function signatures and variable declarations that the EVM-based bytecode can understand. This is known as ABI encoding where the ABI encodes the necessary information for the machine-readable bytecode to process. In most cases, ABI encoding is automated and done by smart contract compilers. 

What is ABI decoding?

When the EVM-bytecode executes an instruction and returns a result, it is in a raw hexadecimal format, and the ABI decodes the hexadecimal format, which isn't human-readable, into a human-readable language. This is known as ABI decoding.

You get the Solidity code from the ABI, and basically the ABI acts as the interface for encoding/decoding data into and out of the machine code. 

How does Solidity code map to EVM opcodes?

EVM bytecode is made up of a number of opcodes. When ABI encoding calls a function, it refers to a particular opcode. After processing the transaction, the opcode returns a result, which the ABI decodes for the user. 

How do ABIs work in Solidity?

An ABI specifies which function to invoke (encoding), and executes the function to return data to the user (decoding). A smart contract contains several functions which are deployed on the EVM as bytecode, and each smart contract has its own ABI which is required to get the results. 

Since smart contracts are stored in binary format, the ABI defines the structures and methods to interact with the binary contract. Post-compilation smart contract generates an ABI represented in Solidity JSON ABI format.

Certain IDEs like Remix automatically generate the contract ABI. However, you can also manually create the ABI using the Solidity Compiler NPM package.

Solidity JSON ABI generates the following components:

  • Type - defines the nature of the function (receive, fallback, constructor) 
  • Name - defines the name of the function
  • Inputs - array of objects with name, type, components
  • Outputs - array of objects similar to inputs
  • stateMutability - defines the mutability of the function (pure, view, non-payable or payable

How does a transaction work with an ABI?

A transaction works with a Solidity ABI file in 3 steps:

  1. The ABI of a smart contract is provided to the frontend library like EtherJS.
  2. The frontend library translates the method call and arguments into calldata which is provided as part of a transaction to an Ethereum node.
  3. After a transaction is validated it generates a receipts trie containing the detailed logs and gas (transaction fees) used.

What is a receipts trie? 

An Ethereum transaction generates a receipt called ‘receipts trie’ which records the outcome of a successful transaction. A receipts trie consists of four types of information:

  1. State of the transaction
  2. Cumulative gas used
  3. Set of logs created during execution
  4. Bloom filter composed from the logs

To better understand how a transaction works, consider the following example.    

ERC-20 Token Transfer Example 

For instance, you want to transfer an ERC-20 token from one wallet to another. The following code instructs the ABI to send a message to the EVM-based bytecode. 



transfer (address to, uint amount) external;

ABI encoding ensures that the bytecode recognizes the function and executes the transaction. After generating a result, ABI decoding translates the result into a human-readable format. The user gets a receipt that ERC-20 tokens have been transferred from one address to the other.

Learn More About Solidity's ABI

While learning Solidity, you will understand that ABI is the cornerstone of Ethereum smart contracts. ABIs facilitate transactions in the blockchain ecosystem. Despite the importance of ABIs in smart contract technology, ABIs are often overlooked in developer tutorials. While beyond the scope of this article, knowing what the Solidity interface is will further your understanding of how contracts interact with each other. 

An in-depth understanding of ABI is the stepping stone towards developing robust smart contracts and dApps, and becoming a Solidity dev.

Ethereum developers use the Solidity programming language to write smart contract code for the Ethereum network. But how does Solidity work and interact with the Ethereum Virtual Machine (EVM)? It all begins with compiling smart contracts. 

This article explains:

  • What the Solidity ABI is through introducing the necessity of smart contract compilation
  • How the ABI works as the Solidity compiler
  • What bytecode is and its function in the process of compilation
  • What the Solidity ABI is and how it is different from an API.
  • How ABIs work (with examples)

What is smart contract compilation?

Smart contract compilation is the process that converts the Solidity smart contract code into a language compatible with the Ethereum Virtual Machine language. 

Developers write smart contracts in Solidity, a high-level programming language that is readable and understandable by humans only. The EVM cannot understand Solidity. Since the virtual machine cannot understand Solidity, compilation converts the human-understandable Solidity code into a machine-readable language. The Ethereum ecosystem uses the Solidity compiler to compile its smart contracts. 

What is the Solidity Compiler?

The Solidity compiler, also known as solc, compiles Solidity-based smart contracts into EVM understandable bytecode and the Application Binary Interface (ABI). The bytecode and Solidity contract ABI are the primary components for interacting with Ethereum smart contracts.  

What is bytecode?

The bytecode is the smart contract information in a binary format on the Ethereum Virtual Machine. The bytecode is not human-readable and can only be read by a machine (EVM). In other words, Solidity gets compiled and translated into machine-readable bytecode so that EVM can carry out the necessary functions. 

The bytecode contains a series of machine-understandable instructions called opcodes, each one-byte (eight bits) long. Thus, a bytecode is an amalgamation of one-byte opcodes. 

Bytecode is divided into two types:

  1. Creation bytecode
  2. Runtime bytecode

What is creation bytecode?

Smart contract compilation generates the creation bytecode, containing the constructor logic and constructor parameters of smart contracts. The creation bytecode is responsible for generating the runtime bytecode.

When you click on ‘compilation details’ for a smart contract on any Integrated Development Environment (IDE) platform, you see the creation bytecode. Creation bytecode is executed only once during deployment. 

To retrieve the on-chain creation bytecode, use:



type (ContractName). creationCode 

To retrieve the creation bytecode off-chain by JSON RPC call, use this method: getTransactionByHash.  

What is runtime bytecode?

The runtime bytecode is the compiled smart contract data that is stored on-chain as the permanent executable code. Unlike creation bytecode, the runtime bytecode does not contain constructor logic and constructor parameters. 

To retrieve the on-chain runtime bytecode, use:



type (ContractName). runtimeCode

To retrieve runtime bytecode off-chain by JSON RPC call, use this method: getCode

How to Interact with Bytecode

Smart contract data is stored on the EVM in machine-readable bytecode, and stored on external applications in Javascript and other smart contracts in human-readable Solidity language because they cannot communicate with bytecode. This is where the second component of smart contract compilation, the Application Binary Interface (ABI), makes the interaction possible. 

What is the Application Binary Interface (ABI) in Solidity?

The Application Binary Interface (ABI) is an interpreter that facilitates communication with the EVM bytecode. The Solidity ABI is a human-readable list of methods on a smart contract for executing particular functions. You can use the ABI with a library like ethers.js to interact with smart contracts.   

An ABI in Solidity is similar to, but also different from, an API (Application Program Interface).

What is the difference between the Solidity ABI and an API?

In web2, APIs facilitate the interaction between web applications and centralized servers, and the Solidity ABI provides smart contract data to applications and other contracts. When an application uses an API to request data from a server, the API feeds it, whereas ABIs access smart contract data in binary bytecode format known as Solidity Binaries.

In the next section, we explain what Solidity Binaries are. 

What are Solidity Binaries?

Solidity Binaries are a unique data storage infrastructure for smart contracts in the Ethereum ecosystem.  

Developers cannot deploy the human-readable Solidity code on the Ethereum blockchain. Instead, the Solidity smart contract data is stored as raw bytecode in binary format (i.e. a long string of hexadecimal characters). This is known as Solidity Binaries, which makes it cost-efficient to store data on the blockchain.

But how does the ABI access Solidity Binaries? It does so by a process called ABI encoding.     

What is Solidity ABI encoding?

The ABI calls the smart contract with function signatures and variable declarations that the EVM-based bytecode can understand. This is known as ABI encoding where the ABI encodes the necessary information for the machine-readable bytecode to process. In most cases, ABI encoding is automated and done by smart contract compilers. 

What is ABI decoding?

When the EVM-bytecode executes an instruction and returns a result, it is in a raw hexadecimal format, and the ABI decodes the hexadecimal format, which isn't human-readable, into a human-readable language. This is known as ABI decoding.

You get the Solidity code from the ABI, and basically the ABI acts as the interface for encoding/decoding data into and out of the machine code. 

How does Solidity code map to EVM opcodes?

EVM bytecode is made up of a number of opcodes. When ABI encoding calls a function, it refers to a particular opcode. After processing the transaction, the opcode returns a result, which the ABI decodes for the user. 

How do ABIs work in Solidity?

An ABI specifies which function to invoke (encoding), and executes the function to return data to the user (decoding). A smart contract contains several functions which are deployed on the EVM as bytecode, and each smart contract has its own ABI which is required to get the results. 

Since smart contracts are stored in binary format, the ABI defines the structures and methods to interact with the binary contract. Post-compilation smart contract generates an ABI represented in Solidity JSON ABI format.

Certain IDEs like Remix automatically generate the contract ABI. However, you can also manually create the ABI using the Solidity Compiler NPM package.

Solidity JSON ABI generates the following components:

  • Type - defines the nature of the function (receive, fallback, constructor) 
  • Name - defines the name of the function
  • Inputs - array of objects with name, type, components
  • Outputs - array of objects similar to inputs
  • stateMutability - defines the mutability of the function (pure, view, non-payable or payable

How does a transaction work with an ABI?

A transaction works with a Solidity ABI file in 3 steps:

  1. The ABI of a smart contract is provided to the frontend library like EtherJS.
  2. The frontend library translates the method call and arguments into calldata which is provided as part of a transaction to an Ethereum node.
  3. After a transaction is validated it generates a receipts trie containing the detailed logs and gas (transaction fees) used.

What is a receipts trie? 

An Ethereum transaction generates a receipt called ‘receipts trie’ which records the outcome of a successful transaction. A receipts trie consists of four types of information:

  1. State of the transaction
  2. Cumulative gas used
  3. Set of logs created during execution
  4. Bloom filter composed from the logs

To better understand how a transaction works, consider the following example.    

ERC-20 Token Transfer Example 

For instance, you want to transfer an ERC-20 token from one wallet to another. The following code instructs the ABI to send a message to the EVM-based bytecode. 



transfer (address to, uint amount) external;

ABI encoding ensures that the bytecode recognizes the function and executes the transaction. After generating a result, ABI decoding translates the result into a human-readable format. The user gets a receipt that ERC-20 tokens have been transferred from one address to the other.

Learn More About Solidity's ABI

While learning Solidity, you will understand that ABI is the cornerstone of Ethereum smart contracts. ABIs facilitate transactions in the blockchain ecosystem. Despite the importance of ABIs in smart contract technology, ABIs are often overlooked in developer tutorials. While beyond the scope of this article, knowing what the Solidity interface is will further your understanding of how contracts interact with each other. 

An in-depth understanding of ABI is the stepping stone towards developing robust smart contracts and dApps, and becoming a Solidity dev.

{{learn-solidity}}

Contact Us

Talk to an expert at Alchemy to answer all of your product questions.
Valid number
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Build blockchain magic with Alchemy

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get started for free