Skip to content
On this page

Chain id โ€‹

The type of chain identifiers in SmartPy is sp.TChainId.
The corresponding type in Michelson is

Michelson chain_id.

Literals โ€‹

sp.chain_id_cst(<bytes>)
Return a chain id of type sp.TChainId by its hexadecimal representation.

Example โ€‹

python
value = sp.chain_id_cst("0x9caecab9")

Check reference Chain Id template.

INFO

Please note that chain ids are non comparable. Equality can be verified by using sp.verify_equal.

Global property โ€‹

sp.chain_id
Get the chain identifier of type sp.TChainId which represents the network currently evaluating the transaction.

Example โ€‹

python
@sp.entrypoint
def ep(self):
    sp.verify(sp.chain_id == sp.chain_id_cst("0x9caecab9"))
Michelson CHAIN_ID