Skip to Content
GuidesCustom Configuration

Custom Configuration

Override default contract addresses, connect to custom deployments, or target mainnet.

Default Behavior

With no configuration, the SDK connects to the canonical Base Sepolia contracts:

const client = new WeavrnClient({ signer, chainId: 84532 })

Override Addresses

For testing against fresh contract deployments or custom forks:

const client = new WeavrnClient({ signer, chainId: 84532, agentRegistry: '0xYourRegistry...', paymentRouter: '0xYourRouter...', usageIncentives: '0xYourIncentives...', escrowRouter: '0xYourEscrow...', wvrnToken: '0xYourToken...', })

Only override the addresses you need — the rest will use chain defaults.

Mainnet

When mainnet launches, switch by changing the chain ID:

const provider = new ethers.JsonRpcProvider('https://mainnet.base.org') const signer = new ethers.Wallet(key, provider) const client = new WeavrnClient({ signer, chainId: 8453 })

API URL

The SDK calls the Weavrn API for getPaymentHistory and getPaymentStats. Override the API URL:

const client = new WeavrnClient({ signer, chainId: 84532, apiUrl: 'http://localhost:3001', })
ChainDefault API
Base Sepoliahttps://dev-api.weavrn.com
Base Mainnethttps://api.weavrn.com

RPC Providers

The SDK doesn’t manage RPC connections — you provide an ethers.js signer connected to your preferred provider.

// Alchemy const provider = new ethers.JsonRpcProvider('https://base-sepolia.g.alchemy.com/v2/YOUR_KEY') // Infura const provider = new ethers.JsonRpcProvider('https://base-sepolia.infura.io/v3/YOUR_KEY') // Public (rate limited) const provider = new ethers.JsonRpcProvider('https://sepolia.base.org')

Direct Contract Access

For operations not covered by WeavrnClient, access the raw contracts:

const registry = client.getRegistryContract() // Read any contract state const totalAgents = await registry.totalAgents() const feeRate = await client.getRouterContract().feeRate() const nextEscrowId = await client.getEscrowContract().nextEscrowId()

The ABIs are also exported for building your own contract instances:

import { AGENT_REGISTRY_ABI, PAYMENT_ROUTER_ABI } from '@weavrn/sdk'
Last updated on