Stacks Namespace - Chains

Author Léo Pradel @pradel, Greg Ogunyanwo @gregogun
Discussions-To https://forum.stacks.org/t/caip-2-and-caip-10-stacks-specification/13290
Status Draft
Type Standard
Created 2022-06-07
Requires CAIP-2

CAIP-2

For context, see the [CAIP-2][] specification.

Rationale

In [CAIP-2][] a general blockchain identification scheme is defined. This is the implementation of CAIP-2 for Stacks. The chain ID is used as a way to mitigate replay attacks on different Stacks chains, as it is included in the transaction encoding. Stacks mainnet runs on bitcoin mainnet and testnet runs on bitcoin testnet3.

Syntax

For reference, the format of reference currently specified in SIP-005 is an unsigned integer in decimal representation. The unsigned integer is represented as a 32-bit unsigned integer with a maximum value of 2^32-1.

Resolution Method

To resolve a blockchain reference for the stacks namespace, make an API call request to a blockchain node on the route /v2/info, the response will contain the network_id field. For example:

{
  "id": 1,
  "network_id": 1,
  "server_version": "stacks-node 2.05.0.2.0 (develop:4641001+, release build, linux [x86_64])",
  // ... other fields
}

Test Cases

This is a list of manually composed examples

# Stacks mainnet
stacks:1

# Stacks testnet
stacks:2147483648

References

  • [SIP-005][] - Blocks and Transactions
  • [API documentation][] - Core API info

[SIP-005][https://github.com/stacksgov/sips/blob/main/sips/sip-005/sip-005-blocks-and-transactions.md] [API documentation][https://hirosystems.github.io/stacks-blockchain-api/#operation/get_core_api_info] [CAIP-2][https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md]

Copyright and related rights waived via CC0.

Citation

Please cite this document as:

Léo Pradel @pradel, Greg Ogunyanwo @gregogun, "namespaces/stacks-caip2: Stacks Namespace - Chains [DRAFT]," Chain Agnostic Namespaces, stacks-caip2, June 2022 / . [Online serial]. Available: https://github.com/ChainAgnostic/namespaces/stacks-caip2.md