get_contract

Documentation for eth_defi.abi.get_contract function.

get_contract(web3, fname, bytecode=None)

Get Contract proxy class from ABI JSON file.

Read ABI file from - Our bundled contracts in the Python package - Filesystem using absolute path - ABI file can be a solc compiling artifact or Etherscan copy-pasted ABI.

See Web3.py documentation on Contract instances.

Any results are cached. Web3 connection is part of the cache key.

Note

If the contract requires library linking (Forge linkReferences), use get_contract_with_forge_libraries() instead.

Example:

IERC20 = get_contract(web3, "sushi/IERC20.json")
Parameters
Returns

Contract proxy class

Return type

Type[web3.contract.contract.Contract]