Skip to main content
The Rust SDK is the canonical client for the Grid. The gen CLI uses it under the hood, and so does every Rust integration. 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 reference, see the rustdoc on docs.rs (when published) or build it locally with cargo doc -p client-sdk --open.

Crates

Install

The crates are not yet published to crates.io. Pull them from the gen-bc repo by Git tag:
Or pin them in Cargo.toml directly:
Replace v0.1.0 with the tag matching your target network.

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.
new_http_with_rpc_config(...) accepts a ClientConfig if you need custom headers, timeouts, or a different RPC URL per request.

First call

Probe the validator to confirm connectivity:
That single call rules out the most common setup failures: wrong endpoint, network unreachable, protocol version mismatch.

Send a transfer

Sending a transfer is a four-step flow: load a signer, build the activation payload, sign and submit it, await the result. The SDK collapses the last two into one call.
A few notes:
  • The example uses build_transfer_payload from client_sdk::faucet. That helper is the canonical path for moving the GEN token between accounts. To call a custom token contract, generate a typed client with #[generate_contract_client] and call its transfer method instead.
  • sign_and_submit_and_wait_activation polls until the activation reaches a terminal state. If you need fire-and-forget semantics use sign_and_submit_activation and follow up later with client.wait(activation_id).
  • AmountInSubunits is the smallest unit of the token. The GEN token uses 18 decimals; convert as needed before passing.

Loading keys

GenSigner accepts raw bytes today. Most production agents will load from a wallet file written by the CLI or from a KMS. The CLI’s wallet store lives at ~/.gen/wallets/. To bridge from there programmatically, use gen wallet export (see gen wallet) and feed the result to GenSigner::from_private_key_bytes. Never hard-code a private key in source. The example above uses [0u8; 32] only as a placeholder.

GenClient API surface

Every public method on GenClient, in source order. For full signatures and documentation, see the rustdoc.

Errors

The SDK returns structured SdkError variants. The ones you are likely to handle in production: See the rustdoc for the full enum.

Next steps