Shader
Read receipts

DocsGuides18 of 35 · 3 min read

Read receipts

List what a wallet was charged in the app, the SDK or the CLI, open one settlement, and decode a receipt from the chain yourself.

Every charge and deposit has a receipt. You need a signed-in wallet or an agent token to list a wallet's receipts; reading one from the chain needs only its transaction signature and an RPC endpoint.

#List and open them

App

  1. Open Receipts

    Open Receipts. The table shows Time (UTC), Kind, Job, Units, Credits, Agent key and the Transaction, newest first, and new receipts appear as they land.

  2. Filter

    Filter by Kind or Agent key; Clear filters shows all again.

  3. Open one

    Open a row. The settlement page shows every line with its units and credits split into USDC-backed and SHDR-backed parts, the wallet, the agent key, the slot and block time, a link to the explorer, and the raw decoded event.

SDK

receipts.ts
const { items } = await shader.receipts({ kind: 'rental_settle', limit: 5 })

Each item has the signature, line index, kind, units, credits and agent key. GET /receipts/{signature} in the API returns one settlement with every line.

CLI

Terminal
shader receipts --kind rental_settle --limit 5

MCP

Call list_receipts with an optional kind and limit.

#Read one from the chain

The program emits events through a self-invoked instruction (emit_cpi!), so a receipt sits in the transaction's inner instructions rather than in its logs. Each one is the 8-byte event tag e445a52e51cb9a1d, the 8-byte Receipt discriminator (the first 8 bytes of sha256("event:Receipt")), and the event's fields in Borsh.

  1. Install

    The script needs only @solana/web3.js and bs58.

    Terminal
    npm install @solana/web3.js bs58
  2. Save the script

    read-receipt.ts
    import { createHash } from 'node:crypto'
    import { Connection, PublicKey } from '@solana/web3.js'
    import bs58 from 'bs58'
    
    const SHADER = new PublicKey(process.env.SHADER_PROGRAM_ID!)
    const EVENT_CPI = Buffer.from('e445a52e51cb9a1d', 'hex')
    const RECEIPT = createHash('sha256').update('event:Receipt').digest().subarray(0, 8)
    
    function decodeReceipt(data: Buffer) {
      let o = 0
      const key = () => new PublicKey(data.subarray(o, (o += 32))).toBase58()
      const u64 = () => data.readBigUInt64LE((o += 8) - 8)
      return {
        wallet: key(),
        agentKey: key(),
        jobId: data.subarray(o, (o += 16)).toString('hex'),
        kind: data.readUInt8(o++) === 0 ? 'rental' : 'generation',
        units: u64(),
        requested: u64(),
        charged: u64(),
        usdcPart: u64(),
        shdrPart: u64(),
        shdrAtoms: u64(),
        lineIndex: data.readUInt16LE((o += 2) - 2),
        settleNonce: u64(),
        timestamp: new Date(Number(data.readBigInt64LE((o += 8) - 8)) * 1000).toISOString(),
      }
    }
    
    export async function readReceipts(connection: Connection, signature: string) {
      const tx = await connection.getTransaction(signature, { commitment: 'confirmed', maxSupportedTransactionVersion: 0 })
      if (!tx?.meta) throw new Error('Transaction not found')
      const keys = tx.transaction.message.getAccountKeys({ accountKeysFromLookups: tx.meta.loadedAddresses })
      return (tx.meta.innerInstructions ?? [])
        .flatMap((inner) => inner.instructions)
        .filter((ix) => keys.get(ix.programIdIndex)?.equals(SHADER))
        .map((ix) => Buffer.from(bs58.decode(ix.data)))
        .filter((d) => d.subarray(0, 8).equals(EVENT_CPI) && d.subarray(8, 16).equals(RECEIPT))
        .map((d) => decodeReceipt(d.subarray(16)))
    }
    
    const connection = new Connection(process.env.RPC_URL!, 'confirmed')
    console.log(await readReceipts(connection, process.argv[2]!))
  3. Run it

    Pass your RPC endpoint, the program id from Program instructions, and a settlement's signature.

    Terminal
    SHADER_PROGRAM_ID=<program id> RPC_URL=<rpc url> node read-receipt.ts <signature>
  4. Read the output

    The last line of a local test rental prints:

    Output
    [
      {
        wallet: '3hgCz9NXPdANaJfHrVgARTZsUr89hWqJdxfrW8kBFPbD',
        agentKey: '11111111111111111111111111111111',
        jobId: '4846273fedd74761b4772a6913a49ea0',
        kind: 'rental',
        units: 2n,
        requested: 400n,
        charged: 400n,
        usdcPart: 400n,
        shdrPart: 0n,
        shdrAtoms: 0n,
        lineIndex: 0,
        settleNonce: 3n,
        timestamp: '2026-11-28T05:48:50.000Z'
      }
    ]

    This line charged 400 base units, 0.4 credit, for the last 2 seconds of a rental, settled at stop, all of it from USDC-backed credits. agentKey is the default key, all ones, because the wallet spent it itself.

#What happened

  1. Fetch

    The script read the transaction from your RPC, with its inner instructions.

  2. Find

    It kept the inner instructions of the shader program that start with the event tag and the Receipt discriminator.

  3. Decode

    It read each one's fields in order, with the same layout as Receipt.

#Afterwards

To account for one agent, filter by its key: everything it was charged is there. Events has every field of every event the program emits.

#If it fails

What you seeWhyNext
Transaction not foundThe signature is not on that cluster, or the RPC has pruned itUse an RPC with history for that cluster
An empty listThe transaction is a deposit or not a settlementDeposits emit UsdcDeposited or ShdrDeposited; see Events