# On-chain actions

Quests check what a member's linked wallet did on chain with two evaluator readers: `ctx.wallet.events()` for EVM contract events and `ctx.wallet.transactions()` for Solana programs. `ctx.wallet.programAccount()` reads the state a Solana program keeps per wallet ([Solana program accounts](#solana-program-accounts)), and `ctx.wallet.stake()` the SOL a wallet delegates through native stake accounts ([Solana native stake](#solana-native-stake)). All four follow the [evaluator reader rules](verification.md#evaluator-readers-null-errors-and-pinning): missing is `null`, a failure throws. The [wallets guide](/docs/build/wallets#check-on-chain-actions) installs and configures the ready-made quests that use them.

## EVM events

`ctx.wallet.events({ event, account, since, afterActivation?, where?, address?, newest? })` reads the events of one EVM contract whose `account` argument is one of the member's pinned linked EVM wallets, from `since` to the chain's `finalized` block (its `safe` block on a chain without a finalized tag). `event` is a CAIP-10 contract, a space and the event's Solidity signature with argument names and `indexed` markers, such as `"eip155:8453:0x… Transfer(address indexed from, address indexed to, uint256 value)"` (a leading `event` keyword is accepted): every argument named, at most three indexed, at least one indexed `address`, no tuples or arrays of arrays. Take it from a `settings.contractEvent({ label, description?, default })` setting, typed `ContractEvent`; never from member input. `isContractEvent()` and `parseContractEvent()` from `@domino-sdk/relay/authoring` check the syntax. `account` names the indexed `address` argument matched against the wallets, such as `"to"`. `since` is epoch milliseconds, at most 30 days before the evaluation (`maxWalletEventLookback`); `afterActivation: true` raises it to the quest's first activation in the environment.

It returns `{ event, chain, contract, since, at, finality, complete, logs, observedAt }`: `event` with the contract EIP-55 checksummed, `at` the newest block read (`{ kind: "block", number }`), `finality` `"finalized"` or `"safe"`, `complete` whether `logs` holds every matching event since `since` (absent from results captured before Relay reported it), and `logs` oldest first, each `{ wallet, block, timestamp, tx, logIndex, args }` with `timestamp` the block's time in epoch milliseconds and `args` every argument by name (integers as decimal strings, addresses EIP-55, bytes lowercase hex, an array argument as an array). Key a repeatable completion on `` `${chain}:${tx}:${logIndex}` ``.

- `where` maps argument names to an equality (an address in any case, a decimal integer, `true`/`false`, or hex bytes) or `{ gte: "<decimal>" }` for an integer argument; every condition must hold, at most 10. Equalities on indexed static arguments also narrow the RPC topic filter. A condition on the `account` argument, an unknown argument, an array, an indexed dynamic argument (stored as its hash) or a value of the wrong type throws `author-error`.
- Only events that name the member in an indexed argument can be read: a router or aggregator flow where the member is only `tx.from` cannot. No Cosmos or Snapshot activity; Solana programs are read with [`ctx.wallet.transactions()`](#solana-transactions).
- Reads go through dRPC: `eth_chainId`, the finalized (or safe) block, the first block estimated from block times and checked against its header, then `eth_getLogs` over 10,000-block ranges, several requests at a time, a refused range halved down to 100 blocks (below that, `provider-unavailable`). A read over more than 3,000,000 blocks or more than 1,000 logs (`limits.walletEventLogs`, counted before `where` filters non-indexed arguments) throws `author-error`. 3,000,000 blocks is under 30 days on fast chains; at block times measured in October 2026, about: Robinhood 3 days, Gravity 8, opBNB 8, Arbitrum One 9, Monad 10, Cronos 14, Plume 15, BNB Smart Chain 15, Sei 16, Telos 17, Arc 17, Tempo 19, Playnance 20, Aurora 22, Stable 24, Moca 28. Only finalized blocks are read, so no reorg handling is needed; recent events appear once final (about 13 minutes on Ethereum, longer on rollups).
- `newest: n` (1 to 1,000) returns at most the `n` newest matching events: Relay scans back from the head and stops at either cap instead of throwing, with `complete: false` when it left older matching events out or stopped before `since`. Without `newest`, a read returns every matching event with `complete: true` or throws. Use it for a busy wallet or a long window on a fast chain.
- Publication, Console settings edits and unarchiving check every `settings.contractEvent()` value: the syntax, a chain Relay reads, a chain that reports a `finalized` or `safe` block, and code at the address. Refusals are `422 validation-failed` naming the setting's label; an RPC outage is `503 unavailable`; a platform without a dRPC key refuses every event with `503 not-configured`.
- `address`, `null` and failures follow `ctx.wallet.balance()`: no linked EVM wallet returns `null`; outages throw `provider-unavailable`. Reads are captured, replayed on retries, and count toward the eight capability calls.
- `WalletReader.events` is optional in the type so that older test doubles compile; hosted evaluations always supply it, so call it as `ctx.wallet.events!(…)`. The testing kit answers it from `facts.wallet.events` (called with `{ event, account, since, afterActivation, where, address }`, defaults `false` and `null`, plus `newest` when the quest sets it) without applying `since`, `where` or `newest`, null while `facts.wallet.list` links no EVM wallet; a run's `capabilityCalls` lists event reads as `wallet-events`.
- Anti-sybil: set a minimum with `where` and `gte`, count only logs at or after the wallet's `verifiedAt`, keep `since` recent, and add a member budget.

Snippet `onchain-action` installs a complete quest: a `settings.contractEvent()` event, the participant argument, an optional `settings.amount()` minimum, events since the later of activation and the wallet's `verifiedAt` within 30 days read with `newest: maxWalletEventLogs`, and a `keyed` completion on `chain:tx:logIndex` that skips events already rewarded.

## Solana transactions

`ctx.wallet.transactions({ program, chain?, since, afterActivation?, mint?, address? })` reads the successful transactions at `finalized` commitment of the member's pinned linked Solana wallets since `since` that invoked `program` in a top-level or inner instruction (lookup-table addresses resolved), oldest first. Take `program` from a `settings.solanaProgram({ label, description?, default })` setting (base58, `isSolanaProgram()`); never from member input. `chain` is the cluster: omit it (or pass `"solana"` or `"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"`) for mainnet, or pass `"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"` for devnet; the same linked wallets are read on either, and the result's `chain` names the cluster. `since` is epoch milliseconds, at most 30 days before the evaluation (`maxWalletTransactionLookback`); `afterActivation: true` raises it to the quest's first activation. With `mint` (an SPL mint), Relay pages the signatures of each wallet's associated token account for the mint instead of the wallet's: far fewer transactions, but tokens in other token accounts are not seen.

It returns `{ program, chain, mint, since, at, complete, transactions, observedAt }`: `at` the finalized slot read (`{ kind: "slot", number }`), and `transactions` each `{ wallet, signature, slot, timestamp, signer, programs, balanceChanges }`, with `signer` whether that wallet signed it (read from the parsed account keys; `false` in results captured before it existed and in testing-kit facts that omit it), `programs` every invoked program in call order (each top-level instruction's program, then the programs it called) and `balanceChanges` `[{ mint, delta }]` (`mint` `"SOL"` for lamports, rent included and the fee left out when the wallet paid it, wrapped SOL under its own mint; `delta` a signed integer string; unchanged mints omitted). Token changes come from `preTokenBalances`/`postTokenBalances` of accounts the wallet owns, so tokens routed through accounts it does not own do not show. A transaction touching two linked wallets appears once per wallet. A transaction appears when it touched the wallet (or, with `mint`, its token account), whoever signed it: an incoming transfer from someone else's swap counts as received, with `signer` false. Check `signer` for anything that rewards an action. Key a repeatable completion on `signature`.

- Helpers in `@domino-sdk/relay/authoring`, pure over one transaction: `received(tx, mint)` and `spent(tx, mint)` (integer string or `"0"`), `swapped(tx, { into?, from? })` (one mint down, a different one up), `invoked(tx, program)`, `instruction(tx, name)` (first decoded instruction's args, or `null`).
- Instructions: saving a `settings.solanaProgram()` value (publication, Console edit) stores the program's IDL (Anchor legacy or 0.30+, Codama `rootNode` with `standard: "codama"`, or Shank with `metadata.origin: "shank"`), read on the cluster the check found the program on, in the release's `solanaIdls[settingKey]` (`{ program, source: "chain" | "pasted", idl }`); a later on-chain upgrade changes nothing until the next save. Two places are read, the first winning: the Program Metadata Program's canonical `idl` account (Anchor 1.0 and later, Codama; UTF-8 JSON, format JSON or none, stored in the account, uncompressed, gzip or zlib) and the legacy `anchor:idl` account the program owns (earlier versions). An operator can paste one in Console (quest → **Instruction decoding**) or send `solanaIdls: { [settingKey]: idl | null }` with `POST /releases/settings`; a pasted IDL takes precedence over the on-chain one until removed (`null`), when the save stores the on-chain one. A pasted IDL in none of these formats, naming another program (`address`, `metadata.address` or Codama `program.publicKey`), or over 512 KiB is `422`. With an IDL, each transaction has `instructions`: the program's top-level and inner instructions in call order, `{ name, args, accounts }`, matched on the IDL's discriminator: Anchor's first 8 bytes (the IDL's `discriminator`, else `sha256("global:<snake_case name>")[..8]`), Shank's `discriminant`, Codama's discriminator nodes (constant, field and size); undescribed or undecodable ones are skipped. A Codama instruction's discriminator argument is left out of `args`, and an optional account it leaves out (the program passed in its place) is left out of `accounts`; with `optionalAccountStrategy: "omitted"`, a transaction passing fewer accounts than the instruction lists names none from the first optional one on. Names as the IDL spells them. Args: ints up to 32 bits and floats as numbers, 64/128-bit as decimal strings, `pubkey` base58, `bytes`/`vec`/arrays as arrays, absent option `null`, struct as object, enum `{ Variant: fields }`, tuple as array, map as an object keyed by each key as a string, Codama base16/58/64 strings in their encoding. `accounts` maps IDL account names (composite `group.name`) to addresses. Without an IDL, `instructions` is absent.
- Each wallet's read fetches at most 1,000 successful transactions (`limits.walletTransactions`), newest first; a wallet with more, or whose newest 10,000 signatures don't reach `since`, returns its newest ones with `complete: false` and does not throw.
- Reads use the platform's Solana RPC for the cluster (dRPC's `solana` or `solana-devnet` network where it has the key), after checking the cluster's genesis hash: `getSignaturesForAddress` at `finalized`, failed signatures skipped, then `getTransaction` with `jsonParsed` and `maxSupportedTransactionVersion: 1`. A transaction appears about 13 seconds after it lands.
- Publication, Console settings edits and unarchiving check every `settings.solanaProgram()` value on Solana mainnet, then on devnet when mainnet has no executable program there: an address with no account on either, or one executable on neither, is `422 validation-failed` naming the setting's label; an RPC outage is `503 unavailable`.
- `address`, `null` and failures follow `ctx.wallet.balance()`: no linked Solana wallet returns `null`; outages throw `provider-unavailable`. Reads are captured, replayed on retries, and count toward the eight capability calls.
- `WalletReader.transactions` is optional in the type so that older test doubles compile; hosted evaluations always supply it, so call it as `ctx.wallet.transactions!(…)`. The testing kit answers it from `facts.wallet.transactions` (called with `{ program, since, afterActivation, mint, address }`, defaults `false` and `null`, plus `chain` for devnet; transactions may carry `instructions`) without applying `program`, `since` or `mint`, null while `facts.wallet.list` links no Solana wallet; a run's `capabilityCalls` lists transaction reads as `wallet-transactions`.
- Anti-sybil: someone else can send tokens to a member's wallet in a transaction that calls the program, so a `received()` check alone rewards transfers; require `tx.signer`, a minimum with `received()` against a `settings.amount()`, count only transactions at or after the wallet's `verifiedAt`, keep `since` recent, and add a member budget.

`domino quests from-idl <program> [--cluster mainnet|devnet] [--idl <file>] [--instruction <name>] [--key <key>] [--out <file>] [--rpc <url>] [--force]` writes a quest checking one instruction of an Anchor program, and a test beside it. It reads the IDL from `--idl`, else from the cluster's public RPC (`getMultipleAccounts` at `finalized`; `--rpc` overrides): the canonical Program Metadata `idl` account, then the legacy `anchor:idl` account, passing over one Relay would not store, as Relay does. Anchor legacy and 0.30+ only: a Codama or Shank IDL, one naming another program (`address`, `metadata.address`), over 512 KiB as minified JSON, with no instruction Relay decodes (a name, `accounts`, named `args`), unreadable or absent is `IDL_UNAVAILABLE`. Without `--instruction` it prompts in a terminal; otherwise `INPUT_REQUIRED` with `details.choices`, and an unknown name `INVALID_ARGUMENT`. It writes `<key>.quest.ts` (key default: the IDL's `metadata.name` or `name`, then the instruction, kebab-case) in the first `discover.quests` pattern's directory (`quests/` without relay.json) or `--out`, and `<name>.test.ts` beside it (vitest when the nearest package.json depends on it, else `node:test`, with `facts.wallet.transactions`); an existing file is `LOCAL_CONFLICT` unless `--force`. The quest follows `solana-action`'s guards (signed transactions after the wallet's `verifiedAt` and activation, deduplicated, keyed on `signature`), passes `chain` for devnet, and requires `instruction(tx, name)`; each argument of type `u8`–`u32`/`i8`–`i32` becomes a `settings.integer()` minimum (the type's smallest by default), `u64`/`u128` a `settings.amount()` minimum (`"0"`), `i64`/`i128` a `settings.text()` minimum (empty counts any), `bool` a `settings.choice()` of `any`/`true`/`false`, and `pubkey`/`publicKey`/`string` a `settings.text()` exact match (empty counts any); other types are TODO comments. Keys `program`, `balance` and `points` are the quest's own; a clashing argument key gets a numeric suffix. The `--json` result lists `settings` (`{ argument, type, setting }`), `unchecked` and `idlSource` (`file`, `program-metadata` or `anchor-idl-account`). With `--idl`, Relay still stores only the on-chain IDL at publication: paste the file in Console (**Instruction decoding**) or send `solanaIdls`. With `--account <type> --field <name> --seeds <seeds>` it writes an account-state quest instead (`--instruction` beside them is `INVALID_ARGUMENT`): `ctx.wallet.programAccount()` on the account type, `once()`, accepting when the field summed over the member's wallets (no account counts 0) reaches `minimum`, a `settings.amount()` (`"1"`) for unsigned fields or a `settings.text()` integer (`"1"`) for `i*`. Choices are the IDL's Borsh account types (0.30+ `serialization` other than `borsh` left out; legacy accounts carry their struct, 0.30+ ones name a type) and their `u8`–`u128`/`i8`–`i128` fields; a missing `--account`, or `--field`/`--seeds` outside a terminal, is `INPUT_REQUIRED` with `details.choices`, an unknown one `INVALID_ARGUMENT`. `--seeds` lists the seeds in order, comma-separated: `wallet` (required), `pubkey:<address>` (a `settings.text()` named `seed<position>`, the address its default), `<u8…i128>:<integer>` (literal), and other text or `string:<text>` (literal, 1–32 bytes), at most 15; anything else is `INVALID_ARGUMENT`. The test answers `facts.wallet.programAccount`. Spaces around a seed are ignored, and an integer seed must fit its type. The `--json` result has `instruction: null`, `account: { name, field, type, seeds }`, `settings` listing each `pubkey:` seed (`argument: "seed <position>"`) and the field's `minimum`, and empty `unchecked`; an instruction quest's has `account: null`.

`domino quests fixtures <signature...> --program <program> [--cluster mainnet|devnet] [--wallet <address>] [--idl <file>] [--out <file>]` turns real transactions into a `facts.wallet.transactions` answer (`management.solana.transactionFixture({ chain, program, signatures, wallet?, idl? })`, experimental, `POST /solana/transaction-fixtures`, `read` permission). Relay reads them through its Solana RPC as `ctx.wallet.transactions()` does and decodes the program's instructions with the IDL saving the program's setting stores (the on-chain one Relay reads for the setting, mainnet first, then devnet), or `--idl`'s, checked as a pasted IDL. Each must be finalized, successful, on the cluster, call the program and list the wallet (`--wallet`, default the fee payer, which must then be the same for all) among its accounts; the answer is that wallet's view, oldest first, with `mint: null`, `complete: true` and `since` the oldest block time. At most 20 distinct signatures a call (`limits.transactionFixtureSignatures`; the CLI refuses more with `INVALID_ARGUMENT`, the API with 400). Refusals: 404 `transaction-not-found` (no transaction on that cluster, such as one from the other cluster; CLI `NOT_FOUND`), 409 `transaction-not-final` (`CONFLICT`), 422 `transaction-failed`, and 422 `validation-failed` for another program, a wallet not in the transaction, an unusable `--idl` or a program that is not executable on the cluster (`REJECTED`); `apiCode` carries the API's code. 10 calls a minute per user and 100 an hour per organization (429 `rate-limited`). An `--idl` file the CLI cannot read or parse is `IDL_UNAVAILABLE`. Without `--out` the answer prints on stdout; `--json` prints it too.

Snippet `solana-action` installs a complete quest: a `settings.solanaProgram()` program, an optional token mint (an SPL mint, which narrows the read to its associated token accounts, or `"SOL"`) with a `settings.amount()` minimum received, transactions the linked wallet signed since the later of activation and its `verifiedAt` within 30 days, and a `keyed` completion on `signature` that skips transactions already rewarded. Its README shows a `spent()` variant for deposits and staking.

To complete the quest without the member asking for a check, trigger it with `automatic({ tracker })` on a `wallet.programActivity({ program, mint? })` tracker instead of `manual()`: the quest runs for each transaction the tracker records, within about 10 minutes of it finalizing, filters it with `where` on the record's data (`signature`, `signer`, `amount`, `delta`) with no evaluator and no Solana read of its own, and should key its completion on `tracker.record.data.signature`, since a transaction two linked wallets share is one record per wallet. The tracker's `minAmount` counts tokens moved in or out; for tokens received, filter `{ path: "delta", gt: 0, gte: { setting: "minimum" } }` and `{ path: "signer", equals: true }`. Snippet `solana-action-automatic` installs the tracker and the quest. Console shows "Completes automatically within about 10 minutes" on quests such a tracker triggers.

## Solana program accounts

`ctx.wallet.programAccount({ program, account, seeds, chain?, address? })` reads one account type at the program-derived address of each of the member's pinned linked Solana wallets: `find_program_address(seeds, program)` with `{ wallet: true }` replaced by each wallet's 32 bytes. Use it for state a program keeps per user, such as a stake, lock or position account ("staked at least N in our program"). `program` comes from a `settings.solanaProgram()` setting whose release stores an IDL (Anchor, Codama or Shank; on-chain or pasted, as for [instructions](#solana-transactions)); never from member input. `account` is the type's name in the IDL's `accounts`, such as `"Escrow"`. `seeds` are the program's `#[account(seeds = …)]` seeds in order, at most 15: `{ wallet: true }` (required, at least once), a string (UTF-8 bytes), `{ pubkey: "<base58>" }` (32 bytes), or an integer `{ u8 | u16 | u32 | u64 | u128 | i8 | i16 | i32 | i64 | i128: value }` (little-endian, as `to_le_bytes()`; a safe integer number or a decimal string). Other seeds come from code or settings, never member input. `chain` works as for `transactions()`.

It returns `{ program, chain, account, wallets: [{ address, pda, fields }], at, observedAt }`: `pda` the derived address, `fields` the account's fields by IDL name, decoded as instruction args are (ints up to 32 bits and floats as numbers, 64/128-bit as decimal strings, `pubkey` base58, option `null`, enum `{ Variant: fields }`), or `null` when no account exists at `pda`; `at` the slot every account was read at (`{ kind: "slot", number }`, `kind` open).

- One read: the genesis-hash check, then one `getMultipleAccounts` (`base64`, `confirmed`, the first 10 KiB of each account) for the program and every derived account; past 99 wallets, further calls with `minContextSlot` at the first call's slot.
- Each account must be owned by `program` and match the account type's discriminator (Anchor: the IDL's `discriminator` in 0.30+, else `sha256("account:<Name>")[..8]`; Codama: its discriminator nodes); otherwise `author-error` naming the account. Shank accounts, and Codama accounts that declare no discriminator, have none to check: the seeds alone pick the account. The program must be executable on the cluster. Zero-copy accounts a 0.30+ IDL marks (`serialization` other than `borsh`) are refused; a legacy IDL does not mark them, so read only Borsh accounts with one. An address holding only SOL (system-owned, no data), which anyone can create by sending SOL to it, reads as no account.
- `author-error`: a malformed program, a program with no IDL in the release, an account type the IDL does not name (the message lists the ones it does), seeds without `{ wallet: true }` or with a seed over 32 bytes or an integer out of range, data that does not decode as the type, and an unlinked `address`. Outages throw `provider-unavailable`, never `null` fields.
- `address`, `null` and capture follow `ctx.wallet.balance()`: no linked Solana wallet returns `null`; reads are captured, replayed on retries, and count toward the eight capability calls. Accounts not derivable from seeds (keypair accounts found by `getProgramAccounts`) cannot be read.
- `WalletReader.programAccount` is optional in the type for older test doubles; call it as `ctx.wallet.programAccount!(…)`. The testing kit answers it from `facts.wallet.programAccount` (called with `{ program, account, seeds, address }`, plus `chain` for devnet) without deriving or decoding, null while `facts.wallet.list` links no Solana wallet; `capabilityCalls` lists it as `wallet-program-account`.

Snippet `solana-program-state` installs a complete quest: JUP staked in Jupiter's locked voter by default (`Escrow` at `["Escrow", locker, wallet]`, summing `amount` across wallets) against a `settings.amount()` minimum; change the account type, seeds and field for another program.

To reward keeping a position over days ("keep JUP staked for 90 days") or rank holders by it, sample one integer field daily with a `wallet.programAccounts({ program, account, seeds, field, chain?, idl? })` tracker instead: see [Solana program account samples](trackers.md#solana-program-account-samples) and the `program-position-streak` snippet.

Snippet `realms-voter` reads SPL Governance (Realms, `GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw`): `tokenOwnerRecordV1` (which decodes V1 and V2 records) at `["governance", realm, mint, wallet]`, summing `governingTokenDepositAmount` against a `settings.amount()` minimum (Grape's realm and GRAPE by default); with a `proposal` setting it also requires a signed `castVote` within 30 days (`ctx.wallet.transactions()`) whose `proposalAccount` is the proposal and whose `voterTokenOwnerRecord` is one of the member's record `pda`s, since a vote record derives from the token owner record, not the wallet. SPL Governance publishes no IDL: the snippet ships a Shank IDL (`docs/snippets/realms-voter.idl.json`, from the Realms governance SDK, Apache-2.0) to paste. Voter-weight plugin realms (VSR, NFT voting) and votes a delegate cast are not read.

Snippet `solana-lp` checks liquidity in pools that issue an LP token (Raydium AMM v4 and CPMM, Meteora Dynamic AMM) with `ctx.wallet.balance({ chain: "solana", token: lpMint })` against a `settings.amount()` minimum (Raydium SOL-USDC by default). Not covered: Orca Whirlpools, Raydium CLMM and Meteora DAMM v2 (position NFTs whose accounts derive from the NFT mint; `nfts()` counts a whole collection, not one pool), Meteora DLMM (keypair positions), and LP staked in farms. LP locked in Meteora's lock escrow (`LockEscrow` at `["lock_escrow", pool, wallet]`, field `totalLockedAmount`) is a program-account read: `domino quests from-idl Eo7WjKq67rjJQSZxS6z3YkapzY3eMj6Xy8X5EQVn5UaB --account LockEscrow --field totalLockedAmount --seeds lock_escrow,pubkey:<pool>,wallet`.

## Solana native stake

`ctx.wallet.stake({ chain?, voteAccount?, address? })` reads the SOL the member's pinned linked Solana wallets delegate through native stake accounts: every Stake program account where a wallet is the staker or the withdrawer (either authority controls it). Use it for "delegates at least X SOL to our validator". `voteAccount` is the validator's vote account (base58, not its identity), from code or settings, never member input; omit it to count every validator. `chain` works as for `transactions()`.

It returns `{ chain, voteAccount, epoch, total, activating, deactivating, wallets: [{ address, amount, activating, deactivating }], voteAccounts: [{ voteAccount, amount, activating, deactivating }], at, observedAt }`, every amount lamports as a decimal string. At `epoch`: `total`/`amount` is active stake (activation epoch before it, or genesis, and not deactivating); `activating` was delegated this epoch and becomes active at the boundary; `deactivating` was deactivated this epoch. Neither is in `total`: add `activating` to accept members right after they delegate. Fully deactivated and undelegated accounts count nowhere. `voteAccounts` lists only validators with stake in some state; with `voteAccount`, only it. `at` is the earliest slot read (`{ kind: "slot", number }`, `kind` open).

- One read: the genesis-hash check, `getEpochInfo`, then per wallet two `getProgramAccounts` calls on `Stake11111111111111111111111111111111111111` (`base64`, `confirmed`), filtered by `dataSize` 200 and the wallet at the staker (12) or withdrawer (44) offset, plus the vote account (124) when given. An account found twice, or by two linked wallets, counts once, under its withdrawer when both are read. Across members it is not deduplicated: a withdrawer can set any address as staker, so two members can count the same account. Warmup and cooldown are taken as one epoch.
- `author-error`: a `voteAccount` that is not a base58 32-byte address, and an unlinked `address`. A node that refuses `getProgramAccounts`, an answer that is not a stake account holding the filtered bytes, and outages throw `provider-unavailable`, never zero.
- `address`, `null` and capture follow `ctx.wallet.balance()`: no linked Solana wallet returns `null`; a linked wallet without stake accounts reads `"0"`; reads are captured, replayed on retries, and count toward the eight capability calls.
- Native stake only: liquid-staking tokens are `ctx.wallet.balance()` on the token's mint; a stake pool's accounts belong to the pool's authorities, not the member.
- `WalletReader.stake` is optional in the type for older test doubles; call it as `ctx.wallet.stake!(…)`. The testing kit answers it from `facts.wallet.stake` (called with `{ voteAccount, address }`, plus `chain` for devnet) without classifying accounts, null while `facts.wallet.list` links no Solana wallet; `capabilityCalls` lists it as `wallet-stake`.

Snippet `validator-stake` installs a complete quest: a vote account, a minimum in lamports (shown in SOL) and whether activating stake counts; with it off, a member whose stake is still activating is asked to come back after the epoch boundary.

To reward keeping stake over days ("10 SOL delegated for a month") or rank stakers, sample it daily with a `wallet.stake({ chain?, voteAccount? })` tracker instead: see [Solana stake samples](trackers.md#solana-stake-samples) and the `validator-stake-streak` snippet.

## Quests completed from a signed Solana transaction

Experimental. An app's server completes a quest from a transaction the member signs in their wallet, instead of the member submitting it in a session:

1. The transaction carries an SPL Memo instruction (`MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr`) whose text is `solanaActionMemo({ quest, reference? })` from `@domino-sdk/relay/server`: `domino:quest:<quest key>`, then `:<reference>` when there is one. `reference` (up to 64 letters, digits, `_` or `-`) names where the quest was completed, such as a check-in station. The memo program fails the transaction if a signer it lists did not sign, and the wallet shows the text to the member.
2. Once the member signs and sends it, the server calls `management.attempts.submitSolanaTransaction({ quest, signature, chain? })` with a key holding `ingest` (hosted-app keys and editors do). `chain` is mainnet by default, or `"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1"` for devnet.
3. Relay reads the transaction at `finalized` and runs a normal attempt for the one member of the project and environment whose active linked Solana wallet signed it. It resolves with the queued attempt (202), whose `action` is `{ kind: "solana-transaction", chain, signature, wallet, reference }`.

The quest's evaluator decides, so its checks, budgets and completion policy apply unchanged. It reads the transaction as `ctx.action`, and so does a `keyed()` completion: `keyed((ctx) => ctx.action?.reference ?? "app")` completes once per reference per member. Every attempt that did not come from a transaction reads `ctx.action` as `null`.

| Refusal | Meaning |
| --- | --- |
| 409 `transaction-not-final`, with `Retry-After` | No finalized transaction by that signature yet; one finalizes about 13 seconds after it lands. Send the same signature again. An unknown signature answers this too, so retry up to a deadline. |
| 422 `transaction-failed` | The transaction failed on chain. |
| 422 `transaction-not-for-quest` | No Domino quest memo, more than one, or one naming another quest. |
| 404 `wallet-not-linked` | No signer is a member's active linked Solana wallet. Relay never links a wallet or signs a member in from a transaction: the member links it in the app first. |
| 409 `account-ambiguous` | Signers belong to different members; `members` lists them. |
| 422 `quest-not-transaction-completable` | Only a member-submitted `manual()` quest without input takes a transaction. |
| 422 `station-unknown` | The quest has `stations` and the memo's reference names none of them (or there is no reference). |
| 422 `station-proof-mismatch` | The named station is declared `proof: "code"`: it takes no transactions. |
| 409 `station-closed` | The named station was closed at the transaction's block time. |
| 409 `station-revoked` | An operator revoked the named station (`management.quests.stations.revoke()`), judged at submission, whenever the transaction was signed. |
| 502 `unavailable` | The Solana read failed; nothing was recorded. Send it again. |
| 429 `rate-limited`, with `Retry-After` | The project environment's budget of 1,500 reads per 10 minutes (3,000 across Domino) is spent; nothing was read. |

The signature names the attempt (its action ID is derived from it): sending it again returns the first attempt (200), even after the wallet was unlinked. A wallet linked or unlinked while the claim is admitted answers 409 `conflict`; send it again. Console's attempt view shows the transaction, the signing wallet and the reference; erasing the member removes them. A key limited to selected trackers (`ingestTrackers`) is refused with 403 `permission-required`. In tests, `runQuest(quest, { action: { wallet, reference? } })` supplies `ctx.action`, and refuses a quest Relay would refuse.

Check-in stations (experimental): `defineQuest({ ..., stations: [{ key, label, opensAt?, closesAt? }], completion: perStation() })`, up to 200 stations, keys unique and at most 64 letters, digits, `_` or `-` (the memo `reference`), labels up to 120 characters, times in epoch milliseconds with `closesAt` after `opensAt`; publishing breaks any of these, or stations on a quest that takes no transaction or on a reusable quest type (`defineQuestType`), with 422 `validation-failed`. Relay then takes a transaction only when its reference names a station whose window holds the transaction's block time (`opensAt <= blockTime < closesAt`; a missing bound is open), and refuses the quest's other submissions, a member's own included, with `station-unknown`. Operator paths skip the station check: a test member's pass, and member imports, whose keys are not checked against the stations. `perStation()` from `@domino-sdk/relay/authoring` is `keyed()` on the reference, so each member completes each station once and a repeat is accepted onto the existing completion. Stations are part of the release: deploys change them, promotion copies them to live, and `management.quests.list()` returns them. Station keys never change once printed: rotate a code by adding a station and closing the old one. `runQuest(quest, { now, action })` judges the window at `now`, and refuses a code station as Relay does.

A station may declare `proof: "code"` (`"transaction"` when left out; one quest can mix them; any other value is 422 `validation-failed`). Relay refuses every transaction naming a code station with 422 `station-proof-mismatch`, judged before the signers are looked up, because a transaction station's Solana Pay URL is public. Members check in at a code station with its code ([below](#check-in-with-a-code)). Its code is an environment binding, not part of the release: each environment holds its own per quest authoring key and station key, sealed, and a promotion never copies it but warns (`binding-missing`, kind `station-code`, key `<quest key>/<station key>`) for each code station live has no code for. `management.quests.stations.setCode(quest, station, { code, actionId? })` (`PUT /quests/<quest>/stations/<station>/code`; 6 to 64 letters, digits, `-` or `_`) sets a chosen code, `generateCode(quest, station, { actionId? })` (`POST …/code/generate`) sets a 12-character code from `ABCDEFGHJKLMNPQRSTUVWXYZ23456789` and answers it as `code` this once, and `clearCode(quest, station)` (`DELETE …/code`) removes it. Each answers `{ quest, station, codeSet, replaced }` and needs `publish` in the selected environment; a CLI session may write live too, automation keys and MCP clients test only. A retry with the same `actionId` answers the first result, the same generated code included. A station the current release lacks is 404 `not-found`, a transaction station 422 `station-proof-mismatch`, and setting or generating without the deployment's sealing key 503 `not-configured`; clearing also removes a code a later release left behind. No read returns a code: `management.quests.stations.list(quest)` answers each station's `proof` and `codeSet`, and the audit records `station-code-set` and `station-code-cleared` without it. From a terminal (experimental): `printf %s "$CODE" | domino quests stations code set <quest> <station>` reads the code from stdin only, never an argument, and refuses a terminal or an empty stdin with `INPUT_REQUIRED` before sending anything; `domino quests stations code generate <quest> <station>` prints the generated code this once (`code` under `--json`, and `next` says to store it now); `domino quests stations code clear <quest> <station> [--yes]` asks first when it can prompt. Like `domino secrets`, they use test unless `--environment live` is given, ignore `RELAY_ENVIRONMENT` and relay.json (warning when either names live), and answer `{ quest, station, codeSet, replaced, environment, next }`; when `replaced` is true, QR codes printed with the old code no longer check members in. `management.quests.stations.codeQr(quest, station, { url })` (`GET …/code/qr?url=<https scan page>`, `publish`, either environment) answers the station's printable QR code as SVG (`Cache-Control: no-store`): the scan page with `quest` (the quest's key, its ID when it has none), `station` and `code` query parameters added, keeping its own, and the station's label under it; Console's **Download QR** on a code station draws it. A station without a code there is 409 `station-code-not-set`, a transaction station 422 `station-proof-mismatch`, a non-https `url` 422 `validation-failed`.

### Check in with a code

Experimental. A member checks in at a code station with its code and no wallet, two ways:

- From the member's browser: `relay.quests.checkIn(quest, station, { code, actionId? })`, `POST /v1/me/quests/<quest>/stations/<station>/check-in` with `{ code, actionId }`, for the signed-in member ([participant-api.md](participant-api.md#check-in-at-a-code-station)). It also counts toward the member's 120 submissions an hour. Apps whose installed SDK predates it must upgrade: their portal proxy doesn't forward the route.
- From the app's server, when it checks codes itself: `management.attempts.submitStationCode({ quest, station, code, member, actionId? })`, `POST /management/v1/attempts/station-code`, with a key holding `ingest` and not limited to selected trackers (403 `permission-required`). `member` is the member the app signed in, such as `signedInMember`'s; a member Relay doesn't know is 404 `not-found`.

Either answers the queued attempt (202), or the first attempt for a repeated `actionId` (200). The attempt carries the station as `station` and no `action` (released clients parse `action` with a transaction's fields); the evaluator and `perStation()` read `{ kind: "station-code", reference: station }` in `ctx.action`, so each member completes each station once, a repeat is accepted onto the existing completion, and `management.quests.stations.list()` counts code check-ins in `completions`. Check `ctx.action.kind` before reading a transaction's fields. As with a transaction, a check-in waits while the member's previous attempt on the quest is undecided (409 `attempt-pending`). Relay compares the code in constant time and keeps none of it: no attempt, request, event, log line or answer holds it.

Relay checks the station refusals in the order below, after the guess budgets.

| Refusal | Meaning |
| --- | --- |
| 422 `station-unknown` | The quest has no station with that key, or no stations. |
| 422 `station-proof-mismatch` | Transactions prove the station, not a code. |
| 409 `station-code-not-set` | The station has no code in this environment (`stations.setCode` or `generateCode` sets one). |
| 409 `station-revoked` | An operator revoked the station. |
| 409 `station-closed` | The station is outside its window now: a code carries no time, so the window is judged at submission. |
| 422 `station-code-invalid` | The code doesn't match, letter case included. |
| 429 `rate-limited`, with `Retry-After` | A guess budget is spent; checked once the quest is found (an unknown quest is 404 `not-found`), before the station's checks and before any code is compared. |
| 503 `not-configured` | The deployment can't open station codes. |

A station's printed QR code opens the app's scan page with `quest`, `station` and `code` query parameters. `useStationCheckIn({ stations? })` from `@domino-sdk/relay/react` (experimental) runs that page: it reads them with `parseStationCodeLink`'s rules, removes `code` from the address bar with `history.replaceState`, keeps the check-in with an action ID in `sessionStorage` (`domino:pending-station-check-in`) until it settles, so it survives a sign-in that leaves the page and resumes wherever the hook renders next in the tab, and calls `relay.quests.checkIn` with the session once a member is signed in. It answers `{ status, quest?, station?, attempt?, code?, error?, retryAfter?, retry }`: `none` (no link and nothing kept), `sign-in-required`, `checking`, `checked-in` (with `attempt`; the experience is invalidated), `refused` (a 4xx answer, with the refusal `code` and `retryAfter` ms for `rate-limited`), or `failed` (network, 5xx, timeout or an uncertain write). `station` is `{ key, label }`, the label from `stations` (such as the quest's list) or the key. A refusal forgets the check-in except `rate-limited` and `attempt-pending`; `retry()` resends a kept one with the same action ID. A 401 or `stale-session` answer goes back to `sign-in-required`. `checkInAtStation(relay, { stations? })` from `@domino-sdk/relay/browser` does the same once, without React, and never rejects. The `station-codes` snippet installs a code-station quest, a stations module both import, and a scan page component.

Guess budgets count only wrong codes: 10 per member and station an hour (room for typos), and 600 per station in 10 minutes across members (a distributed guess at a 6-character code stays above a thousand years on average). While either is spent, every check-in it covers answers 429, a right code included, until its window ends. `runQuest(quest, { now, action: { kind: "station-code", reference } })` simulates a code check-in: it refuses a station the quest lacks, one transactions prove, or one closed at `now` with a `TestSetupError`, and takes the code as right.

To check members in at stations with a printed QR code, `defineStationAction({ quest, rpcUrl, linkUrl, chain?, label?, icon?, instructions?, waitUntil?, findTimeout?, management?, env? })` from `@domino-sdk/relay/server` (experimental) serves the quest's stations as Solana Pay transaction requests: a Web `(request, env?, context?) => Response` handler for `GET`, `POST` and `OPTIONS` of one URL, the station named by `?station=<key>`. `GET` answers `{ label, icon }` (the quest's title and image unless set). `POST { account }` answers `{ transaction, message }`: a legacy transaction with the member as fee payer, a blockhash read through `rpcUrl`, the instructions `instructions({ account, station, quest, request })` returns (none by default), a 0-lamport System transfer from the member to themselves that names a fresh reference key as a read-only account, and the quest's memo with the station key as reference. A quest without stations (422), a missing (400), unknown (404), code (422) or currently closed (409) station, a closed quest (422) and a bad `account` (400) are refused with `{ message }` before anything is built. Solana Pay has no callback: after answering, the handler polls `getSignaturesForAddress(reference)` through `rpcUrl` every 2 s for up to `findTimeout` (90 s), then submits the signature, retrying `transaction-not-final`, `attempt-pending`, `conflict` and `unavailable` for up to 60 s. It keeps running through `waitUntil` (Next.js `after`, with `maxDuration` covering about 150 s) or a Worker context's `waitUntil`, which Cloudflare stops 30 s after the response: there the lookup and submission stop at 28 s, so only a member who signs within about 10 s checks in. It logs failures with `console.error`. A member's own submission can't complete a station quest, so a check-in that did not count (an unlinked wallet, a missed lookup) is redone by scanning again; `perStation()` completes each station once. `domino quests stations qr <quest> [--url <https URL>] [--page-url <https URL>] [--out <dir>] [--force]` writes `<station key>.svg` per station (default directory `<quest key>-stations`) with the label under the code: a transaction station's encodes `solana:` and `--url` with `?station=<key>`, URL-encoded; a code station's is drawn by `management.quests.stations.codeQr` from its code in the command's environment, linking to `--page-url`. Pass the URL each kind of station the quest has needs; a missing one, a quest without stations or a non-HTTPS URL is `INVALID_ARGUMENT`, and an existing file `LOCAL_CONFLICT` unless `--force`. A code station without a code goes under `skipped` (`{ station, label, reason: "station-code-not-set" }`) and the rest are still written. The `--json` result has `environment`, `files` (`{ station, label, proof, file, link }`, where `link` is the Solana Pay link for a transaction station and the `--page-url` for a code station) and `skipped`, and never a code: the code is only inside the code stations' files, so keep them private until printed. Code stations need `publish`. The key needs `read` and `ingest`.

To serve the quest as a blink, `defineQuestAction({ quest, build, linkUrl, chain?, metadata?, reference?, management?, env?, confirmTimeout? })` from `@domino-sdk/relay/server` (experimental) returns a Web `(request, env?) => Response` handler for `GET`, `POST` and `OPTIONS` of one URL, from the app's own origin; serve `actionsJson(rules?)` at `/actions.json`. `GET` answers the Actions card (the quest's title, instructions and image unless `metadata` overrides them); an archived or paused quest, or one that can't take a transaction, gets a disabled card and its `POST` is refused before the member signs. `POST { account }` calls `build({ account, params, quest, request })`, which returns an unsigned `@solana/kit` transaction message (legacy or v0), kit's compiled transaction, or its bytes; the helper appends only the quest's memo (`reference(request)` sets its reference) and answers `{ type: "transaction", transaction, links.next }`. Throw `QuestActionRefusal(message, status?)` from `build` to refuse without calling Relay. The `links.next` callback submits the signature, retries `transaction-not-final`, `attempt-pending`, `conflict` and `unavailable` for about 45 s (about 50 s in all: raise a host's request limit such as Next.js `maxDuration`, or lower `confirmTimeout`), waits for the attempt's decision and answers a `completed` action (points, the rejection reason, or "check the app in a minute"); `wallet-not-linked` answers buttons that open `linkUrl` and resend the signature. Every response carries the CORS, `X-Action-Version: 2.4` and `X-Blockchain-Ids` headers, errors included; errors are `{ message }`, and an error thrown from `build` answers 500 and is logged. On `*.domino.page` the app needs `routing: "transparent"`. The key needs `read` and `ingest`.

To rank or count program use over time (weekly top users, active-day streaks, monthly volume) without an indexer, use a `wallet.programActivity({ program, ... })` tracker instead of an evaluator read: Relay records every member's matching transactions as tracker records every 10 minutes, with the signer and link-time guards built in. See [trackers](trackers.md#solana-program-activity) and the `program-activity` snippet.

## Soulbound badges on Solana

`@domino-sdk/relay/solana` (experimental; needs the optional peers `@solana/kit` and `@solana-program/token-2022`, which no other SDK entry loads; kit's types need TypeScript 5.7+ and the `DOM` lib) mints badges from the team's own server; Domino holds no key. `createSolanaBadgeMint({ authority, rpc, name, symbol, uri, mint? })` creates a 0-decimal Token-2022 mint with the NonTransferable, metadata-pointer and token-metadata extensions, `authority` as mint and metadata authority and payer; run it once per badge. In a `completion.created` webhook route, after `verifyWebhook`, call `awardSolanaBadge({ management, event, mint, authority, rpc, network, quests?, whenNoWallet: "skip", label? })`. It answers `ignored` for other events, leaderboard prizes and quest IDs outside `quests`; `already-minted` with the stored receipt when the completion has a `badge` receipt; `no-wallet`, sending nothing, when the member has no linked Solana wallet they proved (imported wallets don't count); otherwise it signs one transaction (paid by `authority`) that opens the member's associated token account if needed and mints 1 unit to their most recently linked proven wallet, with an SPL Memo `domino-badge:<completion>`; records it as receipt `badge-attempt-<n>` (label: its last valid block height) before sending, so only one call per completion can send; sends it, waits for `confirmed`, and answers `minted` with the `badge` receipt (`asset` the mint, `recipient` the wallet). A later call that finds an attempt records `badge` once it landed, sends attempt n+1 once it failed or expired, and otherwise throws `SolanaBadgePendingError` (`code: "badge-pending"`, nothing sent): let it fail the delivery, since Domino stops waiting after 10 s and redelivers. The key needs `points` (it also reads `members.identityStates`). A mint that isn't Token-2022 or whose mint authority isn't `authority` throws before sending. With `whenNoWallet: "defer"` it answers `deferred` instead of `no-wallet`; subscribe the route to `wallet.linked` too (experimental, data `{ member, chain, network, address }`, sent once when a member proves a wallet not already linked and proved; vouched and imported wallets, re-proofs and operator relinks send nothing) and pass that event to `awardOwedSolanaBadges({ management, event, mint, authority, rpc, network, quests?, label? })`. For a Solana wallet it pages `management.completions.list({ member, quest })` (read permission; the member's unrevoked completions) for each quest in `quests` (every quest's when omitted; leaderboard prizes skipped) and awards each through the same once-per-completion path, answering `{ status: "awarded", awards: [{ completion, quest, award }] }`; other events and chains answer `ignored`. A redelivery finds each `badge` receipt and mints nothing; it throws on the first failure (such as `SolanaBadgePendingError`), and the retry skips what is minted. Quests read the badge with `ctx.wallet.balance({ chain, token: mint })`; the `solana-badge` snippet has the route, the mint script, a badge quest a member completes by linking a Solana wallet, and a holder quest.

Compressed badges (cNFTs, Metaplex Bubblegum v2) suit large drops: rent is paid once for a tree, then each badge costs its fee plus Bubblegum's 90,000-lamport mint fee. `createSolanaBadgeTree({ authority, rpc, maxDepth, maxBufferSize, collection: { name, uri, transferable? }, confirmRent?, tree?, collectionKey? })` creates, in one transaction, a private Bubblegum v2 tree (2^maxDepth badges; a supported depth/buffer pair such as 14/64) and a Core collection with the `BubblegumV2` plugin and, unless `transferable`, a `PermanentFreezeDelegate` frozen with no authority, so its cNFTs can never be transferred or burned. `authority` becomes tree delegate and collection update authority and pays the rent; before sending, it calls `confirmRent({ lamports, sol, capacity, treeBytes })` (false sends nothing and throws) or, without it, prints the rent with `console.info`. Then pass `badge: { kind: "cnft", tree, collection, metadata: { name, symbol?, uri } }` instead of `mint` to `awardSolanaBadge` or `awardOwedSolanaBadges`: each completion mints one cNFT with `mint_v2` to the member's wallet, with the same attempt receipts, memo, results and `SolanaBadgePendingError`; the `badge` receipt's `asset` is the cNFT's asset ID, read from the landed transaction, so `rpc` also needs `getTransaction` (`SolanaCompressedBadgeRpc`); no DAS RPC is needed to mint. It throws before sending when `tree` is not a Bubblegum v2 tree that `authority` created or delegates (or a public one), when the tree is full, or when `collection` is not a Core collection whose update authority is `authority`. Quests gate on the badge with `ctx.wallet.nfts({ collection: "solana:<cluster>/nft:<collection>" })`, which counts Core-collection cNFTs through Helius once it has indexed the mint.
