Chain id

Blockchain ids.

Data structures and information about EVM based blockchains. Because the same trading pair and smart contract can across multiple blockchains, we need to have a way to identify blockchains. See ChainId enum class for passing the identity of a blockchain around. This is based on the underlying web3.eth.chain_id attribute of a chain.

Trading Strategy package embeds the chain list data from chains repository as the submodule for the Python package. This data is used to populate some ChainId data.

exception tradingstrategy.chain.ChainDataDoesNotExist

Cannot find data for a specific chain

class tradingstrategy.chain.ChainId

Ethereum EVM chain ids and chain metadata.

Chain id is an integer that defines the identity of a blockchain, all running on same or different EVM implementations.

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:

ethereum = 1

Ethereum mainnet chain id

bsc = 56

Binance Smarrt Chain mainnet chain id

polygon = 137

Polygon chain id

avalanche = 43114

Avalanche C-chain id

ethereum_classic = 61

Ethereum Classic chain id. This is also the value used by EthereumTester in unit tests.

ganache = 1337

Ganache test chain. This is the chain id for Ganache local tester / mainnet forks.

property data: dict

Get chain data entry for this chain.

get_name() str

Get full human readab name for this blockchain

get_slug() str

Get URL slug for this chain

get_homepage() str

Get homepage link for this blockchain

Get an absolute SVG image link to a chain icon, transparent background

get_explorer() str

Get explorer landing page for this blockchain

Get one address link.

Use EIP3091 format.

Get one tx link

static get_by_slug(slug: str) Optional[tradingstrategy.chain.ChainId]

Map a slug back to the chain.

Most useful for resolving URLs.