1.0.16 • Published 9 months ago
clarity-bitcoin-client v1.0.16
Clarity Bitcoin Client
Clarity Bitcoin Client is an open-source TypeScript library for interacting with the Clarity-Bitcoin-V5 contract on the Stacks blockchain.
Given a bitcoin txid the library fetches the block and transaction data necessary to build the merkle proofs to submit to the clarity-bitcoin-lib-v5 contract.
Installation
npm install clarity-bitcoin-clientUsage
1️⃣ Import the Library
import { fetchApiData, extractProofInfo, parseWTx, type TxForClarityBitcoin } from "clarity-bitcoin-client";
const tx: TxForClarityBitcoin = await fetchApiData(network, mempoolApi, txId);
const proof: TransactionProofSet = await extractProofInfo(tx, contractId);
const result = await parseWTx(stacksApi, proof);Test client
A svelte app using this lib is available here.
Known Issues
- The
was-segwit-tx-mined-compactmethod fails with error 7 - on verifying coinbase merkle proof. - Breaks if you give it the coinbase transaction id
API Reference
Works with mempool space api. future editions may work with the rpc bitcoin node interface.
Development
Clone the repository and install dependencies:
git clone https://github.com/your-repo/clarity-bitcoin-client.git
cd clarity-bitcoin-client
npm installBuild & Test
npm run build # Compile to dist/
npm test # Run testsPublishing to NPM
npm run build
npm publishLicense
MIT
Contributors
Open to contributions! Feel free to submit a PR. 🚀