Skip to main content

Configuration

@4mica/sdk needs a signing key and can use sensible defaults for everything else. Build a Config with ConfigBuilder, then pass it to Client.new.

Options

ethereumHttpRpcUrl and contractAddress are fetched from the core service by default. The SDK validates the connected chain id but does not verify the contract address or code. Only override these if you need values that differ from the server defaults.

Using ConfigBuilder

ConfigBuilder is a fluent builder. Chain the options you need, then call build().
build() throws a ConfigError when a signer or wallet key is missing, a URL is invalid, or the auth refresh margin is not a finite non-negative number.

Using environment variables

Call fromEnv() to load configuration from the environment.
Most shells do not allow variable names that start with a digit. To set them inline for a single command, use env: env 4MICA_WALLET_PRIVATE_KEY="0x..." 4MICA_NETWORK="base" node app.js.

Using a custom signer

To integrate a hardware wallet, remote signer, or MPC wallet, pass a viem Account. It must expose address, signTypedData, and signMessage.

Coinbase CDP wallet

Use createCdpAccount for a Coinbase CDP MPC wallet whose private key never leaves CDP. It returns a viem Account you can pass to .signer(). This requires the optional @coinbase/cdp-sdk dependency.

SIWE authentication

Auth is enabled by default. Enable automatic SIWE refresh, or pass a static bearer token.
Or use a static token instead of SIWE:
Never commit private keys. Use a test wallet while you develop and a dedicated service wallet, hardware-backed signer, MPC wallet, or hosted key management system in production.
Start on Base Sepolia (eip155:84532) with small amounts. Once a flow works end to end, move shared values into environment variables and switch networks.

Next steps

Overview

Install the SDK and see the capabilities at a glance.

Client operations

Deposit collateral, sign payments, issue guarantees, and settle cleared cycles.