Bitcoin
Bereit, das in der Produktion aufzurufen?
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
Bitcoin
Das Free-Tier deckt persönliche Projekte ab. Pay-as-you-go skaliert ohne Karte.
Almost every confusing thing about building on Bitcoin dissolves once the UTXO model clicks, which is why it is the first concept to learn. Unlike a chain that keeps a running balance per account and mutates it on each transfer, Bitcoin holds no balances at all: value lives as discrete, indivisible coins called unspent transaction outputs (UTXOs), each locked to a script and each either fully spent or fully unspent. There is no address-to-balance row to read and no nonce to track — a transaction simply consumes some existing UTXOs and creates new ones in their place. After this guide you will understand what a UTXO is and how it is identified, why an address balance is something you compute rather than fetch, how to read a live output with gettxout against https://bitcoin.therpc.io/YOUR_API_KEY, and how coin selection and change work when you spend.
txid of the transaction that created it and the vout index of that output within it — for example txid:0 and txid:1 are two distinct coins.gettxout reads from this in-memory set, not from historical transaction data, so it answers "is this output still spendable right now?" directly and quickly.gettxout returns a live output's details: value denominated in BTC, the scriptPubKey with its type and address, and a confirmations count, plus coinbase and the best-block context. It answers only for outputs still in the UTXO set.null result is normal, not an error. When gettxout returns null the output is either already spent or never existed — that is exactly how you confirm a coin has been consumed. Do not treat null as a failure to handle; treat it as the "spent or unknown" answer.getrawtransaction. Because spent outputs leave the UTXO set, gettxout can no longer see them. Fetch the creating transaction by txid and read its vout[n] to recover the value and script of an output that has since been spent.gettxout reports value in whole BTC, while statistics methods like getblockstats report amounts in satoshis (1 BTC = 100,000,000 sat). Convert deliberately and keep internal accounting in integer satoshis to avoid floating-point drift.include_mempool for in-flight spends. Pass it to gettxout so the answer accounts for outputs already spent by unconfirmed mempool transactions. This prevents you from selecting a coin that is still "unspent" on chain but already committed in a pending transaction, which would create a double-spend.