ChainId#
tradingstrategy.chain.ChainId Python class in Trading Strategy framework.
- class ChainId[source]#
Bases:
IntEnum
Chain ids and chain metadata helper.
This class is intended to present primary key for a blockchain in datasets, not its native chain id. This id may differ from what blockchain assumes its own id natively.
Chain id is an integer that defines the identity of a blockchain, all running on same or different EVM implementations. For non-EVM blockchains we have some special logic to handle them so we can present chain ids or all blockchains through this enum.
Chain id is a 32-bit integer.
For non-EVM chains like ones on Cosmos or Solana we use negative values, so that they are not confused with chain.network database. Cosmos natively uses string ids for chains instead of integers.
This class also provides various other metadata attributes besides ChainId.value, like ChainId.get_slug(). Some of this data is handcoded, some is pulled from chains submodule.
For the full chain id list see:
= `Cosmos chain registry <https://github.com/cosmos/chain-registry
- __init__()#
Methods
get_name
()Get full human readab name for this blockchain
get_slug
()Get URL slug for this chain
Get homepage link for this blockchain
Get an absolute SVG image link to a chain icon, transparent background
Get explorer landing page for this blockchain
get_address_link
(address)Get one address link.
get_tx_link
(tx)Get one tx link
get_by_slug
(slug)Map a slug back to the chain.
Attributes
Ethereum mainnet chain id
Binance Smarrt Chain mainnet chain id
Alias for Binance Smart Chain
Polygon chain id
Avalanche C-chain id
Arbitrum One id
Ethereum Classic chain id.
Ganache test chain.
Anvil test chain.
Chain id not known
Osmosis on Cosmos Does not have chain registry entry, beacuse Cosmos maintains its own registry
Python EVM test backend
Get chain data entry for this chain.
- ethereum = 1#
Ethereum mainnet chain id
- bsc = 56#
Binance Smarrt Chain mainnet chain id
- binance = 56#
Alias for Binance Smart Chain
- polygon = 137#
Polygon chain id
- avalanche = 43114#
Avalanche C-chain id
- arbitrum = 42161#
Arbitrum One id
- ethereum_classic = 61#
Ethereum Classic chain id.
This is also the value used by EthereumTester in unit tests. https://github.com/ethereum/eth-tester
- ganache = 1337#
Ganache test chain.
This is the chain id for Ganache local tester / mainnet forks.
- anvil = 31337#
Anvil test chain.
Standalone Anvil chain launch.
- unknown = 0#
Chain id not known
- osmosis = -100#
Osmosis on Cosmos Does not have chain registry entry, beacuse Cosmos maintains its own registry
- ethereum_tester = 131277322940537#
Python EVM test backend
- get_svg_icon_link()[source]#
Get an absolute SVG image link to a chain icon, transparent background
- Return type:
- get_address_link(address)[source]#
Get one address link.
Use EIP3091 format.
https://eips.ethereum.org/EIPS/eip-3091
- Return type: