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:Cargo.toml directly:
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: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.- The example uses
build_transfer_payloadfromclient_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 itstransfermethod instead. sign_and_submit_and_wait_activationpolls until the activation reaches a terminal state. If you need fire-and-forget semantics usesign_and_submit_activationand follow up later withclient.wait(activation_id).AmountInSubunitsis 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 onGenClient, in source order. For full signatures and documentation, see the rustdoc.
Errors
The SDK returns structuredSdkError variants. The ones you are likely to handle in production:
See the rustdoc for the full enum.
Next steps
- JSON-RPC reference: every wire-level method the SDK speaks.
- Send your first transfer (CLI): the same flow at the command line, useful for sanity-checking your setup.
