diff --git a/modules/chronik-client/README.md b/modules/chronik-client/README.md index 6c8902645..72b119236 100644 --- a/modules/chronik-client/README.md +++ b/modules/chronik-client/README.md @@ -1,68 +1,73 @@ # Chronik Indexer Client Access Chronik Indexer via browser or Node. ## Installation `npm install chronik-client` `yarn add chronik-client` ## Usage ```js import { ChronikClient } from 'chronik-client'; // For XEC, eCash chain: const chronik = new ChronikClient('https://chronik.be.cash/xec'); // For XPI, Lotus chain: const chronik = new ChronikClient('https://chronik.be.cash/xpi'); // Get Genesis block (on eCash): const block = await chronik.block( '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f', ); // Get the first 11 blocks of the chain: const blocks = await chronik.blocks(0, 10); // Get SLP tx details on eCash: const tx = await chronik.tx( '0f3c3908a2ddec8dea91d2fe1f77295bbbb158af869bff345d44ae800f0a5498', ); +// Get token details for a given token ID +const tokenDetails = await chronik.token( + '0daf200e3418f2df1158efef36fbb507f12928f1fdcf3543703e64e75a4a9073', +); + // Validate Genesis UTXO (considered 'unspent' by Chronik): const validationResult = await chronik.validateUtxos([ { txid: '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', outIdx: 0, }, ]); const GENESIS_PK = '04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc' + '3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f'; // Get first page of tx history of the Genesis pubkey, most recent first: const history = await chronik .script('p2pk', GENESIS_PK) .history(/*page=*/ 0, /*page_size=*/ 10); // Get all UTXOs of the Genesis pubkey: const utxos = await chronik.script('p2pk', GENESIS_PK).utxos(); // Listen to updates on scripts: const ws = chronik.ws({ onMessage: msg => { console.log('Got update: ', msg); }, onReconnect: e => { // Fired before a reconnect attempt is made: console.log('Reconnecting websocket, disconnection cause: ', e); }, }); // Wait for WS to be connected: await ws.waitForOpen(); // Subscribe to scripts (on Lotus, current ABC payout address): // Will give a message on avg every 2 minutes ws.subscribe('p2pkh', 'b8ae1c47effb58f72f7bca819fe7fc252f9e852e'); // Unsubscribe: ws.unsubscribe('p2pkh', 'b8ae1c47effb58f72f7bca819fe7fc252f9e852e'); ``` diff --git a/modules/chronik-client/package.json b/modules/chronik-client/package.json index 0161eb9e4..cdab7eab7 100644 --- a/modules/chronik-client/package.json +++ b/modules/chronik-client/package.json @@ -1,43 +1,43 @@ { "name": "chronik-client", - "version": "0.8.2", + "version": "0.8.3", "description": "A client for accessing the Chronik Indexer API", "main": "dist/index.js", "types": "dist/index.d.ts", "author": "Tobias Ruck", "license": "MIT", "scripts": { "build-proto": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=. ../bitcoinsuite-chronik-client/proto/chronik.proto -I=../bitcoinsuite-chronik-client/proto/ --ts_proto_opt=esModuleInterop=true --ts_proto_opt=forceLong=string", "build": "tsc", "build-docs": "typedoc --out docs index.ts", "test": "mocha -r ts-node/register test/test.ts", "test-long": "mocha -r ts-node/register test/test.ts --timeout 1000000000", "format": "prettier --write .", "lint": "eslint . --ext .js,.jsx,.ts,.tsx && prettier --check ." }, "devDependencies": { "@types/chai": "^4.2.22", "@types/chai-as-promised": "^7.1.4", "@types/mocha": "^9.0.0", "@typescript-eslint/eslint-plugin": "^5.5.0", "@typescript-eslint/parser": "^5.5.0", "chai": "^4.3.4", "chai-as-promised": "^7.1.1", "eslint": "^8.4.0", "eslint-config-prettier": "^8.3.0", "mocha": "^9.1.3", "prettier": "^2.5.1", "prettier-plugin-organize-imports": "^2.3.4", "ts-node": "^10.4.0", "ts-proto": "^1.92.1", "typedoc": "^0.22.10", "typescript": "^4.5.2" }, "dependencies": { "@types/ws": "^8.2.1", "axios": "^0.21.1", "isomorphic-ws": "^4.0.1", "protobufjs": "^6.8.8", "ws": "^8.3.0" } }