// Create a basic network from a network name
const network = createNetwork('mainnet');
const network = createNetwork(STACKS_MAINNET);
// Create a network with an API key
const network = createNetwork('testnet', 'my-api-key');
const network = createNetwork(STACKS_TESTNET, 'my-api-key');
// Create a network with options object
const network = createNetwork({
network: 'mainnet',
apiKey: 'my-api-key',
});
// Create a network with options object with custom API key options
const network = createNetwork({
network: 'mainnet',
apiKey: 'my-api-key',
host: /\.example\.com$/, // default is /(.*)api(.*)(\.stacks\.co|\.hiro\.so)$/i
httpHeader: 'x-custom-api-key', // default is 'x-api-key'
});
// Create a network with custom client options
const network = createNetwork({
network: STACKS_TESTNET,
client: {
baseUrl: 'https://custom-api.example.com',
fetch: customFetchFunction
}
});
Generated using TypeDoc
Creates a customized Stacks network.
This function allows you to create a network based on a predefined network (mainnet, testnet, devnet, mocknet) or a custom network object. You can also customize the network with an API key or other client options.