gnosis.eth.clients package

Submodules

gnosis.eth.clients.blockscout_client module

exception gnosis.eth.clients.blockscout_client.BlockScoutConfigurationProblem

Bases: BlockscoutClientException

class gnosis.eth.clients.blockscout_client.BlockscoutClient(network: EthereumNetwork)

Bases: object

NETWORK_WITH_URL = {<EthereumNetwork.XDAI: 100>: 'https://blockscout.com/poa/xdai/', <EthereumNetwork.MATIC: 137>: 'https://polygon-explorer-mainnet.chainstacklabs.com/', <EthereumNetwork.MUMBAI: 80001>: 'https://polygon-explorer-mumbai.chainstacklabs.com/', <EthereumNetwork.ENERGY_WEB_CHAIN: 246>: 'https://explorer.energyweb.org/', <EthereumNetwork.VOLTA: 73799>: 'https://volta-explorer.energyweb.org/', <EthereumNetwork.OLYMPUS: 333999>: 'https://explorer.polis.tech', <EthereumNetwork.BOBA_RINKEBY: 28>: 'https://blockexplorer.rinkeby.boba.network/', <EthereumNetwork.BOBA: 288>: 'https://blockexplorer.boba.network/', <EthereumNetwork.GATHER_DEVNET: 486217935>: 'https://devnet-explorer.gather.network/', <EthereumNetwork.GATHER_TESTNET: 356256156>: 'https://testnet-explorer.gather.network/', <EthereumNetwork.GATHER_MAINNET: 192837465>: 'https://explorer.gather.network/', <EthereumNetwork.METIS_TESTNET: 588>: 'https://stardust-explorer.metis.io/', <EthereumNetwork.METIS: 1088>: 'https://andromeda-explorer.metis.io/', <EthereumNetwork.FUSE_MAINNET: 122>: 'https://explorer.fuse.io/', <EthereumNetwork.VELAS_MAINNET: 106>: 'https://evmexplorer.velas.com/', <EthereumNetwork.REI_MAINNET: 47805>: 'https://scan.rei.network/', <EthereumNetwork.REI_TESTNET: 12357>: 'https://scan-test.rei.network/', <EthereumNetwork.METER: 82>: 'https://scan.meter.io/', <EthereumNetwork.METER_TESTNET: 83>: 'https://scan-warringstakes.meter.io/', <EthereumNetwork.GODWOKEN_TESTNET: 71401>: 'https://v1.betanet.gwscan.com/'}
build_url(path: str)
get_contract_metadata(address: ChecksumAddress) Optional[ContractMetadata]
exception gnosis.eth.clients.blockscout_client.BlockscoutClientException

Bases: Exception

gnosis.eth.clients.contract_metadata module

class gnosis.eth.clients.contract_metadata.ContractMetadata(name: Union[str, NoneType], abi: List[Dict[str, Any]], partial_match: bool)

Bases: object

abi: List[Dict[str, Any]]
name: Optional[str]
partial_match: bool

gnosis.eth.clients.etherscan_client module

class gnosis.eth.clients.etherscan_client.EtherscanClient(network: EthereumNetwork, api_key: Optional[str] = None)

Bases: object

HTTP_HEADERS = {'User-Agent': 'curl/7.77.0'}
NETWORK_WITH_API_URL = {<EthereumNetwork.MAINNET: 1>: 'https://api.etherscan.io', <EthereumNetwork.RINKEBY: 4>: 'https://api-rinkeby.etherscan.io', <EthereumNetwork.ROPSTEN: 3>: 'https://api-ropsten.etherscan.io', <EthereumNetwork.GOERLI: 5>: 'https://api-goerli.etherscan.io/', <EthereumNetwork.KOVAN: 42>: 'https://api-kovan.etherscan.io/', <EthereumNetwork.BINANCE: 56>: 'https://api.bscscan.com', <EthereumNetwork.MATIC: 137>: 'https://api.polygonscan.com', <EthereumNetwork.OPTIMISTIC: 10>: 'https://api-optimistic.etherscan.io', <EthereumNetwork.ARBITRUM: 42161>: 'https://api.arbiscan.io', <EthereumNetwork.AVALANCHE: 43114>: 'https://api.snowtrace.io'}
NETWORK_WITH_URL = {<EthereumNetwork.MAINNET: 1>: 'https://etherscan.io', <EthereumNetwork.RINKEBY: 4>: 'https://rinkeby.etherscan.io', <EthereumNetwork.ROPSTEN: 3>: 'https://ropsten.etherscan.io', <EthereumNetwork.GOERLI: 5>: 'https://goerli.etherscan.io', <EthereumNetwork.KOVAN: 42>: 'https://kovan.etherscan.io', <EthereumNetwork.BINANCE: 56>: 'https://bscscan.com', <EthereumNetwork.MATIC: 137>: 'https://polygonscan.com', <EthereumNetwork.OPTIMISTIC: 10>: 'https://optimistic.etherscan.io', <EthereumNetwork.ARBITRUM: 42161>: 'https://arbiscan.io', <EthereumNetwork.AVALANCHE: 43114>: 'https://snowtrace.io'}
build_url(path: str)
get_contract_abi(contract_address: str, retry: bool = True)
get_contract_metadata(contract_address: str, retry: bool = True) Optional[ContractMetadata]
get_contract_source_code(contract_address: str, retry: bool = True)

Get source code for a contract. Source code query also returns:

  • ContractName: “”,

  • CompilerVersion: “”,

  • OptimizationUsed: “”,

  • Runs: “”,

  • ConstructorArguments: “”

  • EVMVersion: “Default”,

  • Library: “”,

  • LicenseType: “”,

  • Proxy: “0”,

  • Implementation: “”,

  • SwarmSource: “”

Parameters
  • contract_address

  • retry – if True, try again if there’s Rate Limit Error

Returns

exception gnosis.eth.clients.etherscan_client.EtherscanClientConfigurationProblem

Bases: Exception

exception gnosis.eth.clients.etherscan_client.EtherscanClientException

Bases: Exception

exception gnosis.eth.clients.etherscan_client.EtherscanRateLimitError

Bases: EtherscanClientException

gnosis.eth.clients.sourcify module

class gnosis.eth.clients.sourcify.Sourcify(network: EthereumNetwork = EthereumNetwork.MAINNET, base_url: str = 'https://repo.sourcify.dev/')

Bases: object

Get contract metadata from Sourcify. Matches can be full or partial:

  • Full: Both the source files as well as the meta data files were an exact match between the deployed bytecode and the published files.

  • Partial: Source code compiles to the same bytecode and thus the contract behaves in the same way, but the source code can be different: Variables can have misleading names, comments can be different and especially the NatSpec comments could have been modified.

get_contract_metadata(contract_address: str) Optional[ContractMetadata]

Module contents