Skip to content

Expose chain ID in Clarity #2982

Closed
Closed
@MarvinJanssen

Description

@MarvinJanssen

Having a native constant for the chain ID in Clarity is very useful for various reasons. One can build triggers based on mainnet/testnet, etc., but it is specifically useful for signed message verification. A common way to prevent replay protection across forks is to add a chain ID to the message somewhere. Right now that means you have to hardcode the chain ID.

The chain ID is expressed as 4 bytes in a transaction and as a u32 in Rust:

  • 0x00000001 or 1 for mainnet
  • 0x80000000 or 2147483648 for testnet

My suggestion is to expose it as chain-id with a type of either uint or (buff 4).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions