clarity-bitcoin-client
v1.0.18
Published
Clarity Bitcoin Client is an open-source TypeScript library for interacting with the **[Clarity-Bitcoin-V5](https://explorer.hiro.so/txid/SP2PABAF9FTAJYNFZH93XENAJ8FVY99RRM50D2JG9.clarity-bitcoin-lib-v5?chain=mainnet) contract** on the Stacks blockchain.
Readme
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. Library
import { fetchApiData, extractProofInfo, parseWTx, type TxForClarityBitcoin } from "clarity-bitcoin-client";
const data: ProofRequest = await getProofData(req.params.txid, blockHash, getRpcParams());
const pgd: ProofGenerationData = getProofGenerationData(data);
const proof: TransactionProofSet = extractProofInfo(pgd, data);The bitcoin connection parameters are expected;
{
rpcHost: CONFIG.rpcHost,
rpcPort: CONFIG.rpcPort,
rpcPass: CONFIG.rpcPass,
rpcUser: CONFIG.rpcUser
}2. API Usage
A hosted service is avaliable here
Test client
A svelte app using this lib is available here.
Known Issues
- the bitcoin node is pruned to 500 blocks roughly 3 days of transactions.
Development
Clone the repository and install dependencies:
git clone https://github.com/BigMarketDao/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. 🚀
