How to get a smart contracts ABI for use in Web3.py and Python?

If you want to use Python to interact with a Solidity smart contract you need to know the contracts address or account number and the contracts ABI (application binary interface). The contracts ABI is the how you call functions in a contract and get data back. It is list of the contract’s functions and arguments (in JSON1 format). All of the contracts functions are specified in the contracts ABI.

The quickest way to get a contracts ABI is via Ether Scan.

  1. Visit Ether Scan
  2. Input the smart contract address into the search bar at the top of the screen
  3. Scroll down about half way and select the “Contract” tab

How to get a smart contracts ABI for use in Web3.py and Python Etherscan

4. Scroll down a little further and you will see the contracts ABI.

5. There is a handy copy ABI to clipboard function which makes it very easy to copy this text into your code

How to get a smart contracts ABI for use in Web3.py and Python Etherscan

Next – Read Solidity smart contract data using Web3.py in Python

Leave a Reply