RPCX Examples by Table

An example method for each of the nine RPCX live tables: transactions, instructions, logs, fees, SOL and token flows, blocks, balances, and token holdings of many wallets in one call.

This page has example methods for each of the nine live tables. Most examples read many wallets in one call, with a list param such as wallets: pubkey[]. Paste one into the Code tab of a new method, fill in Params, select Validate, Save, then Run.

For the columns of each table, see Live tables or search them on All tables. For the method language itself, see Writing methods and the language reference.

Read this first

  • A key or a range right after from. Use a key such as (address | in wallets), sig, program on live_instructions, or (owner | in owners) on live_token_accounts. A chain table can also be read by a bounded ts or slot range alone, up to 3,000 slots. Without either, Validate refuses the method with live_key_missing.
  • Add a time range to reads by address. ts >= from && ts < to keeps the run fast and the cost low. Very busy accounts, such as programs, the USDC mint, or the System Program, read a lot of data.
  • Pass many wallets in one call. A list param holds up to 1,000 values. Do not call a method once per wallet.
  • Live data. The chain tables hold the latest Solana data, up to the newest blocks. Older history is not available.
  • Current state. live_accounts and live_token_accounts hold the state at the time the method runs, not a history.
  • Amounts are raw integers. SOL amounts are in lamports (divide by 1e9). Token amounts are in base units (divide by 10^decimals). live_token_accounts also has ui_amount.
  • Wrapped SOL has the mint So11111111111111111111111111111111111111112.

live_signatures

Transactions that touch an address, newest first. This is the cheapest table to read, because RPCX does not fetch the full transactions.

How active each wallet was, with its failed transactions and its latest transaction:

RPCX methodtext
# Transactions per wallet in a window.method activity(wallets: pubkey[] "Wallets", from: time "Start (UTC)", to: time "End (UTC)") {  from live_signatures  filter (address | in wallets) && ts >= from && ts < to  derive {failed = case [success == false => 1, true => 0]}  group {address} (    aggregate {      txs = count this,      failures = sum failed,      last_tx = max ts    }  )  sort {-txs}}

live_transactions

One row per transaction that touches an address, or one transaction by signature.

Every transaction of a list of wallets, newest first:

RPCX methodtext
method txsFor(wallets: pubkey[] "Accounts", from: time, to: time) {  from live_transactions  filter (address | in wallets) && ts >= from && ts < to  sort {-ts}}

Fees and compute units each wallet paid for as the fee payer:

RPCX methodtext
# Fees paid per wallet, in lamports.method feesPaid(wallets: pubkey[] "Wallets", from: time, to: time) {  from live_transactions  filter (address | in wallets) && ts >= from && ts < to  filter signer == address  group {address} (    aggregate {      txs = count this,      fees = sum fee,      compute = sum compute_units    }  )  sort {-fees}}

A list of transactions by signature:

RPCX methodtext
method txsBySig(sigs: signature[] "Signatures") {  from live_transactions  filter (sig | in sigs)  select {sig, ts, success, fee, signer, programs}}

live_instructions

One row per instruction, inner instructions included. Read by address, program, sig, or a range.

Every call of one program, with the fee payer and fee of its transaction:

RPCX methodtext
# Instructions of one program with the fee payer and fee of their transaction.method programCalls(prog: pubkey "Program id", from: time "Start, inclusive", to: time "End, exclusive") {  from i = live_instructions  filter program == prog && ts >= from && ts < to  join side:inner t = (from live_transactions | filter address == prog && ts >= from && ts < to) (==sig)  select {i.ts, i.sig, i.outer_index, i.inner_index, i.data, t.signer, t.fee, t.success}  sort {-i.ts}}

A program can be very busy. Keep the range short, and add take when you only need the newest rows.

The most called programs in a short range, read without a key:

RPCX methodtext
# Top programs by top-level instruction count. A range without a key may cover at most 3,000 slots.method topPrograms(from: time "Start, inclusive", to: time "End, exclusive", n: uint64 = 20 "Rows") {  from live_instructions  filter ts >= from && ts < to && stack_height == 1  group {program} (aggregate {calls = count this, txs = count_distinct sig})  sort {-calls}  take n}

live_logs

One row per program log line. Read by address, sig, or a range.

The log lines of an address's transactions that contain a word:

RPCX methodtext
# Log lines of the transactions that touch an address and contain a word.method logsWith(addr: pubkey "Any address", word: string "Text to find", from: time "Start, inclusive", to: time "End, exclusive") {  from live_logs  filter address == addr && ts >= from && ts < to  filter (text.contains word line)  select {ts, sig, line_index, line}  sort {-ts}}

live_sol_balance_changes

One row per account whose SOL balance changed in a transaction that touches the address.

The net SOL flow of each wallet, fees included:

RPCX methodtext
# Net SOL change per wallet, in SOL.method netSol(wallets: pubkey[] "Wallets", from: time, to: time) {  from live_sol_balance_changes  filter (address | in wallets) && ts >= from && ts < to  filter account == address  group {address} (    aggregate {      txs = count_distinct sig,      net_lamports = sum change    }  )  derive {net_sol = net_lamports / 1000000000}  sort {-net_sol}}

filter account == address keeps only the wallet's own balance. Without it, you also get the other accounts in the same transactions.

live_token_balance_changes

One row per token account whose balance changed in a transaction that touches the address.

The net token flow of each wallet, per mint:

RPCX methodtext
# Net token change per wallet and mint, in base units.method tokenFlows(wallets: pubkey[] "Wallets", from: time, to: time) {  from live_token_balance_changes  filter (address | in wallets) && ts >= from && ts < to  filter owner == address  group {address, mint} (    aggregate {      txs = count_distinct sig,      net = sum change    }  )  sort {address, -txs}}

To follow one token only, add a pubkey param and filter mint == token.

live_blocks

One row per block. Read by a ts or slot range only, up to 3,000 slots.

Blocks and transactions in a slot range:

RPCX methodtext
# Block count and transactions in a slot range.method blockStats(start: uint64 "First slot, inclusive", stop: uint64 "Last slot, exclusive") {  from live_blocks  filter slot >= start && slot < stop  aggregate {blocks = count this, txs = sum tx_count, first_ts = min ts, last_ts = max ts}}

live_accounts

The current state of each account. One row per address that exists.

The SOL balance of many wallets:

RPCX methodtext
method solBalances(wallets: pubkey[] "Wallets") {  from live_accounts  filter (address | in wallets)  select {address, sol = lamports / 1000000000, owner, slot}  sort {-sol}}

An address with no account on chain returns no row.

live_token_accounts

The token accounts each wallet holds now, for SPL Token and Token-2022.

Who holds a token, among a list of wallets:

RPCX methodtext
# Balance of one token for each wallet that holds it.method holdersOf(owners: pubkey[] "Wallets", token: pubkey "Token mint") {  from live_token_accounts  filter (owner | in owners) && mint == token  filter amount > 0  select {owner, token_account, ui_amount}  sort {-ui_amount}}

Every non-empty holding of a list of wallets:

RPCX methodtext
method holdings(owners: pubkey[] "Wallets") {  from live_token_accounts  filter (owner | in owners)  filter amount > 0  select {owner, mint, ui_amount, program}  sort {owner, -ui_amount}}