networkFromName
Returns the pre-configured StacksNetwork object for a given network name string. This is the primary way to convert a StacksNetworkName into a full network configuration.
Usage
import { networkFromName } from '@stacks/network';
const mainnet = networkFromName('mainnet');
// Same as STACKS_MAINNET
const testnet = networkFromName('testnet');
// Same as STACKS_TESTNET
const devnet = networkFromName('devnet');
// Same as STACKS_DEVNET
const mocknet = networkFromName('mocknet');
// Same as STACKS_MOCKNETNotes
Throws an
Errorif an unknown network name is provided.Most
@stacks/transactionsfunctions call this internally when you pass a network string like'testnet'.
Signature
Returns
StacksNetwork
The pre-configured network object corresponding to the given name.
Parameters
name (required)
Type:
StacksNetworkName—'mainnet' | 'testnet' | 'devnet' | 'mocknet'
The network name to resolve.
Last updated
Was this helpful?