Understand how your transaction worked
Understand what happened behind each call of your first transaction on the BSV blockchain, from Send a payment from a web app and Verify your payment on the explorer. Read it before you add transactions to your own app. The same model applies to every transaction your app makes, since your code asks and the wallet builds and signs. Knowing it tells you what your app decides, what the wallet decides, and where each number on the explorer comes from.
The app asks, the wallet signs
Your script never held a key or picked a coin. It asked BSV Desktop for a transaction, and the wallet did the rest:
- 1Your app
Asks for 1,000 satoshis with
createAction - 2BSV Desktop
Signs after you click Authorize. The private key stays here
- 3Testnet
Receives the signed transaction and records it
- 4Your app
Gets the transaction ID back from the wallet
The line between the two is the BRC-100The standard interface between an app and a wallet wallet interface. WalletClient from @bsv/sdk sends your request across it, and any BRC-100 wallet answers it in the same way, BSV Desktop on a computer or BSV Browser on a phone. The private key stays in the wallet, so your app never handles it. In BSV Desktop, each transaction waits for Authorize in the Spending Request.
To see every method of the interface, read BRC-100 Wallet Interface.
The transaction is an action with outputs
createAction is how an app asks for a transaction, which BRC-100 calls an action. In pay.mjs, the action has a description and one output:
descriptionis the text the Spending Request shows, “Pay my own address”.- The output has
satoshis, 1,000, and alockingScript, the locking scriptThe part of a transaction output that sets the condition to spend it thatnew P2PKH().lock(address)built from your address. It says that only the key behind that address can spend the 1,000 satoshis.
A satoshi is the smallest unit of BitcoinSV (BSV), and 100,000,000 satoshis make 1 BSV.
The app describes only what it wants to create. Which coins pay for it, the fee and the signature are the wallet’s choices, and createAction returns the transaction ID once the wallet has funded, signed and processed the transaction.
Your balance is a set of UTXOs
A BSV blockchain wallet does not keep one balance number. It keeps UTXOsUnspent transaction output, outputs of earlier transactions that nobody has spent yet, and the balance is their sum. A transaction spends whole UTXOs as its inputs and creates new outputs:
- Inputs: the UTXOs the wallet chose, which must add up to the amount plus the fee.
- Outputs: the payment to the address, and the change, the rest, which goes back to the wallet.
For example, one test transaction that paid 1,000 testnet satoshis had this shape on the explorer:
| Part | Satoshis |
|---|---|
| Input: one UTXO of the wallet | 5,873 |
| Output 1: payment to the address | 1,000 |
| Output 2: change back to the wallet | 4,816 |
| Fee: inputs minus outputs | 57 |
This explains the balance in the Quick Start. The wallet adds its change on its own, since it created that output. The 1,000 satoshis went to your BSV address, a plain address, so BSV Desktop adds them only when it checks that address: click Get paid, open the BSV ADDRESS tab and click Check for payments, or keep that tab open. Until then, the balance is lower by the amount plus the fee.
The fee depends on the size
No output carries the fee. It is the difference between the inputs and the outputs, and the wallet sets it from a rate in satoshis per kilobyte, 250 sats/kB by default in BSV Desktop. More inputs make a larger transaction, so the fee grows with the number of coins the wallet spends, not with the amount:
| Transaction paying 1,000 satoshis | Inputs | Size | Fee |
|---|---|---|---|
| One UTXO covered it | 1 | 225 bytes | 57 satoshis |
| Four UTXOs needed | 4 | 666 bytes | 168 satoshis |
The fees are the ones on the explorer, so they can be a satoshi or two above the size times the rate.
That is why the total in the Spending Request changes from one transaction to another, and why the fee on the explorer equals the Spending Request total minus the amount.
From sent to confirmed
After you approved, BSV Desktop signed the transaction and sent it to the network. It shows as unconfirmed on the explorer until a miner includes it in a block. Your app does not need to wait for a block to know that the transaction went out.
Related articles
To learn more about building transactions on the BSV blockchain, review these articles: