Skip to main content
The Monaco SDK requires a Viem wallet client and network configuration. This page covers installation, SDK initialization, configuration options, and best practices.

Installation

Basic Initialization

Monaco needs a Viem walletClient configured for Sei testnet during private alpha. You can create that client from an injected browser wallet, WalletConnect, a local private key, or any other Viem-supported wallet setup. Monaco will support mainnet wallet clients when mainnet access opens. See the Viem Wallet Client docs for the full set of options.

Configuration Options

WalletClient
required
Viem wallet client for signing transactions and messages. Must be configured with a valid account and chain.
string
required
Required (v0.4.0+): Sei blockchain RPC endpoint URL. Each application should configure their own RPC provider to avoid rate limits. For testnet/staging, use https://evm-rpc-testnet.sei-apis.com. For production, use a dedicated RPC provider like Ankr, GetBlock, or AllThatNode.
Network
required
For public usage, set this to "staging" or "mainnet". Selects the chain ("staging" uses Sei testnet; "mainnet" uses Sei mainnet) and the default API and WebSocket URLs. The SDK type also supports internal presets, but public docs intentionally cover only public endpoints.
number
Optional. Poll interval, in milliseconds, for the SDK’s internal viem public client when it waits on transaction receipts. Defaults to 750ms (viem’s own default is 4000ms), so sdk.vault.deposit and sdk.waitForTransaction resolve within about one to two Sei blocks. Must be a positive finite number, otherwise the SDK throws InvalidConfigError on construction. Set it to 4000 to restore the previous cadence.
RequestSigning
Optional. Which protocol signs authenticated REST requests: "legacy" (the default) sends the X-Monaco-* headers, "rfc9421" sends RFC 9421 HTTP message signatures. Both use the same session key, and WebSocket and gRPC authentication are unaffected either way. There is no automatic downgrade, so select "rfc9421" only against a gateway that verifies it. In RFC mode the SDK requires a string request body, disables redirect following on authenticated requests, and throws if the caller supplies a signature header itself. See HTTP message signatures.

Network Configurations

The SDK automatically configures API and WebSocket endpoints based on the network parameter:
  • Chain: Sei Atlantic-2 testnet
  • Chain ID: 1328
  • API: Staging API Gateway
  • WebSocket: Auto-resolved from network

RPC Provider Options

seiRpcUrl points the SDK at Sei for on-chain reads and transaction confirmation. During private alpha, use the Sei testnet RPC. In production code, source seiRpcUrl from an environment variable rather than hardcoding it.

SDK Instance Properties

Once initialized, the SDK exposes these APIs:

SDK Utility Methods

() => boolean
Check if the SDK has a valid wallet connection
() => boolean
Check if the user has a valid authentication session
() => string
Get the current wallet address. Throws InvalidStateError if no account is connected.Error Handling:
Best Practice: Use isConnected() before calling:
() => Network
Get the current network name, for example 'staging'
(serverKey: string | undefined) => void
Set the application secret key (sk_...) used for backend-authenticated requests. The key is fanned out to every sub-API in one call and sent in the x-server-key header on those requests. There is no token exchange. Pass undefined to clear it.Server-key auth is independent of sdk.login() / session auth; a client may hold both a session and a server key at the same time.
() => number
Get the current blockchain chain ID (1328 for testnet)
(hash: string, confirmations?: number, timeout?: number) => Promise<TransactionReceipt>
Wait for a transaction to be confirmed on-chainParameters:
  • hash: Transaction hash to wait for
  • confirmations?: Number of confirmations required (optional)
  • timeout?: Timeout in milliseconds (optional)
Returns: Viem TransactionReceipt