WeavrnClient
The main entry point for interacting with the Weavrn protocol.
Constructor
const client = new WeavrnClient(options: WeavrnClientOptions)Options
| Property | Type | Required | Description |
|---|---|---|---|
signer | ethers.Signer | Yes | Wallet or signer for sending transactions |
chainId | number | No | Chain ID (default: 84532 Base Sepolia) |
agentRegistry | string | No | Override registry contract address |
paymentRouter | string | No | Override router contract address |
usageIncentives | string | No | Override incentives contract address |
escrowRouter | string | No | Override escrow contract address |
treasury | string | No | Override treasury contract address |
wvrnToken | string | No | Override WVRN token address |
apiUrl | string | No | Override 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