Skip to content
Docs

Cloud SDK

Ledger records and tokens

Use gray.ledger to read the token registry and create, list, and update transaction records.

Token registry

ts
// One page (default: verified tokens), then the next with nextCursor
const page = await gray.ledger.listTokens({ chainId: "ethereum", limit: 50 });
const next = await gray.ledger.listTokens({ chainId: "ethereum", cursor: page.nextCursor });

// Search by symbol/name prefix or exact address
const hits = await gray.ledger.listTokens({ chainId: "ethereum", q: "usd" });

// Every page, lazily
for await (const t of gray.ledger.iterateTokens({ chainId: "solana" })) console.log(t.symbol, t.logoUrl);

// Enrich portfolio holdings (up to 50 per call)
const p = await gray.portfolio.get({ chainId: "ethereum", address });
const ids = p.assets.filter((a) => a.address !== "native").map((a) => a.address);
const { items, missing } = await gray.ledger.listTokens({ chainId: "ethereum", addresses: ids });
// items → registry entries (logoUrl, verification, …)
// missing → custom / unregistered tokens (still work everywhere else)

const token = await gray.ledger.getToken(items[0]._id);

verification is verified, unverified, abandoned or flagged. Project keys can read the registry; Gray manages it. Each request costs 1 credit.

Transaction records

ts
// 1. Create a record before you broadcast
const record = await gray.ledger.createTransaction({
  kind: "transfer",
  chainId: "ethereum",
  from: "0xSender",
  to: "0xRecipient",
  value: "10000000000000000",
  status: "prepared",
});

// 2. Broadcast with the record ID so it is updated with the hash
await gray.transactions.broadcast({
  chainId: "ethereum",
  signedPayload,
  ledgerTxId: record._id,
});

// 3. Update the status when the transaction confirms
await gray.ledger.updateTransaction(record._id, { status: "confirmed" });

// List and read records
const recent = await gray.ledger.listTransactions({ chainId: "ethereum", limit: 50 });
const one = await gray.ledger.getTransaction(record._id);

Statuses are prepared, broadcast, confirmed, and failed. See the Ledger API guide for the full record shape.