Client
The ThetanutsClient is the single entry point to the Thetanuts SDK — it initializes all modules, manages provider/signer connections, and exposes chain configuration.
Constructor
import { ThetanutsClient } from '@thetanuts-finance/thetanuts-client';
const client = new ThetanutsClient({
chainId: 8453, // Required: Chain ID (Base = 8453)
provider: Provider, // Required: ethers.js provider
signer?: Signer, // Optional: For write operations
referrer?: string, // Optional: Referrer address for fees
apiBaseUrl?: string, // Optional: Override API URL
indexerApiUrl?: string, // Optional: Override indexer URL
pricingApiUrl?: string, // Optional: Override pricing URL
wsUrl?: string, // Optional: Override WebSocket URL
stateApiUrl?: string, // Optional: Override RFQ state indexer URL
env?: 'dev' | 'prod', // Optional: Environment (default: prod)
logger?: ThetanutsLogger, // Optional: Custom logger
keyStorageProvider?: KeyStorageProvider, // Optional: Custom RFQ key storage
rfqKeyPrefix?: string, // Optional: Custom RFQ key prefix
});Properties
chainId
number
Active chain ID (e.g. 8453)
chainConfig
ChainConfig
Chain configuration with addresses and tokens
provider
Provider
ethers.js provider instance
signer
Signer | undefined
Signer for transactions
referrer
string | undefined
Default referrer address
apiBaseUrl
string
Orders API endpoint URL
indexerApiUrl
string
Indexer API endpoint URL
pricingApiUrl
string
Pricing API endpoint URL
stateApiUrl
string
RFQ state indexer URL
Modules Access
All SDK modules are accessed as properties on the client instance:
Chain Config Access
Helper Methods
getSignerAddress()
Get the address of the current signer. Throws SIGNER_REQUIRED if no signer is configured.
requireSigner()
Get the signer instance, throwing SIGNER_REQUIRED if unavailable.
Initialization Patterns
Read-only (no signer)
With signer (for transactions)
Browser with MetaMask
Custom logger
URL overrides
Error Handling
The client throws ThetanutsError for typed error conditions:
Architecture
See Also
Modules Overview — All 15 modules at a glance
Chain Config — Full chain configuration reference
../getting-started/configuration.md — Getting started with configuration
Last updated

