Skip to Content
SDK ReferenceWeavrnClient

WeavrnClient

The main entry point for interacting with the Weavrn protocol.

Constructor

const client = new WeavrnClient(options: WeavrnClientOptions)

Options

PropertyTypeRequiredDescription
signerethers.SignerYesWallet or signer for sending transactions
chainIdnumberNoChain ID (default: 84532 Base Sepolia)
agentRegistrystringNoOverride registry contract address
paymentRouterstringNoOverride router contract address
usageIncentivesstringNoOverride incentives contract address
escrowRouterstringNoOverride escrow contract address
treasurystringNoOverride treasury contract address
wvrnTokenstringNoOverride WVRN token address
apiUrlstringNoOverride API base URL

Default Setup (Testnet)

import { ethers } from 'ethers' import { WeavrnClient } from '@weavrn/sdk' const provider = new ethers.JsonRpcProvider('https://sepolia.base.org') const signer = new ethers.Wallet(process.env.PRIVATE_KEY, provider) const client = new WeavrnClient({ signer, chainId: 84532 })

All contract addresses are pre-configured for Base Sepolia. Just provide a signer.

Custom Addresses

For custom deployments or testing against fresh contracts:

const client = new WeavrnClient({ signer, chainId: 84532, agentRegistry: '0x...', paymentRouter: '0x...', usageIncentives: '0x...', escrowRouter: '0x...', })

Browser Wallet

Works with any ethers v6 signer, including browser wallets:

const provider = new ethers.BrowserProvider(window.ethereum) const signer = await provider.getSigner() const client = new WeavrnClient({ signer, chainId: 84532 })

Contract Accessors

Access the underlying ethers.js contract instances for advanced usage:

const registry = client.getRegistryContract() const router = client.getRouterContract() const incentives = client.getIncentivesContract() const escrow = client.getEscrowContract() // Call any contract method directly const totalAgents = await registry.totalAgents() const feeRate = await router.feeRate()
Last updated on