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
| Option | Required | Description |
|---|---|---|
walletPrivateKey | Yes, unless signer is provided | Private key used for signing. |
signer | Yes, unless walletPrivateKey | A pre-built viem Account. Mutually exclusive with walletPrivateKey. |
network | No | Network shorthand or CAIP-2 id. Defaults to ethereum-sepolia. |
rpcUrl | No | Override the core API URL directly (for self-hosted deployments). |
ethereumHttpRpcUrl | No | Ethereum JSON-RPC endpoint. Fetched from core when omitted. |
contractAddress | No | Core4Mica contract address. Fetched from core when omitted. |
adminApiKey | No | API key for admin RPCs. |
bearerToken | No | Static bearer token for auth. Disables SIWE auth. |
authUrl | No | SIWE auth endpoint. Defaults to rpcUrl when auth is enabled. |
authRefreshMarginSecs | No | Seconds before expiry at which the session refreshes. Defaults to 60. |
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
CallfromEnv() 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 viemAccount. It must expose address, signTypedData, and signMessage.
Coinbase CDP wallet
UsecreateCdpAccount 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.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.