Skip to content
Docs

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

Package manager
npm install @gray3/cloud

The 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

@gray3/cloud

new Gray(config)

new Gray(config: GrayConfig): Gray
ts
import { Gray } from "@gray3/cloud";

const gray = new Gray({
  projectId: process.env.GRAY_PROJECT_ID!, // "proj_…"
  secretKey: process.env.GRAY_SECRET_KEY!, // "gray_sk_…"
});
FieldRequiredDescription
projectIdYesYour project ID. Must start with proj_.
secretKeyYesA project secret key. Must start with gray_sk_.
chainsNoChain ID allowlist. When set, every chain-scoped call is limited to these chains. See Chains and allowlists.
customChainsNoCustom EVM networks to register at startup. See Custom EVM chains.
fetchNoA 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

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.