Reading the Bitcoin state
ICP smart contracts can query information about the Bitcoin mainnet or testnet programmatically.
Reading unspent transaction outputs (UTXOs)
To read unspent transaction outputs from the Bitcoin network, make a call to the bitcoin_get_utxos
Bitcoin API method.
- Motoko
- Rust
loading...
loading...
Reading current balance
To read the current balance of a Bitcoin address, make a call to the bitcoin_get_balance
Bitcoin API method.
- Motoko
- Rust
loading...
loading...
Reading the fee percentile
The transaction fees on the Bitcoin network change dynamically based on the number of pending transactions. In order to get fee percentiles of the last 10_000 transactions mined into blocks, call bitcoin_get_current_fee_percentiles
.
The function returns 101 numbers that are fees measured in millisatoshi per virtual byte. The i
-th element of the result corresponds to the i
-th percentile fee. For example, to get the median fee over the last few blocks, look at the 50
-th element of the result.
- Motoko
- Rust
loading...
loading...
Reading the block headers
To read the block headers within a provided range of start and end heights, make a call to the bitcoin_get_block_headers
Bitcoin API method
loading...