Networks
Typically, we speak of mainnet and testnet as the networks of Stacks. Most wallets are configured to mainnet by default—this is the production environment, the actual blockchain that holds real STX tokens.
As the name suggests, testnet is a public network for testing. It's a separate blockchain state that holds test tokens, which have no value.
For completeness we also mention devnet. This isn't "one" network, but how developers refer to ephemeral local networks used for testing. It is the same as testnet, but for local development. Learn more.
Setting the network
Most Stacks.js functions accept a network parameter or an optional last argument.
The network type is a string, and can be one of:
'mainnet'(default)'testnet''devnet''mocknet'(alias ofdevnet)
Examples
Network in transaction signing:
const tx = makeSTXTokenTransfer({
// ...
network: 'testnet',
});Network in address derivation:
const address = privateKeyToAddress(privateKey, 'devnet');
// ST3NBRSFKX28FQ2ZJ1MAKX58HKHSDGNV5N7R21XCPLast updated
Was this helpful?
