Choosing a Network
Network Selection
The library supports Mainnet and Regtest Bitcoin networks. No Testnet endpoints are currently available; use Regtest for all development and testing purposes.
The following table lists the endpoint URLs for each supported network:
| Network | RPC Endpoint URL | WebSocket Endpoint URL | Use Case |
|---|---|---|---|
| Mainnet | https://mainnet.opnet.org | wss://mainnet.opnet.org/ws | Production |
| Regtest | https://regtest.opnet.org | wss://regtest.opnet.org/ws | Development/Test |
typescript
Specifying a network
import { JSONRpcProvider, WebSocketRpcProvider } from 'opnet';
import { networks, Network } from '@btc-vision/bitcoin';
// Configuration based on environment
const config = {
mainnet: {
rpc: 'https://mainnet.opnet.org',
ws: 'wss://mainnet.opnet.org/ws',
network: networks.bitcoin,
},
regtest: {
rpc: 'https://regtest.opnet.org',
ws: 'wss://regtest.opnet.org/ws',
network: networks.regtest,
},
};
// Select environment
const env = 'regtest';
const { rpc, ws, network } = config[env];
// Create providers
const httpProvider = new JSONRpcProvider({
url: rpc,
network: network
});
const wsProvider = new WebSocketRpcProvider({
url: ws,
network: network
});Specifying a Network
The library exposes the networks object containing all supported Bitcoin network definitions. This object is passed to methods that require network specification, ensuring consistent network identification across the application.
typescript
networks definition
import { networks } from '@btc-vision/bitcoin';
// Network objects
networks.bitcoin // Mainnet
networks.testnet // Testnet
networks.regtest // Regtest