Skip to main content

API Reference

TachiClient

Constructor

import { TachiClient } from "@tachibtc/sdk";

const client = new TachiClient({
baseUrl: "https://rpc-devnet.tachibtc.com",
timeoutMs: 30000, // optional, default 30s
});
OptionTypeDefaultDescription
baseUrlstringBase URL of the Tachi daemon RPC
fetchfetchglobalThis.fetchCustom fetch implementation
timeoutMsnumber30000Request timeout in ms. Set to 0 to disable

Health & Status

getHealth()

Liveness probe returning daemon status and validator count.

const health = await client.getHealth();
// { status: "ok", validators: 3 }

Returns: HealthResponse

FieldTypeDescription
statusstringDaemon status
validatorsnumberNumber of validators

getStatus()

Node info, sync status, and latest block height via CometBFT.

const status = await client.getStatus();
console.log(status.result);

Returns: CometRPCResponse


Peer Info

getPeerInfo()

Returns the PeerID, public key, and network addresses of this node.

const peer = await client.getPeerInfo();
// { peer_id: "abc...", pub_key_hex: "def...", host: "127.0.0.1", p2p_port: 26656, rpc_addr: "..." }

Returns: ValidatorInfo

FieldTypeDescription
peer_idstringPeer identifier
pub_key_hexstringPublic key (hex)
hoststringHost address
p2p_portnumberP2P port
rpc_addrstringRPC address

Validators

getValidators()

All validators from bootstrap registry merged with KDHT-discovered validators.

const { count, validators } = await client.getValidators();

Returns: ValidatorsResponse

FieldTypeDescription
countnumberTotal validator count
validatorsValidatorInfo[]Validator list

getValidatorCount()

Number of validators in the bootstrap registry.

const { count } = await client.getValidatorCount();

Returns: ValidatorCountResponse


getLiveValidators()

Validators whose peers are currently connected via the overlay network.

const live = await client.getLiveValidators();
console.log(`${live.count} of ${live.total_known} online`);

Returns: LiveValidatorsResponse

FieldTypeDescription
countnumberLive validator count
total_knownnumberTotal known validators
validatorsValidatorInfo[]Live validator list

waitForValidatorsReady(expected?)

Long-polls until the expected number of validators have registered or a 60-second timeout expires.

const ready = await client.waitForValidatorsReady(3);
console.log(ready.ready); // true or false

Parameters:

ParamTypeDefaultDescription
expectednumber2Number of expected validators

Returns: ReadyResponse


registerValidator(info)

Register a validator with this bootstrap node.

await client.registerValidator({
peer_id: "abc",
pub_key_hex: "def",
host: "127.0.0.1",
p2p_port: 26656,
rpc_addr: "http://localhost:26657",
});

Parameters: ValidatorInfo

Returns: RegisterResponse{ status: string, total: number }


Network

getNetInfo()

Listening addresses, connected peer count, and per-peer connection info via CometBFT.

const netInfo = await client.getNetInfo();

Returns: CometRPCResponse


Transactions

broadcastTxAsync(tx)

Broadcast a hex-encoded transaction. Returns immediately without waiting for CheckTx.

const result = await client.broadcastTxAsync("deadbeef");
caution

Transaction hex strings do not use a 0x prefix.

Parameters:

ParamTypeDescription
txstringHex-encoded transaction bytes

Returns: CometRPCResponse


broadcastTxSync(tx)

Broadcast a hex-encoded transaction. Waits for CheckTx to complete before responding.

const result = await client.broadcastTxSync("deadbeef");
console.log(result.result);

Parameters:

ParamTypeDescription
txstringHex-encoded transaction bytes

Returns: CometRPCResponse


Queries

query(params)

Forward a query to the CometBFT ABCI application.

const result = await client.query({
path: "/store/key",
data: "0xab", // optional, hex-encoded
height: "100", // optional
});

Parameters: QueryParams

ParamTypeRequiredDescription
pathstringYesABCI query path
datastringNoHex-encoded query data
heightstringNoBlock height to query at

Returns: CometRPCResponse


Bitcoin RPC

bitcoinRPC(request)

Forward a JSON-RPC 1.0 request to the underlying bitcoind. Any method exposed by the Bitcoin node is reachable.

const info = await client.bitcoinRPC({ method: "getblockchaininfo" });
console.log(info.result);

const block = await client.bitcoinRPC({
method: "getblock",
params: ["<block-hash>"],
});
warning

This proxies any Bitcoin RPC method, including privileged ones like sendtoaddress, dumpprivkey, and stop. Ensure the daemon's RPC is properly access-controlled.

Parameters: BitcoinRPCRequest

ParamTypeDefaultDescription
methodstringBitcoin RPC method name
paramsunknown[]Method parameters
jsonrpcstring"1.0"JSON-RPC version
idstring"tachi-sdk"Request ID

Returns: BitcoinRPCResponse<T>

FieldTypeDescription
resultTRPC result
error{code, message} | nullError if any
idstringRequest ID