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.
Example:
IERC20 = get_contract(web3, "sushi/IERC20.json")
- Parameters
web3 (web3.main.Web3) – Web3 instance
bytecode (Optional[str]) – Override bytecode payload for the contract
fname (str | pathlib.Path) –
Solidity compiler artifact.
Use slash prefixed path for absolute lookups.
- Returns
Contract proxy class
- Return type
Type[web3.contract.contract.Contract]