Understanding the Protocol Design

Under development...

UTXO-Based

Bitcoin operates on a UTXO (Unspent Transaction Output) model rather than an account-based balance system. Every transaction consumes one or more existing UTXOs as inputs and produces new UTXOs as outputs. The library handles UTXO selection, change calculation, and fee estimation internally. Each method on TransactionFactory returns the resulting UTXOs (nextUTXOs) that your application must track and pass as inputs to subsequent transactions. Failure to do so will result in double-spend rejections.

UTXO Transaction Model Inputs (consumed) UTXO 50,000 sat UTXO 30,000 sat Your Transaction Fee 1,500 sat Outputs (created) Recipient 40,000 sat Change 38,500 sat

Two-Transaction Model

OP_NET smart contract operations, both deployments and interactions, require a pair of Bitcoin transactions that are broadcast together as a unit. The interaction transaction embeds the contract calldata within a Taproot script path, while the funding transaction creates a UTXO with the exact amount needed (covering fees, priority fee, and gas) locked to the interaction's script address. The TransactionFactory handles this two-transaction construction automatically: you provide the parameters, and it returns both signed transactions ready to broadcast.

Simple Bitcoin transfers that do not involve smart contract logic use a single transaction and do not require this pairing.

Funding & Interaction Transaction Flow User Funding TX Interaction TX Bitcoin Network 1. Create funding transaction Sends exact amount to a one-time script address (P2TR or P2MR) 2. Create interaction transaction Spends funding output, embeds calldata in Tapscript 3. Broadcast both transactions Funding TX confirms first, Interaction TX spends its output User Funding TX Interaction TX Bitcoin Network