Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose chain ID in Clarity #2982

Closed
MarvinJanssen opened this issue Dec 23, 2021 · 1 comment
Closed

Expose chain ID in Clarity #2982

MarvinJanssen opened this issue Dec 23, 2021 · 1 comment

Comments

@MarvinJanssen
Copy link
Member

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).

@jcnelson jcnelson added this to To do in Stacks 2.1 via automation Mar 31, 2022
@jcnelson jcnelson moved this from To do to Review in progress in Stacks 2.1 Apr 25, 2022
@jcnelson jcnelson moved this from Review in progress to Done in Stacks 2.1 Apr 29, 2022
@jcnelson
Copy link
Member

jcnelson commented May 5, 2022

This has been merged to next.

@jcnelson jcnelson closed this as completed May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants