Using P2TR
How to use P2TR in OP_NET
OP_NET provides two ways to access P2TR addresses. Use the p2tr property on a wallet object to retrieve the P2TR address directly. Alternatively, call the p2tr() method on an Address object, which allows specifying the target network as a parameter.
The following example shows how to use both ways:
typescript
// Mainnet Taproot
const p2trMainnet = wallet.p2tr;
console.log('P2TR Mainnet:', p2trMainnet);
// Output: bc1p...
// Testnet Taproot
const p2trTestnet = wallet.address.p2tr(networks.testnet);
console.log('P2TR Testnet:', p2trTestnet);
// Output: tb1p...
// Regtest Taproot
const p2trRegtest = wallet.address.p2tr(networks.regtest);
console.log('P2TR Regtest:', p2trRegtest);
// Output: bcrt1p...