https://github.com/hirosystems/platform-template-clarity-bitcoin
https://github.com/hirosystems/platform-template-clarity-bitcoin
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hirosystems/platform-template-clarity-bitcoin
- Owner: hirosystems
- License: mit
- Created: 2024-11-11T20:27:28.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-11-18T09:19:11.000Z (7 months ago)
- Last Synced: 2025-12-23T06:43:49.366Z (6 months ago)
- Language: Clarity
- Size: 96.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Interact with Bitcoin using Clarity
This example demonstrates how to use Clarity to parse Bitcoin transactions and block headers and verify that transactions were sent on the blockchain.
## Know your Contract
The [clarity-bitcoin.clar](/contracts/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 logic
- `verify-block-header (...)` function unpacks the nuances of verifying a block header for a given block height
- `was-tx-mined-compact` and `was-segwit-tx-mined-compact` functions determines whether or not a Bitcoin transaction was mined in a previous Bitcoin block
To add a new contract, use [Clarinet](https://docs.hiro.so/stacks/clarinet).
## Test your Contract
- You can manually test your your contracts in the [Clarinet console](https://docs.hiro.so/clarinet/how-to-guides/how-to-test-contract#load-contracts-in-a-console).
- You can programmatically test your contracts with [unit tests](https://docs.hiro.so/clarinet/how-to-guides/how-to-test-contract).