Skip to main content

Getting Started

firo-rpc is a TypeScript library that lets you talk to a Firo node from your application. You send requests — like "what's the current block count?" or "send some FIRO to this address" — and it gives you back typed, structured responses.

Install

npm install @nexusocean/firo-rpc

Connect to a Node

Before using any methods you need to create a client. The client holds your connection settings and is reused for every call.

import { createFiroRpcClient } from '@nexusocean/firo-rpc';

const client = createFiroRpcClient({
host: '127.0.0.1',
port: 8888,
user: 'rpcuser',
pass: 'rpcpass',
protocol: 'http',
});
OptionDefaultDescription
host127.0.0.1IP or hostname of your Firo node
port8888RPC port configured in firo.conf
userRPC username (required)
passRPC password (required)
protocolhttpUse https if your node has TLS enabled
timeoutRequest timeout in milliseconds

Make Your First Call

const blockCount = await client.getBlockCount();
console.log(`Chain is at block ${blockCount}`);

Batch Multiple Calls

Send several requests in one round trip using client.batch. This is faster than making individual calls one after another.

const results = await client.batch([
{ method: 'getblockcount' },
{ method: 'getnetworkinfo' },
]);

const count = results[0].result as number;
const info = results[1].result;

Call Any Method Directly

If a method isn't listed in the typed API, you can still call it using the generic client.call escape hatch:

const raw = await client.call<string>('getbestblockhash');

Node Requirements

Some methods require extra flags in your firo.conf file:

FlagNeeded for
txindex=1Looking up transactions not in your wallet or mempool
addressindex=1getAddressBalance, getAddressTxIds
mobile=1All Spark privacy methods

After adding index flags, restart your node with -reindex once to build the index from scratch.