Welcome to the comprehensive documentation for opnet, the official client library for building Bitcoin-based applications on OPNet.
npm install opnet @btc-vision/transaction @btc-vision/bitcoinimport { getContract, IOP20Contract, JSONRpcProvider, OP_20_ABI } from 'opnet';
import { networks } from '@btc-vision/bitcoin';
// Connect to OPNet
const provider = new JSONRpcProvider({ url: 'https://regtest.opnet.org', network: networks.regtest });
// Interact with a token contract
const token = getContract<IOP20Contract>(
'op1...', // contract address
OP_20_ABI,
provider,
networks.regtest
);
// Read token balance
const balance = await token.balanceOf(myAddress);
console.log('Balance:', balance.properties.balance);- Setting Up HTTP Connections
- Constructor Parameters
- Network Configuration
- REST API vs JSON-RPC Mode
- Threaded Parsing
- Real-Time Subscriptions
- Block Notifications
- Epoch Notifications
- Event Handlers
- Connection Management
- Read-Only Method Calls
- CallResult Class
- Decoded Outputs
- Handling Reverts
- Historical Queries
- Access Lists
- Mining Fee (feeRate)
- Priority Fee
- ML-DSA Recipient
- Multiple Private Keys
- Custom UTXOs
- Refund Address
- Extra Inputs/Outputs
- Get Current Block Height
- Fetch Block by Number
- Fetch Block by Hash
- Fetch Multiple Blocks
- Block Properties
- Get Unified Addresses
- Fetch Multiple Keys
- CSV1 Address Lookup
- Address Validation
- Address Conversions