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 inclient-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 offersimportentrypoints — there is no CommonJS build. From CJS code, use dynamicimport(). - 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.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: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 onGenClient.
- Amounts are
bigintsubunits, the token’s smallest unit. The genesis token uses 18 decimals, so the literal above is one token. createAccount(...)andfaucet(...)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 aTraceOutcome.- Calling your own contract is the same shape without the convenience wrapper: build an
ActivationPayloadtargeting your component and pass it toclient.signAndSubmitActivationAndWait(signer, payload)with your own signer — seeGenClientin 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 extendingSdkError. The ones you are likely to handle in production:
See the generated API reference for the full hierarchy.
Next steps
- JSON-RPC reference: every wire-level method the SDK speaks.
- Rust SDK: the canonical client; the TypeScript SDK mirrors its structure.
- Send your first transfer (CLI): the same flow at the command line, useful for sanity-checking your setup.
