1.0.16 • Published 4 months ago

clarity-bitcoin-client v1.0.16

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

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-client

Usage

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

  1. The was-segwit-tx-mined-compact method fails with error 7 - on verifying coinbase merkle proof.
  2. 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 install

Build & Test

npm run build  # Compile to dist/
npm test       # Run tests

Publishing to NPM

npm run build
npm publish

License

MIT

Contributors

Open to contributions! Feel free to submit a PR. 🚀

1.0.16

4 months ago

1.0.11

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.10

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

4 months ago

1.0.0

4 months ago