This example demonstrates how to use Clarity to parse Bitcoin transactions and block headers and verify that transactions were sent on the blockchain.
The clarity-bitcoin.clar contract includes the following functionality.
parse-tx (..)function dives into how to parse a Bitcoin transaction and the expected return type for your use in your business logicverify-block-header (...)function unpacks the nuances of verifying a block header for a given block heightwas-tx-mined-compactandwas-segwit-tx-mined-compactfunctions determines whether or not a Bitcoin transaction was mined in a previous Bitcoin block
To add a new contract, use Clarinet.
- You can manually test your your contracts in the Clarinet console.
- You can programmatically test your contracts with unit tests.