Skip to content
Docs

Cloud SDK

Chains and allowlists

List the chains your project can use and restrict a client to a fixed set of chain IDs.

List chains

@gray3/cloud

gray.chains.list

list(options?: { include?: "capabilities" }): Promise<ChainSummary[]>
ts
const chains = await gray.chains.list();
// [{ id: "ethereum", name: "Ethereum", family: "evm", native: {…}, explorer: {…} }, …]

const withCaps = await gray.chains.list({ include: "capabilities" });
// each chain also has capabilities: { portfolio: { status, code }, nfts: {…}, … }

const base = await gray.chains.get("base"); // ChainSummary | undefined

The list is filtered by your plan and by the client allowlist. It calls GET /v1/chains; cache it on your server because it changes rarely. With capabilities, each chain also has a webhook entry that says whether Webhooks work there and are on for your project.

List every chain

@gray3/cloud

gray.chains.listAll

listAll(): Promise<ChainCatalogEntry[]>
ts
const all = await gray.chains.listAll();
// [{ id: "ethereum", …, capabilities: {…, webhook: {…}}, access: { inPlan, enabled, usable } }, …]

const locked = all.filter((c) => !c.access.inPlan);        // upgrade to unlock
const switchedOff = all.filter((c) => c.access.inPlan && !c.access.enabled);
const webhookReady = all.filter((c) => c.capabilities.webhook?.enabled);

Returns every Gray3 chain, including ones outside your plan or switched off in Console, with capabilities and access flags. It calls GET /v1/chains/all. Unlike list, it ignores the client allowlist and does not include custom chains.

Restrict a client to certain chains

Pass chains when you create the client to limit it to the chains your product supports. Calls for any other chain throw invalid_argument before a request is sent, and multi-chain calls default to the allowlist when you omit chainIds.

ts
const gray = new Gray({
  projectId: process.env.GRAY_PROJECT_ID!,
  secretKey: process.env.GRAY_SECRET_KEY!,
  chains: ["ethereum", "base", "solana"],
});

gray.chains.add("polygon");
gray.chains.add(["arbitrum", "optimism"]);
gray.chains.remove("solana");

console.log(gray.chainIds); // current allowlist; empty when unrestricted

The allowlist only narrows what this client calls. It does not change which networks are enabled for the project in Console.