@stacks/network
The @stacks/network package exports network configurations and helper functions for working with different Stacks networks.
Installation
npm install @stacks/networkNetwork constants
STACKS_MAINNET
STACKS_MAINNET provides the mainnet network configuration.
import { STACKS_MAINNET } from '@stacks/network';
console.log(STACKS_MAINNET);
// {
// chainId: 1,
// transactionVersion: 0,
// peerNetworkId: 385875968,
// magicBytes: "X2",
// bootAddress: "SP000000000000000000002Q6VF78",
// addressVersion: {
// singleSig: 22,
// multiSig: 20,
// },
// client: {
// baseUrl: "https://api.mainnet.hiro.so",
// },
// }STACKS_TESTNET
STACKS_TESTNET provides the testnet network configuration.
STACKS_DEVNET / STACKS_MOCKNET
STACKS_DEVNET provides the devnet network configuration.
networkFromName
networkFromName returns a network configuration for a given name string.
Signature
Parameters
name
'mainnet' | 'testnet' | 'devnet' | 'mocknet'
Yes
Network name
Examples
Using with transactions
clientFromNetwork
clientFromNetwork extracts the API client configuration from a network.
Signature
Parameters
network
StacksNetwork
Yes
Network configuration object
Example
Network configuration properties
All network constants share these properties:
chainId
number
Unique identifier for the network
transactionVersion
number
Transaction serialization version
peerNetworkId
number
P2P network identifier
magicBytes
string
Network magic bytes for serialization
bootAddress
string
Boot contract address
Default values
The package also exports default configuration values:
Was this helpful?
