safe_eth.eth.clients package

Submodules

safe_eth.eth.clients.blockscout_client module

class safe_eth.eth.clients.blockscout_client.AsyncBlockscoutClient(network: EthereumNetwork, request_timeout: int = 10, max_requests: int = 100)

Bases: BlockscoutClient

async async_get_contract_metadata(address: ChecksumAddress) ContractMetadata | None
exception safe_eth.eth.clients.blockscout_client.BlockScoutConfigurationProblem

Bases: BlockscoutClientException

class safe_eth.eth.clients.blockscout_client.BlockscoutClient(network: EthereumNetwork, request_timeout: int = 10)

Bases: object

NETWORK_WITH_URL = {EthereumNetwork.ACALA_NETWORK: 'https://blockscout.acala.network/api/v2/', EthereumNetwork.ALEPH_ZERO: 'https://evm-explorer-testnet.alephzero.org/api/v2/', EthereumNetwork.ALEPH_ZERO_EVM: 'https://evm-explorer.alephzero.org/api/v2/', EthereumNetwork.ARBITRUM_BLUEBERRY: 'https://arb-blueberry.gelatoscout.com/api/v2/', EthereumNetwork.ARENA_Z: 'https://explorer.arena-z.gg/api/v2', EthereumNetwork.ARTHERA_MAINNET: 'https://explorer.arthera.net/api/v2/', EthereumNetwork.ARTHERA_TESTNET: 'https://explorer-test.arthera.net/api/v2/', EthereumNetwork.ASTAR: 'https://astar.blockscout.com/api/v2/', EthereumNetwork.ASTAR_ZKEVM: 'https://astar-zkevm.explorer.startale.com/api/v2/', EthereumNetwork.AURORIA_TESTNET: 'https://auroria.explorer.stratisevm.com/api/v2/', EthereumNetwork.AUTONITY_PICCADILLY_TIBER_TESTNET: 'https://piccadilly.autonity.org/api/v2', EthereumNetwork.AUTONOMYS_CHRONOS_TESTNET: 'https://explorer.auto-evm.chronos.autonomys.xyz/api/v2/', EthereumNetwork.AUTONOMYS_MAINNET: 'https://explorer.auto-evm.mainnet.autonomys.xyz/api/v2/', EthereumNetwork.AUTONOMYS_TAURUS_TESTNET: 'https://explorer.auto-evm.taurus.autonomys.xyz/api/v2/', EthereumNetwork.BAHAMUT: 'https://api.ftnscan.com/api/v2/', EthereumNetwork.BIRDLAYER: 'https://scan.birdlayer.xyz/api/v2', EthereumNetwork.BITROCK_TESTNET: 'https://testnetscan.bit-rock.io/api/v2/', EthereumNetwork.BOB: 'https://explorer-bob-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.BOB_SEPOLIA: 'https://bob-sepolia.explorer.gobob.xyz/api/v2/', EthereumNetwork.CITREA_TESTNET: 'https://explorer.testnet.citrea.xyz/api/v2/', EthereumNetwork.CONNEXT_SEPOLIA: 'https://scan.testnet.everclear.org/api/v2/', EthereumNetwork.DODOCHAIN_TESTNET: 'https://testnet-scan.dodochain.com/api/v2/', EthereumNetwork.EDU_CHAIN_TESTNET: 'https://edu-chain-testnet.blockscout.com/api/v2/', EthereumNetwork.ENI_MAINNET: 'https://scan.eniac.network/api/v2', EthereumNetwork.ETHEREAL_TESTNET: 'https://explorer-ethereal-testnet-0.t.conduit.xyz/api/v2', EthereumNetwork.ETHERLINK_MAINNET: 'https://explorer.etherlink.com/api/v2/', EthereumNetwork.ETHERLINK_SHADOWNET_TESTNET: 'https://shadownet.explorer.etherlink.com/api/v2', EthereumNetwork.ETHERLINK_TESTNET: 'https://testnet.explorer.etherlink.com/api/v2/', EthereumNetwork.EVERCLEAR_MAINNET: 'https://scan.everclear.org/api/v2/', EthereumNetwork.EVMOS: 'https://evm.evmos.org/api/v2/', EthereumNetwork.EVM_ON_FLOW: 'https://evm.flowscan.io/api/v2', EthereumNetwork.EVM_ON_FLOW_TESTNET: 'https://evm-testnet.flowscan.io/api/v2', EthereumNetwork.EXSAT_MAINNET: 'https://scan.exsat.network/api/v2/', EthereumNetwork.EXSAT_TESTNET: 'https://scan-testnet.exsat.network/api/v2/', EthereumNetwork.FLARE_MAINNET: 'https://flare-explorer.flare.network/api/v2/', EthereumNetwork.FLARE_TESTNET_COSTON2: 'https://coston2-explorer.flare.network/api/v2/', EthereumNetwork.GAME7: 'https://mainnet.game7.io/api/v2/', EthereumNetwork.GAME7_TESTNET: 'https://testnet.game7.io/api/v2/', EthereumNetwork.GNOSIS: 'https://gnosis.blockscout.com/api/v2/', EthereumNetwork.GNOSIS_CHIADO_TESTNET: 'https://gnosis-chiado.blockscout.com/api/v2/', EthereumNetwork.GPT_MAINNET: 'https://explorer.gptprotocol.io/api/v2/', EthereumNetwork.GRAVITY_ALPHA_MAINNET: 'https://explorer-gravity-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.GRAVITY_ALPHA_TESTNET_SEPOLIA: 'https://explorer-gravity-alpha-testnet-sepolia-3ggx92odhy.t.conduit.xyz/api/v2/', EthereumNetwork.HAQQ_CHAIN_TESTNET: 'https://explorer.testedge2.haqq.network/api/v2/', EthereumNetwork.HAQQ_NETWORK: 'https://explorer.haqq.network/api/v2/', EthereumNetwork.HASHKEY_CHAIN: 'https://explorer.hsk.xyz/api/v2/', EthereumNetwork.HASHKEY_CHAIN_TESTNET: 'https://hashkeychain-testnet-explorer.alt.technology/api/v2/', EthereumNetwork.HPP_MAINNET: 'https://explorer.hpp.io/api/v2', EthereumNetwork.HPP_SEPOLIA: 'https://sepolia-explorer.hpp.io/api/v2', EthereumNetwork.IMMUTABLE_ZKEVM: 'https://explorer.immutable.com/api/v2/', EthereumNetwork.IMMUTABLE_ZKEVM_TESTNET: 'https://explorer.testnet.immutable.com/api/v2/', EthereumNetwork.INCENTIV_TESTNET: 'https://explorer-testnet.incentiv.io/api/v2', EthereumNetwork.INK_SEPOLIA: 'https://explorer-sepolia.inkonchain.com/api/v2/', EthereumNetwork.IOTA_EVM: 'https://iota-evm.blockscout.com/api/v2/', EthereumNetwork.JAPAN_OPEN_CHAIN_MAINNET: 'https://mainnet.japanopenchain.org/api/v2/', EthereumNetwork.JAPAN_OPEN_CHAIN_TESTNET: 'https://explorer.testnet.japanopenchain.org/api/v2/', EthereumNetwork.KAIA_KAIROS_TESTNET: 'https://baobab.scope.klaytn.com/api/v2/', EthereumNetwork.KAIA_MAINNET: 'https://scope.klaytn.com/api/v2/', EthereumNetwork.KROMA: 'https://blockscout.kroma.network/api/v2/', EthereumNetwork.KROMA_SEPOLIA: 'https://blockscout.sepolia.kroma.network/api/v2/', EthereumNetwork.LINEA: 'https://api-explorer.linea.build/api/v2/', EthereumNetwork.LINEA_SEPOLIA: 'https://api-explorer.sepolia.linea.build/api/v2/', EthereumNetwork.LISK: 'https://blockscout.lisk.com/api/v2/', EthereumNetwork.LISK_SEPOLIA_TESTNET: 'https://sepolia-blockscout.lisk.com/api/v2/', EthereumNetwork.LORENZO: 'https://scan.lorenzo-protocol.xyz/api/v2/', EthereumNetwork.MANTA_PACIFIC_MAINNET: 'https://pacific-explorer.manta.network/api/v2/', EthereumNetwork.MANTLE: 'https://explorer.mantle.xyz/api/v2/', EthereumNetwork.MANTLE_SEPOLIA_TESTNET: 'https://explorer.sepolia.mantle.xyz/api/v2/', EthereumNetwork.MANTLE_TESTNET: 'https://explorer.testnet.mantle.xyz/api/v2/', EthereumNetwork.MANTRACHAIN_TESTNET: 'https://explorer.dukong.io/api/v2/', EthereumNetwork.METER_MAINNET: 'https://scan.meter.io/api/v2/', EthereumNetwork.METER_TESTNET: 'https://scan-warringstakes.meter.io/api/v2/', EthereumNetwork.MINT_MAINNET: 'https://explorer-mint-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.MODE: 'https://explorer-mode-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.MODE_TESTNET: 'https://sepolia.explorer.mode.network/api/v2/', EthereumNetwork.MORPH_HOODI: 'https://explorer-api-hoodi.morphl2.io/api/v2', EthereumNetwork.NAL_SEPOLIA_TESTNET: 'https://testnet-scan.nal.network/api/v2/', EthereumNetwork.NEON_EVM_DEVNET: 'https://neon-devnet.blockscout.com/api/v2/', EthereumNetwork.NEON_EVM_MAINNET: 'https://neon.blockscout.com/api/v2/', EthereumNetwork.OP_CELESTIA_RASPBERRY: 'https://opcelestia-raspberry.gelatoscout.com/api/v2/', EthereumNetwork.OP_SEPOLIA_TESTNET: 'https://optimism-sepolia.blockscout.com/api/v2/', EthereumNetwork.PAIX_DEVELOPMENT_NETWORK: 'https://blockscout.ppaix.com/api/v2', EthereumNetwork.PLUME_DEVNET: 'https://test-explorer.plumenetwork.xyz/api/v2/', EthereumNetwork.PLUME_MAINNET: 'https://phoenix-explorer.plumenetwork.xyz/api/v2/', EthereumNetwork.Q_MAINNET: 'https://explorer.q.org/api/v2/', EthereumNetwork.Q_TESTNET: 'https://explorer.qtestnet.org/api/v2/', EthereumNetwork.REDSTONE: 'https://explorer.redstone.xyz/api/v2/', EthereumNetwork.REYA_NETWORK: 'https://explorer.reya.network/api/v2/', EthereumNetwork.RE_AL: 'https://explorer.re.al/api/v2/', EthereumNetwork.ROOTSTOCK_MAINNET: 'https://rootstock.blockscout.com/api/v2/', EthereumNetwork.ROOTSTOCK_TESTNET: 'https://rootstock-testnet.blockscout.com/api/v2/', EthereumNetwork.SAAKURU_MAINNET: 'https://explorer.saakuru.network/api/v2/', EthereumNetwork.SAGA: 'https://api-sagaevm-5464-1.sagaexplorer.io/api/v2/', EthereumNetwork.SHAPE: 'https://shapescan.xyz/api/v2', EthereumNetwork.SHAPE_SEPOLIA_TESTNET: 'https://sepolia.shapescan.xyz/api/v2/', EthereumNetwork.SNAXCHAIN: 'https://explorer.snaxchain.io/api/v2/', EthereumNetwork.SONEIUM_TESTNET_MINATO: 'https://soneium-minato.blockscout.com/api/v2/', EthereumNetwork.SONGBIRD_CANARY_NETWORK: 'https://songbird-explorer.flare.network/api/v2/', EthereumNetwork.SONGBIRD_TESTNET_COSTON: 'https://coston-explorer.flare.network/api/v2/', EthereumNetwork.STORY: 'https://mainnet.storyscan.xyz/api/v2/', EthereumNetwork.STORY_AENEID_TESTNET: 'https://aeneid.storyscan.io/api/v2/', EthereumNetwork.STORY_ODYSSEY_TESTNET: 'https://odyssey-testnet-explorer.storyscan.xyz/api/v2/', EthereumNetwork.SWELLCHAIN: 'https://explorer.swellnetwork.io/api/v2/', EthereumNetwork.SWELLCHAIN_TESTNET: 'https://swell-testnet-explorer.alt.technology/api/v2/', EthereumNetwork.TAC_MAINNET: 'https://explorer.tac.build/api/v2/', EthereumNetwork.TAC_SAINT_PETERSBURG: 'https://spb.explorer.tac.build/api/v2/', EthereumNetwork.TAC_TURIN: 'https://turin.explorer.tac.build/api/v2', EthereumNetwork.TAIKO_HEKLA_L2: 'https://blockscoutapi.hekla.taiko.xyz/api/v2/', EthereumNetwork.VANA: 'https://vanascan.io/api/v2/', EthereumNetwork.VANA_MOKSHA_TESTNET: 'https://moksha.vanascan.io/api/v2/', EthereumNetwork.ZETACHAIN_MAINNET: 'https://zetascan.com/api/v2/', EthereumNetwork.ZETACHAIN_TESTNET: 'https://testnet.zetascan.com/api/v2/', EthereumNetwork.ZORA: 'https://explorer.zora.energy/api/v2/', EthereumNetwork.ZORA_SEPOLIA_TESTNET: 'https://sepolia.explorer.zora.energy/api/v2/'}
build_url(path: str)
get_contract_metadata(address: ChecksumAddress) ContractMetadata | None
exception safe_eth.eth.clients.blockscout_client.BlockscoutClientException

Bases: Exception

safe_eth.eth.clients.contract_metadata module

class safe_eth.eth.clients.contract_metadata.ContractMetadata(name: str | None, abi: List[Dict[str, Any]], partial_match: bool, implementation: str | None = None)

Bases: object

abi: List[Dict[str, Any]]
implementation: str | None = None
name: str | None
partial_match: bool

safe_eth.eth.clients.ens_client module

class safe_eth.eth.clients.ens_client.EnsClient(config: Config)

Bases: object

Resolves Ethereum Name Service domains using thegraph API

class Config(base_url: str)

Bases: object

base_url: str
property url: str
class SubgraphConfig(base_url: str, api_key: str, subgraph_id: str)

Bases: Config

api_key: str
subgraph_id: str
property url
static domain_hash_to_hex_str(domain_hash: HexStr | bytes | int) HexStr
Parameters:

domain_hash

Returns:

Domain hash as an hex string of 66 chars (counting with 0x), padding with zeros if needed

is_available() bool
Returns:

True if service is available, False if it’s down

query_by_account(account: str) List[Dict[str, Any]] | None
Parameters:

account – ethereum account to search for ENS registered addresses

Returns:

None if there’s a problem or not found, otherwise example of dictionary returned:

{
“registrations”: [
{
“domain”: {

“isMigrated”: true, “labelName”: “gilfoyle”, “labelhash”: “0xadfd886b420023026d5c0b1be0ffb5f18bb2f37143dff545aeaea0d23a4ba910”, “name”: “gilfoyle.eth”, “parent”: {

“name”: “eth”

}

}, “expiryDate”: “1905460880”

}

]

}

query_by_domain_hash(domain_hash: HexStr | bytes | int) str | None

Get domain label from domain_hash (keccak of domain name without the TLD, don’t confuse with namehash) used for ENS ERC721 token_id. Use another method for caching purposes (use same parameter type)

Parameters:

domain_hash – keccak of domain name without the TLD, don’t confuse with namehash. E.g. For batman.eth it would be just keccak(‘batman’)

Returns:

domain label if found

safe_eth.eth.clients.etherscan_client module

safe_eth.eth.clients.sourcify_client module

class safe_eth.eth.clients.sourcify_client.AsyncSourcifyClient(network: EthereumNetwork = EthereumNetwork.MAINNET, base_url_api: str = 'https://sourcify.dev', base_url_repo: str = 'https://repo.sourcify.dev/', request_timeout: int = 10, max_requests: int = 100)

Bases: SourcifyClient

async async_get_contract_metadata(contract_address: str) ContractMetadata | None

Asynchronous version of get_contract_metadata

class safe_eth.eth.clients.sourcify_client.SourcifyClient(network: EthereumNetwork = EthereumNetwork.MAINNET, base_url_api: str = 'https://sourcify.dev', base_url_repo: str = 'https://repo.sourcify.dev/', request_timeout: int = 10, max_requests: int = 100)

Bases: object

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

  • Full: Both the source files and the metadata 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.

Reference: https://docs.sourcify.dev/docs/api/

get_chains() Dict[str, Any]
get_contract_metadata(contract_address: str) ContractMetadata | None
is_chain_supported(chain_id: int) bool
exception safe_eth.eth.clients.sourcify_client.SourcifyClientConfigurationProblem

Bases: Exception

exception safe_eth.eth.clients.sourcify_client.SourcifyClientException

Bases: Exception

Module contents

class safe_eth.eth.clients.AsyncBlockscoutClient(network: EthereumNetwork, request_timeout: int = 10, max_requests: int = 100)

Bases: BlockscoutClient

async async_get_contract_metadata(address: ChecksumAddress) ContractMetadata | None
class safe_eth.eth.clients.AsyncEtherscanClientV2(network: EthereumNetwork, api_key: str | None = None, request_timeout: int = 10, max_requests: int = 100)

Bases: EtherscanClientV2

async async_get_contract_abi(contract_address: str)
async async_get_contract_metadata(contract_address: str) ContractMetadata | None
async async_get_contract_source_code(contract_address: str)

Asynchronous version of get_contract_source_code Does not implement retries

Parameters:

contract_address

class safe_eth.eth.clients.AsyncSourcifyClient(network: EthereumNetwork = EthereumNetwork.MAINNET, base_url_api: str = 'https://sourcify.dev', base_url_repo: str = 'https://repo.sourcify.dev/', request_timeout: int = 10, max_requests: int = 100)

Bases: SourcifyClient

async async_get_contract_metadata(contract_address: str) ContractMetadata | None

Asynchronous version of get_contract_metadata

exception safe_eth.eth.clients.BlockScoutConfigurationProblem

Bases: BlockscoutClientException

class safe_eth.eth.clients.BlockscoutClient(network: EthereumNetwork, request_timeout: int = 10)

Bases: object

NETWORK_WITH_URL = {EthereumNetwork.ACALA_NETWORK: 'https://blockscout.acala.network/api/v2/', EthereumNetwork.ALEPH_ZERO: 'https://evm-explorer-testnet.alephzero.org/api/v2/', EthereumNetwork.ALEPH_ZERO_EVM: 'https://evm-explorer.alephzero.org/api/v2/', EthereumNetwork.ARBITRUM_BLUEBERRY: 'https://arb-blueberry.gelatoscout.com/api/v2/', EthereumNetwork.ARENA_Z: 'https://explorer.arena-z.gg/api/v2', EthereumNetwork.ARTHERA_MAINNET: 'https://explorer.arthera.net/api/v2/', EthereumNetwork.ARTHERA_TESTNET: 'https://explorer-test.arthera.net/api/v2/', EthereumNetwork.ASTAR: 'https://astar.blockscout.com/api/v2/', EthereumNetwork.ASTAR_ZKEVM: 'https://astar-zkevm.explorer.startale.com/api/v2/', EthereumNetwork.AURORIA_TESTNET: 'https://auroria.explorer.stratisevm.com/api/v2/', EthereumNetwork.AUTONITY_PICCADILLY_TIBER_TESTNET: 'https://piccadilly.autonity.org/api/v2', EthereumNetwork.AUTONOMYS_CHRONOS_TESTNET: 'https://explorer.auto-evm.chronos.autonomys.xyz/api/v2/', EthereumNetwork.AUTONOMYS_MAINNET: 'https://explorer.auto-evm.mainnet.autonomys.xyz/api/v2/', EthereumNetwork.AUTONOMYS_TAURUS_TESTNET: 'https://explorer.auto-evm.taurus.autonomys.xyz/api/v2/', EthereumNetwork.BAHAMUT: 'https://api.ftnscan.com/api/v2/', EthereumNetwork.BIRDLAYER: 'https://scan.birdlayer.xyz/api/v2', EthereumNetwork.BITROCK_TESTNET: 'https://testnetscan.bit-rock.io/api/v2/', EthereumNetwork.BOB: 'https://explorer-bob-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.BOB_SEPOLIA: 'https://bob-sepolia.explorer.gobob.xyz/api/v2/', EthereumNetwork.CITREA_TESTNET: 'https://explorer.testnet.citrea.xyz/api/v2/', EthereumNetwork.CONNEXT_SEPOLIA: 'https://scan.testnet.everclear.org/api/v2/', EthereumNetwork.DODOCHAIN_TESTNET: 'https://testnet-scan.dodochain.com/api/v2/', EthereumNetwork.EDU_CHAIN_TESTNET: 'https://edu-chain-testnet.blockscout.com/api/v2/', EthereumNetwork.ENI_MAINNET: 'https://scan.eniac.network/api/v2', EthereumNetwork.ETHEREAL_TESTNET: 'https://explorer-ethereal-testnet-0.t.conduit.xyz/api/v2', EthereumNetwork.ETHERLINK_MAINNET: 'https://explorer.etherlink.com/api/v2/', EthereumNetwork.ETHERLINK_SHADOWNET_TESTNET: 'https://shadownet.explorer.etherlink.com/api/v2', EthereumNetwork.ETHERLINK_TESTNET: 'https://testnet.explorer.etherlink.com/api/v2/', EthereumNetwork.EVERCLEAR_MAINNET: 'https://scan.everclear.org/api/v2/', EthereumNetwork.EVMOS: 'https://evm.evmos.org/api/v2/', EthereumNetwork.EVM_ON_FLOW: 'https://evm.flowscan.io/api/v2', EthereumNetwork.EVM_ON_FLOW_TESTNET: 'https://evm-testnet.flowscan.io/api/v2', EthereumNetwork.EXSAT_MAINNET: 'https://scan.exsat.network/api/v2/', EthereumNetwork.EXSAT_TESTNET: 'https://scan-testnet.exsat.network/api/v2/', EthereumNetwork.FLARE_MAINNET: 'https://flare-explorer.flare.network/api/v2/', EthereumNetwork.FLARE_TESTNET_COSTON2: 'https://coston2-explorer.flare.network/api/v2/', EthereumNetwork.GAME7: 'https://mainnet.game7.io/api/v2/', EthereumNetwork.GAME7_TESTNET: 'https://testnet.game7.io/api/v2/', EthereumNetwork.GNOSIS: 'https://gnosis.blockscout.com/api/v2/', EthereumNetwork.GNOSIS_CHIADO_TESTNET: 'https://gnosis-chiado.blockscout.com/api/v2/', EthereumNetwork.GPT_MAINNET: 'https://explorer.gptprotocol.io/api/v2/', EthereumNetwork.GRAVITY_ALPHA_MAINNET: 'https://explorer-gravity-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.GRAVITY_ALPHA_TESTNET_SEPOLIA: 'https://explorer-gravity-alpha-testnet-sepolia-3ggx92odhy.t.conduit.xyz/api/v2/', EthereumNetwork.HAQQ_CHAIN_TESTNET: 'https://explorer.testedge2.haqq.network/api/v2/', EthereumNetwork.HAQQ_NETWORK: 'https://explorer.haqq.network/api/v2/', EthereumNetwork.HASHKEY_CHAIN: 'https://explorer.hsk.xyz/api/v2/', EthereumNetwork.HASHKEY_CHAIN_TESTNET: 'https://hashkeychain-testnet-explorer.alt.technology/api/v2/', EthereumNetwork.HPP_MAINNET: 'https://explorer.hpp.io/api/v2', EthereumNetwork.HPP_SEPOLIA: 'https://sepolia-explorer.hpp.io/api/v2', EthereumNetwork.IMMUTABLE_ZKEVM: 'https://explorer.immutable.com/api/v2/', EthereumNetwork.IMMUTABLE_ZKEVM_TESTNET: 'https://explorer.testnet.immutable.com/api/v2/', EthereumNetwork.INCENTIV_TESTNET: 'https://explorer-testnet.incentiv.io/api/v2', EthereumNetwork.INK_SEPOLIA: 'https://explorer-sepolia.inkonchain.com/api/v2/', EthereumNetwork.IOTA_EVM: 'https://iota-evm.blockscout.com/api/v2/', EthereumNetwork.JAPAN_OPEN_CHAIN_MAINNET: 'https://mainnet.japanopenchain.org/api/v2/', EthereumNetwork.JAPAN_OPEN_CHAIN_TESTNET: 'https://explorer.testnet.japanopenchain.org/api/v2/', EthereumNetwork.KAIA_KAIROS_TESTNET: 'https://baobab.scope.klaytn.com/api/v2/', EthereumNetwork.KAIA_MAINNET: 'https://scope.klaytn.com/api/v2/', EthereumNetwork.KROMA: 'https://blockscout.kroma.network/api/v2/', EthereumNetwork.KROMA_SEPOLIA: 'https://blockscout.sepolia.kroma.network/api/v2/', EthereumNetwork.LINEA: 'https://api-explorer.linea.build/api/v2/', EthereumNetwork.LINEA_SEPOLIA: 'https://api-explorer.sepolia.linea.build/api/v2/', EthereumNetwork.LISK: 'https://blockscout.lisk.com/api/v2/', EthereumNetwork.LISK_SEPOLIA_TESTNET: 'https://sepolia-blockscout.lisk.com/api/v2/', EthereumNetwork.LORENZO: 'https://scan.lorenzo-protocol.xyz/api/v2/', EthereumNetwork.MANTA_PACIFIC_MAINNET: 'https://pacific-explorer.manta.network/api/v2/', EthereumNetwork.MANTLE: 'https://explorer.mantle.xyz/api/v2/', EthereumNetwork.MANTLE_SEPOLIA_TESTNET: 'https://explorer.sepolia.mantle.xyz/api/v2/', EthereumNetwork.MANTLE_TESTNET: 'https://explorer.testnet.mantle.xyz/api/v2/', EthereumNetwork.MANTRACHAIN_TESTNET: 'https://explorer.dukong.io/api/v2/', EthereumNetwork.METER_MAINNET: 'https://scan.meter.io/api/v2/', EthereumNetwork.METER_TESTNET: 'https://scan-warringstakes.meter.io/api/v2/', EthereumNetwork.MINT_MAINNET: 'https://explorer-mint-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.MODE: 'https://explorer-mode-mainnet-0.t.conduit.xyz/api/v2/', EthereumNetwork.MODE_TESTNET: 'https://sepolia.explorer.mode.network/api/v2/', EthereumNetwork.MORPH_HOODI: 'https://explorer-api-hoodi.morphl2.io/api/v2', EthereumNetwork.NAL_SEPOLIA_TESTNET: 'https://testnet-scan.nal.network/api/v2/', EthereumNetwork.NEON_EVM_DEVNET: 'https://neon-devnet.blockscout.com/api/v2/', EthereumNetwork.NEON_EVM_MAINNET: 'https://neon.blockscout.com/api/v2/', EthereumNetwork.OP_CELESTIA_RASPBERRY: 'https://opcelestia-raspberry.gelatoscout.com/api/v2/', EthereumNetwork.OP_SEPOLIA_TESTNET: 'https://optimism-sepolia.blockscout.com/api/v2/', EthereumNetwork.PAIX_DEVELOPMENT_NETWORK: 'https://blockscout.ppaix.com/api/v2', EthereumNetwork.PLUME_DEVNET: 'https://test-explorer.plumenetwork.xyz/api/v2/', EthereumNetwork.PLUME_MAINNET: 'https://phoenix-explorer.plumenetwork.xyz/api/v2/', EthereumNetwork.Q_MAINNET: 'https://explorer.q.org/api/v2/', EthereumNetwork.Q_TESTNET: 'https://explorer.qtestnet.org/api/v2/', EthereumNetwork.REDSTONE: 'https://explorer.redstone.xyz/api/v2/', EthereumNetwork.REYA_NETWORK: 'https://explorer.reya.network/api/v2/', EthereumNetwork.RE_AL: 'https://explorer.re.al/api/v2/', EthereumNetwork.ROOTSTOCK_MAINNET: 'https://rootstock.blockscout.com/api/v2/', EthereumNetwork.ROOTSTOCK_TESTNET: 'https://rootstock-testnet.blockscout.com/api/v2/', EthereumNetwork.SAAKURU_MAINNET: 'https://explorer.saakuru.network/api/v2/', EthereumNetwork.SAGA: 'https://api-sagaevm-5464-1.sagaexplorer.io/api/v2/', EthereumNetwork.SHAPE: 'https://shapescan.xyz/api/v2', EthereumNetwork.SHAPE_SEPOLIA_TESTNET: 'https://sepolia.shapescan.xyz/api/v2/', EthereumNetwork.SNAXCHAIN: 'https://explorer.snaxchain.io/api/v2/', EthereumNetwork.SONEIUM_TESTNET_MINATO: 'https://soneium-minato.blockscout.com/api/v2/', EthereumNetwork.SONGBIRD_CANARY_NETWORK: 'https://songbird-explorer.flare.network/api/v2/', EthereumNetwork.SONGBIRD_TESTNET_COSTON: 'https://coston-explorer.flare.network/api/v2/', EthereumNetwork.STORY: 'https://mainnet.storyscan.xyz/api/v2/', EthereumNetwork.STORY_AENEID_TESTNET: 'https://aeneid.storyscan.io/api/v2/', EthereumNetwork.STORY_ODYSSEY_TESTNET: 'https://odyssey-testnet-explorer.storyscan.xyz/api/v2/', EthereumNetwork.SWELLCHAIN: 'https://explorer.swellnetwork.io/api/v2/', EthereumNetwork.SWELLCHAIN_TESTNET: 'https://swell-testnet-explorer.alt.technology/api/v2/', EthereumNetwork.TAC_MAINNET: 'https://explorer.tac.build/api/v2/', EthereumNetwork.TAC_SAINT_PETERSBURG: 'https://spb.explorer.tac.build/api/v2/', EthereumNetwork.TAC_TURIN: 'https://turin.explorer.tac.build/api/v2', EthereumNetwork.TAIKO_HEKLA_L2: 'https://blockscoutapi.hekla.taiko.xyz/api/v2/', EthereumNetwork.VANA: 'https://vanascan.io/api/v2/', EthereumNetwork.VANA_MOKSHA_TESTNET: 'https://moksha.vanascan.io/api/v2/', EthereumNetwork.ZETACHAIN_MAINNET: 'https://zetascan.com/api/v2/', EthereumNetwork.ZETACHAIN_TESTNET: 'https://testnet.zetascan.com/api/v2/', EthereumNetwork.ZORA: 'https://explorer.zora.energy/api/v2/', EthereumNetwork.ZORA_SEPOLIA_TESTNET: 'https://sepolia.explorer.zora.energy/api/v2/'}
build_url(path: str)
get_contract_metadata(address: ChecksumAddress) ContractMetadata | None
exception safe_eth.eth.clients.BlockscoutClientException

Bases: Exception

class safe_eth.eth.clients.ContractMetadata(name: str | None, abi: List[Dict[str, Any]], partial_match: bool, implementation: str | None = None)

Bases: object

abi: List[Dict[str, Any]]
implementation: str | None = None
name: str | None
partial_match: bool
class safe_eth.eth.clients.EnsClient(config: Config)

Bases: object

Resolves Ethereum Name Service domains using thegraph API

class Config(base_url: str)

Bases: object

base_url: str
property url: str
class SubgraphConfig(base_url: str, api_key: str, subgraph_id: str)

Bases: Config

api_key: str
base_url: str
subgraph_id: str
property url
static domain_hash_to_hex_str(domain_hash: HexStr | bytes | int) HexStr
Parameters:

domain_hash

Returns:

Domain hash as an hex string of 66 chars (counting with 0x), padding with zeros if needed

is_available() bool
Returns:

True if service is available, False if it’s down

query_by_account(account: str) List[Dict[str, Any]] | None
Parameters:

account – ethereum account to search for ENS registered addresses

Returns:

None if there’s a problem or not found, otherwise example of dictionary returned:

{
“registrations”: [
{
“domain”: {

“isMigrated”: true, “labelName”: “gilfoyle”, “labelhash”: “0xadfd886b420023026d5c0b1be0ffb5f18bb2f37143dff545aeaea0d23a4ba910”, “name”: “gilfoyle.eth”, “parent”: {

“name”: “eth”

}

}, “expiryDate”: “1905460880”

}

]

}

query_by_domain_hash(domain_hash: HexStr | bytes | int) str | None

Get domain label from domain_hash (keccak of domain name without the TLD, don’t confuse with namehash) used for ENS ERC721 token_id. Use another method for caching purposes (use same parameter type)

Parameters:

domain_hash – keccak of domain name without the TLD, don’t confuse with namehash. E.g. For batman.eth it would be just keccak(‘batman’)

Returns:

domain label if found

exception safe_eth.eth.clients.EtherscanClientConfigurationProblem

Bases: Exception

exception safe_eth.eth.clients.EtherscanClientException

Bases: Exception

class safe_eth.eth.clients.EtherscanClientV2(network: EthereumNetwork, api_key: str | None = None, request_timeout: int = 10)

Bases: object

Etherscan API V2 supports multiple chains in the same url.

Reference: https://docs.etherscan.io/etherscan-v2

BASE_API_V2_URL = 'https://api.etherscan.io'
HTTP_HEADERS: MutableMapping[str, str | bytes] = {'User-Agent': 'curl/7.77.0'}
build_url(query: str) str
get_base_url() str | None
Parameters:

network – The Ethereum network to check.

Returns:

Base url for the current network

get_contract_abi(contract_address: str, retry: bool = True)
get_contract_metadata(contract_address: str, retry: bool = True) ContractMetadata | None
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:

classmethod get_supported_networks() List[Dict[str, Any]]

Fetches a list of supported networks by the Etherscan API v2.

Returns:

List of supported networks, or empty list if request fails.

Example response ``` {

“chainname”:”Ethereum Mainnet”, “chainid”:”1”, “blockexplorer”:”https://etherscan.io”, “apiurl”:”https://api.etherscan.io/v2/api?chainid=1”, “status”:1

}, {

“chainname”:”Sepolia Testnet”, “chainid”:”11155111”, “blockexplorer”:”https://sepolia.etherscan.io”, “apiurl”:”https://api.etherscan.io/v2/api?chainid=11155111”, “status”:1

}

classmethod is_supported_network(network: EthereumNetwork) bool

Checks if a given Ethereum network is supported by the Etherscan API v2.

Parameters:

network – The Ethereum network to check.

Returns:

True if the network is supported; False otherwise.

exception safe_eth.eth.clients.EtherscanRateLimitError

Bases: EtherscanClientException

class safe_eth.eth.clients.SourcifyClient(network: EthereumNetwork = EthereumNetwork.MAINNET, base_url_api: str = 'https://sourcify.dev', base_url_repo: str = 'https://repo.sourcify.dev/', request_timeout: int = 10, max_requests: int = 100)

Bases: object

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

  • Full: Both the source files and the metadata 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.

Reference: https://docs.sourcify.dev/docs/api/

get_chains() Dict[str, Any]
get_contract_metadata(contract_address: str) ContractMetadata | None
is_chain_supported(chain_id: int) bool
exception safe_eth.eth.clients.SourcifyClientConfigurationProblem

Bases: Exception

exception safe_eth.eth.clients.SourcifyClientException

Bases: Exception