Skip to main content
The TypeScript SDK is the typed client for the Grid in Node and the browser: RPC access, activation signing and submission, views, simulation, and trace polling. This page covers what to install, how to configure a client, and a worked example for the most common job: sending a transfer. For the full API surface, see the generated API reference.
Pre-release. The SDK surface may still change.

Package layout

The SDK ships as a single package, @gen/client-sdk, with a browser-safe root entrypoint and purpose-specific subpaths:

Install

The package is not yet published to npm. Get it from the gen-framework-preview repository: build the SDK in client-and-test-utils/client-sdk-ts with yarn build, then add packages/client-sdk to your app as a file: or workspace dependency.

Environment

  • ESM-only. The package declares "type": "module" and its exports map only offers import entrypoints — there is no CommonJS build. From CJS code, use dynamic import().
  • Node ≥ 20. The HTTP transport uses the global fetch.
  • Evergreen browsers. The SDK runs in the browser as well as Node; the root entrypoint is browser-safe.
  • BigInt throughout. Amounts and block numbers are bigint, so compilation targets must be ES2020 or later.

Configure a client

GenClient owns RPC access, view execution, activation submission, and waiting. Most apps construct one and reuse it.
DevNet access. DevNet requires a bearer token. Ask your Gen Labs contact for one and substitute it for <your-jwt> in the examples below.
Against a local validator, drop the headers: GenClient.newHttp("http://127.0.0.1:30001"). The options object also accepts pollIntervalMs and maxAttempts for polling, requestTimeoutMs and a custom fetch for transport, and activation header overrides (chainId, version, payloadEncodingVersion).

First call

Probe the validator to confirm connectivity:
That single call rules out the most common setup failures: wrong endpoint, network unreachable, missing bearer token.

Send a transfer

The quickest way to move the genesis token is the faucet flow: create an account, fund it, check the balance. Both steps are one-call conveniences on GenClient.
A few notes:
  • Amounts are bigint subunits, the token’s smallest unit. The genesis token uses 18 decimals, so the literal above is one token.
  • createAccount(...) and faucet(...) return as soon as the activation is accepted. wait(...) polls the activation and all its continuations to a terminal state and resolves the result into a TraceOutcome.
  • Calling your own contract is the same shape without the convenience wrapper: build an ActivationPayload targeting your component and pass it to client.signAndSubmitActivationAndWait(signer, payload) with your own signer — see GenClient in the API reference.

Loading keys

GenSigner accepts the canonical 32-byte Ed25519 secret seed via fromPrivateKeyBytes(...) / fromPrivateKeyHex(...) — not the expanded 64-byte private key, a clamped scalar, or a PKCS#8 wrapper. Raw key imports self-validate by signing and verifying a fixed message unless you opt out with {skipValidation: true}. Mnemonics are supported through GenSigner.fromMnemonic(...) and GenSigner.fromMnemonicWithPath(...); the default derivation path is m/44'/218'/0'/0/0. To bridge from a CLI wallet, use gen wallet export (see gen wallet) and feed the result to fromPrivateKeyBytes. For browser custody integrations, every submission method accepts any EddsaSigner implementation — an object exposing publicKey() and signBytes(...) — so browser wallets and external custody providers can sign without handing raw key material to the SDK. Never hard-code a private key in source. The example above generates a throwaway key only for the walkthrough.

Errors

The SDK throws structured error classes, all extending SdkError. The ones you are likely to handle in production: See the generated API reference for the full hierarchy.

Next steps