jamiepine/voicebox · warning · Error

RPC ${method}: ${json.error.message}

Error message

RPC ${method}: ${json.error.message}

What it means

Thrown by `rpcCall()` in `landing/src/lib/token-stats.ts` (line 271) when the JSON-RPC HTTP layer succeeded (2xx) but the response body carries an `error` object — the standard JSON-RPC 2.0 failure shape. The message embeds the RPC's own error text. Like error 18, the surrounding module isolates this and degrades the affected metric to `null` rather than crashing the page.

Source

Thrown at landing/src/lib/token-stats.ts:271

    creatorRewardsUsd,
    circulating,
    updatedAt: Date.now(),
    warnings,
  };
}

// ── Solana / Helius RPC primitives ───────────────────────────────────────────

async function rpcCall<T>(rpc: string, method: string, params: unknown): Promise<T> {
  const res = await fetch(rpc, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    next: { revalidate: REVALIDATE_S },
    body: JSON.stringify({ jsonrpc: '2.0', id: 'voicebox', method, params }),
  });
  if (!res.ok) throw new Error(`RPC ${method} HTTP ${res.status}`);
  const json = (await res.json()) as { result?: T; error?: { message: string } };
  if (json.error) throw new Error(`RPC ${method}: ${json.error.message}`);
  if (json.result === undefined) throw new Error(`RPC ${method}: empty result`);
  return json.result;
}

interface SupplyResult {
  value: { amount: string; decimals: number; uiAmount: number | null };
}
async function getTokenSupply(
  rpc: string,
): Promise<{ uiAmount: number; decimals: number }> {
  const r = await rpcCall<SupplyResult>(rpc, 'getTokenSupply', [MINT]);
  const decimals = r.value.decimals;
  const uiAmount =
    r.value.uiAmount ?? Number(r.value.amount) / 10 ** decimals;
  return { uiAmount, decimals };
}

// Sum a single owner's balance of the mint across all their token accounts.

View on GitHub (pinned to 51f49dea19)

Solutions

  1. Read the embedded message — it usually states 'Invalid param: mint' or names the bad argument; correct the constant/param it points at.
  2. Confirm `MINT` (`TOKEN_CONTRACT_ADDRESS`) matches the network the RPC serves (mainnet mint on mainnet RPC).
  3. On a provider rate-limit error, switch to a keyed/higher-tier RPC and rely on the ISR cache.
  4. Validate the mint is base58 and 32-44 chars before sending it in params.

Example fix

// before
const json = await res.json() as { result?: T; error?: { message: string } };
if (json.error) throw new Error(`RPC ${method}: ${json.error.message}`);

// after — validate mint before the call to avoid -32602
function assertMint(m: string) {
  if (!/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(m)) throw new Error(`Invalid mint: ${m}`);
}
assertMint(MINT);
const json = await res.json() as { result?: T; error?: { message: string } };
if (json.error) throw new Error(`RPC ${method}: ${json.error.message}`);
Defensive patterns

Strategy: validation

Validate before calling

// Validate the mint before sending it in RPC params
function assertMint(m: string) {
  if (!/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(m)) {
    throw new Error(`Invalid mint address: ${m}`);
  }
}
assertMint(MINT);

Type guard

function isBase58Mint(m: string): boolean {
  return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(m);
}

Try / catch

try {
  return await rpcCall(rpc, method, params);
} catch (e) {
  const msg = (e as Error).message;
  if (/Invalid param|mint/i.test(msg)) warnings.push(`Bad mint for ${method}`);
  else warnings.push(`${method}: ${msg}`);
  return null;
}

Prevention

When it happens

Trigger: Invalid/unmatched mint address passed to `getTokenSupply`/`getAccountInfo` (RPC returns error -32602 invalid param or 'Invalid param: mint'); the method is unsupported by the provider; requesting a slot/block that does not exist; provider-specific rate limit returned as a JSON-RPC error (e.g. Helius -32600 with a rate-limit message); the configured `MINT` constant (`TOKEN_CONTRACT_ADDRESS`) is wrong or the token is on a different network than the RPC.

Common situations: `TOKEN_CONTRACT_ADDRESS` constant points at a devnet token while the RPC is mainnet (or vice versa); mint has a checksum/typo; provider deprecated a method; holder-enumeration RPC params malformed.

Related errors


AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12). Data as JSON: /api/errors/c076fc3c3715b64f. Report an issue: GitHub.