RPCX Method Language Reference
Every step, function, operator, param type, and rule of the RPCX method language, each with its syntax and an example on the live tables.
This page lists everything the RPCX method language accepts, so you can write a method without a coding agent. Each step and function has its syntax, what it does, and an example. Every full method on this page reads the live tables and takes a list of wallets, so one call covers many addresses.
For a shorter introduction and the rules for live tables, see Writing methods. To find tables and columns, see Live tables and All tables. For one example per table, see Examples by table.
The shape of a method
A method is a header followed by a body in braces.
# Transactions of many wallets in a time window, newest first.method walletTxs( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)", limit: uint64 = 100 "Max rows",) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < toselect {address, ts, sig, success, fee}sort {-ts}take limit}- Header:
method <name>(<params>) {. The name is 1 to 64 letters, digits, or underscores. You call the method asrpcx_<name>. Use()for a method with no params. - Body: a pipeline, one step per line. It starts with
fromand ends before the closing}. Each step works on the rows from the step before. - Comments: a
#starts a comment that runs to the end of the line, in the header or the body. - The last
}in the text closes the method. Nothing may follow it except blank lines.
Params
Params go between the parentheses, separated by commas. They may span several lines, and a trailing comma is allowed.
name: typename: type = defaultname: type = default "Description"name?: type- A param name starts with a letter or
_, then letters, digits, or_. Each name is used once. - A param is required unless it has a default.
- A default is a number, a double-quoted string,
true, orfalse. It must fit the type: auint64default is a whole number of 0 or more, and atimedefault is a string such as"2026-11-15". - The description is a double-quoted string and always comes last. It is saved with the method.
name?: typemarks a param as optional with no default. A call that leaves it out, or passesnull, getsnullfor it. See Optional filters.
Param types
pubkey and signature values are checked when the method runs, also inside lists. A value, or a default, that is not valid base58 of the right length is refused. An empty string is not a valid pubkey.
List params
A list param holds many values in one param. A call passes it as a JSON array, with up to 1,000 values. Use it with in:
filter (address | in wallets)This is how a method reads many addresses at once. RPCX reads every address in the list in the same run, so pass all of them in one call instead of calling the method once per wallet. filter address in wallets, without the pipe, means the same.
Using params in the body
There are three ways to refer to params and columns:
In filter address == wallet, address is a column and wallet is the param. live_token_balance_changes has a column named owner, so a method on it that also has an owner param writes this.owner for the column:
method tokenMovesOfOwner(wallets: pubkey[], owner: pubkey, from: time, to: time) {from live_token_balance_changesfilter (address | in wallets) && ts >= from && ts < tofilter this.owner == ownerselect {address, ts, sig, mint, change}}A let may not have the same name as a param.
Params the dashboard adds for you
In the dashboard Code tab you can use a name before you declare it. When the code uses a name that is not a param, a column of a table in from or join, a name made in the code, or a function, the Params tab adds a row for it, marked from code. When the code stops using the name, the row goes away again, unless you edited it.
The type is a guess. Check it before you save:
Params from code are always required. Add a default in the Params tab to make one optional.
Optional filters
To let callers skip a filter, mark the param with ? and test it for null:
method tokenMoves( wallets: pubkey[] "Wallets", token?: pubkey "Token mint. Leave it out for all tokens.", from: time "Start (UTC)", to: time "End (UTC)",) {from live_token_balance_changesfilter (address | in wallets) && ts >= from && ts < tofilter (token == null || mint == token)group {address} (aggregate {moves = count this})}A call without token counts the token balance changes of every mint. A call with token counts only that mint, and the address is still checked as a pubkey.
Two places need a value, so they do not take an optional param:
take. Give the param a default instead, such aslimit: uint64 = 100.- The key or range of a live table, such as
(address | in wallets)orts >= from && ts < to. Use required params there.
Steps
A step takes the rows from the step before it and returns new rows. The body starts with from.
from
Start the pipeline from a table, or from a relation made with let.
from <table>from <alias> = <table>The alias gives the table a short name, which you need with join. Table names come from list_tables, from Live tables, or from the Code tab, which lists them when you type from .
Every read of a live table needs a key or a bounded range in the filter right after from: a key such as address, sig, program on live_instructions, or owner on live_token_accounts, or on a chain table a ts or slot range. Add a ts range to every read by address. See Keys and ranges.
method firstTxs(wallets: pubkey[], from: time, to: time) {from t = live_signaturesfilter (t.address | in wallets) && t.ts >= from && t.ts < toselect {t.address, t.ts, t.sig}take 10}filter
Keep the rows where the condition is true.
filter <condition>Join conditions with && (and) and || (or). Several filter lines in a row act like one filter joined with &&.
method costlyTxs(wallets: pubkey[], from: time, to: time, min_fee: uint64 = 100000) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < tofilter fee >= min_fee && successselect {address, ts, sig, fee, compute_units}}Put the key or range in the first filter, right after from.
derive
Add computed columns and keep all the others.
derive {<name> = <expression>, ...}A new column can be used by the steps after it, including later columns in the same derive.
method feePerCompute(wallets: pubkey[], from: time, to: time) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < tofilter compute_units > 0derive { fee_sol = fee / 1000000000, lamports_per_cu = fee / compute_units}select {ts, sig, fee_sol, lamports_per_cu}take 20}select
Keep only the listed columns, in that order. A column can be renamed or computed.
select {<column>, <new_name> = <expression>, ...}method txsShort(wallets: pubkey[], from: time, to: time) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < toselect {ts, sig, payer = signer, ok = success}take 20}After a select, only the selected columns exist. Put filters on other columns before it.
sort
Order the rows. A leading - sorts in descending order. List several columns to break ties.
sort {<column>, -<column>, ...}method newestTxs(wallets: pubkey[], from: time, to: time) {from live_signaturesfilter (address | in wallets) && ts >= from && ts < tosort {-ts, sig}select {address, ts, sig, success}take 20}Rows have no set order unless you sort. The order also matters for window.
take
Keep the first rows.
take <n>take <start>..<end>take <param>take 10 keeps the first 10 rows. take 11..20 keeps rows 11 to 20: the count starts at 1 and both ends are included. take limit uses a param, which must be uint64 or int64.
method secondPageOfTxs(wallets: pubkey[], from: time, to: time) {from live_signaturesfilter (address | in wallets) && ts >= from && ts < tosort {-ts}select {address, ts, sig}take 21..40}Use one take with a param per method. Use sort before take to choose which rows you get.
group and aggregate
aggregate reduces rows to one row. group runs a short pipeline once for each distinct value of its columns, and is almost always used with aggregate.
aggregate {<name> = <aggregate function>, ...}group {<column>, ...} (<pipeline>)Without group, aggregate returns one row for all rows:
method txStats(wallets: pubkey[], from: time, to: time) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < toaggregate { txs = count_distinct sig, payers = count_distinct signer, fees = sum fee}}With group, you get one row per group, with the group columns first:
method txsPerWallet(wallets: pubkey[], from: time, to: time, limit: uint64 = 20) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < togroup {address} ( aggregate { txs = count this, fees = sum fee })filter txs >= 10sort {-txs}take limit}- A
filterafter the group filters the grouped rows, for examplefilter txs >= 10. groupcan also holdsortandwindow. Seewindow.group {<column>} (take 1)keeps one row per value. See One row per value.group {<column>} (sort {...} | take 3)keeps the top 3 rows per value. See Top rows per group.- The aggregate functions are listed in Aggregate functions.
join
Add the columns of a second table to each row, where a condition matches.
join <alias> = <table> (==<column>)join <alias> = <table> (<condition>)join side:<inner|left|right|full> <alias> = <table> (<condition>)(==sig)joins rows where the columnsigis equal on both sides.- A condition can compare any columns, for example
(c.sig == t.sig). In a condition,thisis the table before the join andthatis the joined table:(this.sig == that.sig). sidesets which rows are kept.inner, the default, keeps rows that match on both sides.leftkeeps every row from the first table.rightkeeps every row from the joined table.fullkeeps every row from both.- Give both tables an alias and use it for the columns, such as
c.ts. Columns with the same name in both tables are ambiguous without one.
Each live table in a join needs its own key or range. Read the second table in a let, or in a pipeline in parentheses, with its own filter, then join it. This adds the fee and fee payer of the transaction to each token balance change:
method tokenMovesWithFee(wallets: pubkey[], from: time, to: time) {let txs = ( from live_transactions filter (address | in wallets) && ts >= from && ts < to select {address, sig, fee, signer})from c = live_token_balance_changesfilter (c.address | in wallets) && c.ts >= from && c.ts < tojoin side:left t = txs (c.sig == t.sig && c.address == t.address)select {c.address, c.ts, c.sig, c.mint, c.change, t.fee, t.signer}}c.address == t.address in the condition matters: a transaction that touches two of your wallets has one row for each of them in both tables.
When a row has no match, the columns from the other table are null. To find rows without a match, test for null, for example filter t.sig == null.
window
Compute columns over a frame of nearby rows, in the current sort order. The row count stays the same.
window (<pipeline>)window rows:<a>..<b> (<pipeline>)window range:<a>..<b> (<pipeline>)window rolling:<n> (<pipeline>)window expanding:true (<pipeline>)The pipeline inside is a derive that uses window functions or aggregate functions. Sort first. Inside group, the window restarts for each group.
A moving average of the fee over the current row and the two before it:
method movingAverageFee(wallet: pubkey, from: time, to: time) {from live_transactionsfilter address == wallet && ts >= from && ts < tosort {ts}window rows:-2..0 (derive {avg3 = average fee})select {ts, sig, fee, avg3}take 50}The frame forms:
A running SOL balance change per wallet, with expanding:true inside group:
method runningSol(wallets: pubkey[], from: time, to: time) {from live_sol_balance_changesfilter (address | in wallets) && ts >= from && ts < tofilter account == addressgroup {address} ( sort {ts} window expanding:true (derive {running = sum change}))select {address, ts, sig, change, running}sort {address, ts}}A filter after window can use the new column.
One row per value
There is no distinct step. To keep one row per value, group by the columns and take one row:
group {<column>, ...} (take 1)method mintsMoved(wallets: pubkey[], from: time, to: time) {from live_token_balance_changesfilter (address | in wallets) && ts >= from && ts < toselect {mint}group {mint} (take 1)}Steps after it, such as sort and take, work on the rows it keeps. To keep more than one row per value, use a larger take inside the group. See Top rows per group.
To count the rows of each value as well, group with aggregate:
method mintList(wallets: pubkey[], from: time, to: time, limit: uint64 = 100) {from live_token_balance_changesfilter (address | in wallets) && ts >= from && ts < togroup {mint} (aggregate {moves = count this})sort {-moves}take limit}let
let names a relation or a function, before the main pipeline. Use it to keep a long method readable.
let <name> = (<pipeline>)let <name> = <param> -> <expression>Use a relation with from <name>. A relation that reads a live table needs its key or range inside the let, right after its from.
method failedTxCount(wallets: pubkey[], from: time, to: time) {let failed = ( from live_signatures filter (address | in wallets) && ts >= from && ts < to filter success == false select {address, sig})from failedgroup {address} (aggregate {failures = count this})}A function names its argument before ->:
method feesInSol(wallets: pubkey[], from: time, to: time) {let sol = x -> x / 1000000000from live_transactionsfilter (address | in wallets) && ts >= from && ts < toselect {ts, sig, fee_sol = sol fee}take 20}Functions
Arguments follow the function name, separated by spaces, with no parentheses or commas: math.round 2 x. When an argument is itself an expression, put it in parentheses: math.round 2 (fee / amount_in).
The examples below are expressions on the columns of live_transactions and live_token_balance_changes.
Aggregate functions
Use these inside aggregate, or inside window for a value over the frame.
To get the time of the first or last transaction, use min ts or max ts.
Window functions
Use these inside window (derive {...}), after a sort.
Math functions
Text functions
The text to work on is always the last argument.
Date functions
Other functions
These two are used with a pipe, |. Inside {...}, such as in derive or select, put the whole expression in parentheses.
In a filter, in takes a list param, a literal list, or a range:
method txsOfTwoWallets(from: time, to: time) {from live_signaturesfilter (address | in [ "ARu4n5mFdZogZAravu7CcizaojWnS6oqka37gdLT5SZn", "EKmzDJWkajsqLMkY5WLWts9iUgqHCQny6hhd77fcQGN",]) && ts >= from && ts < toselect {address, ts, sig}}With a list param, the same filter is filter (address | in wallets), and the caller passes the addresses.
Operators and literals
Operators
The examples are expressions on live_transactions and live_token_balance_changes.
Use parentheses when in doubt about the order: (a + b) * c.
Literals
A date literal can replace a time param, for example filter ts >= @2026-11-15 && ts < @2026-11-16. The method then always reads the same range, and returns nothing once that range is older than the live data. Use time params instead.
case
case picks the value of the first condition that is true. End with true => for a default.
case [<condition> => <value>, ..., true => <default>]method feeSizes(wallets: pubkey[], from: time, to: time) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < toderive { size = case [ fee >= 1000000 => "large", fee >= 10000 => "medium", true => "small", ],}select {ts, sig, fee, size}take 20}To count the rows for each case value, group by the new column:
method feeSizeCounts(wallets: pubkey[], from: time, to: time) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < toderive { size = case [ fee >= 1000000 => "large", fee >= 10000 => "medium", true => "small", ],}group {size} (aggregate {txs = count this})}Names and columns
- Strings use double quotes.
- A column with the same name as a param needs
this.:this.owner. See Using params in the body. - After a
join, write<alias>.<column>. Give an output column a clear name when both tables have it, for exampletx_ts = t.ts. - A new column named like a function, such as
sum,min,count, orneg, cannot be used by a later step: the check fails withAmbiguous name. Pick another name, such astotalortxs. - Amounts are raw integers. SOL amounts are in lamports. Token amounts are in base units: divide by
10^decimalsyourself.
The time range
The chain tables hold the latest Solana data, up to the newest blocks. On a read by address, add a ts range:
filter (address | in wallets) && ts >= from && ts < to- With a key, the range only narrows the read. RPCX reads only the transactions in it, so the run is faster and costs less.
- Without a range, RPCX reads every transaction of each address that it has. For busy addresses, such as programs, the USDC mint, or the System Program, that is a lot of data, and the run can reach the 30-second limit.
- Without a key, a range alone reads every block in it, so it may cover at most 3,000 slots.
slot >= start && slot < stopworks the same way. - Older history is not available. A range that starts earlier returns only the rows RPCX still has.
- Use
timeparams for the bounds. A date literal, such as@2026-11-15, always reads the same range, so the method returns nothing once it is older than the live data. live_accountsandlive_token_accountshave notscolumn. They hold the state at the time the method runs.
Not allowed
These are refused by Validate:
Recipes
Each recipe is a complete method. Paste it into the Code tab of a new method, fill in Params, select Save, and then Run. For wallets, enter one address per line. Start with a short, recent time range.
Activity of many wallets
# Transactions, failures, and fees per wallet in a window.method walletActivity( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)",) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < toderive { failed = case [success == false => 1, true => 0], own_fee = case [signer == address => fee, true => 0],}group {address} ( aggregate { txs = count this, failures = sum failed, first_tx = min ts, last_tx = max ts, fees_paid = sum own_fee })sort {-txs}}For the single transactions, see the walletTxs method at the top of this page.
Who pays for your wallets' transactions
# Fee payers other than the wallet itself, per wallet.method feePayers( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)", limit: uint64 = 50 "Max rows",) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < tofilter signer != addressgroup {address, signer} ( aggregate { txs = count this, fees = sum fee })sort {-txs}take limit}Net SOL flow per hour
# Net SOL change per wallet and hour, in SOL.method solPerHour( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)",) {from live_sol_balance_changesfilter (address | in wallets) && ts >= from && ts < tofilter account == addressderive {hour = date.trunc "hour" ts}group {address, hour} ( aggregate { txs = count_distinct sig, net_lamports = sum change })derive {net_sol = net_lamports / 1000000000}sort {address, hour}}Token inflows of many wallets
# Tokens each wallet received, by mint.method tokenInflows( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)",) {from live_token_balance_changesfilter (address | in wallets) && ts >= from && ts < tofilter owner == address && change > 0group {address, mint} ( aggregate { receipts = count this, received = sum change, last_receipt = max ts })sort {address, -receipts}}Balances and holdings now
# SOL balance and number of token holdings per wallet, right now.method walletSnapshot(wallets: pubkey[] "Wallet addresses") {let holdings = ( from live_token_accounts filter (owner | in wallets) filter amount > 0 group {owner} (aggregate {tokens = count this}))from a = live_accountsfilter (a.address | in wallets)join side:left h = holdings (a.address == h.owner)select {a.address, sol = a.lamports / 1000000000, tokens = h.tokens ?? 0}sort {-sol}}A wallet with no token holdings gets tokens = 0. An address with no account on chain returns no row.
Number each wallet's transactions
# Each wallet's transactions in a window, numbered in time order.method txsNumberedPerWallet( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)", limit: uint64 = 200 "Max rows",) {from live_signaturesfilter (address | in wallets) && ts >= from && ts < togroup {address} ( sort {ts} window (derive {nth = row_number this}))select {address, nth, ts, sig}sort {address, nth}take limit}Top rows per group
# Each wallet's three most expensive transactions in a window.method topFeesPerWallet( wallets: pubkey[] "Wallet addresses", from: time "Start (UTC)", to: time "End (UTC)", limit: uint64 = 300 "Max rows",) {from live_transactionsfilter (address | in wallets) && ts >= from && ts < togroup {address} ( sort {-fee} take 3)select {address, ts, sig, fee}sort {address, -fee}take limit}take 3 inside group keeps the first 3 rows of each wallet, in the order of the sort before it. Change 3 to keep more or fewer rows per wallet.