Cloud SDK
Install and initialize
Install @gray3/cloud and create a server-side Gray client with your project ID and secret key.
Overview
@gray3/cloud is the TypeScript client for the Gray3 Cloud API and the Gray3 Ledger API. It adds your credentials to every request, unwraps the data envelope, and turns API errors into GrayError exceptions. It does not hold keys or sign transactions; signing happens on the device with @gray3/client.
Install
npm install @gray3/cloudThe package is ESM-only and uses only the global fetch. It runs on Node.js 20 and later, Deno, Bun, and edge runtimes such as Cloudflare Workers and Vercel Edge Functions.
Create a client
new Gray(config)
new Gray(config: GrayConfig): Grayimport { Gray } from "@gray3/cloud";
const gray = new Gray({
projectId: process.env.GRAY_PROJECT_ID!, // "proj_…"
secretKey: process.env.GRAY_SECRET_KEY!, // "gray_sk_…"
});| Field | Required | Description |
|---|---|---|
| projectId | Yes | Your project ID. Must start with proj_. |
| secretKey | Yes | A project secret key. Must start with gray_sk_. |
| chains | No | Chain ID allowlist. When set, every chain-scoped call is limited to these chains. See Chains and allowlists. |
| customChains | No | Custom EVM networks to register at startup. See Custom EVM chains. |
| fetch | No | A custom fetch implementation, for example in tests. |
The constructor validates the credential formats and throws a GrayError with invalid_argument if either is malformed. The client sends Cloud API requests to https://blockchain.gray3.io and Ledger API requests to https://ledger.gray3.io automatically.
What the client offers
gray.chains: Chains and allowlistsgray.portfolio: Portfolio and balancesgray.prices,gray.activity,gray.nfts: Prices, activity, and NFTsgray.defi,gray.swap: DeFi and swapsgray.gas,gray.transactions: Gas and transactionsgray.ledger: Ledger records and tokensgray.monero: Monero daemon connection
The package also re-exports GrayError, isGrayError, listChains, getChain, and the chain ID types from @gray3/core, so a backend usually needs only one import.