ChainId#
API documentation for 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__(*args, **kwds)#
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.
__init__
(*args, **kwds)as_integer_ratio
()Return integer ratio.
bit_count
()Number of ones in the binary representation of the absolute value of self.
bit_length
()Number of bits necessary to represent self in binary.
conjugate
Returns self, the complex conjugate of any int.
from_bytes
([byteorder, signed])Return the integer represented by the given array of bytes.
to_bytes
([length, byteorder, signed])Return an array of bytes representing an integer.
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
Base
Mantle
Ethereum Classic chain id.
Ganache test chain.
Anvil test chain.
Chain id not known
Special chain id set for side-loaded data.
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.
denominator
the denominator of a rational number in lowest terms
imag
the imaginary part of a complex number
numerator
the numerator of a rational number in lowest terms
real
the real part of a complex number
- 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
- base = 8453#
Base
- mantle = 5000#
Mantle
- 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
- centralised_exchange = -1#
Special chain id set for side-loaded data.
Symbolise this data is from a centralised exchange.
- 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:
- __new__(value)#