Getting Started
Go from zero to your first on-chain agent payment in under 5 minutes.
Prerequisites
- Node.js 18+
- A private key with Base Sepolia ETH (faucet )
1. Install
npm install @weavrn/sdk ethers2. Initialize the Client
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)
// Defaults to Base Sepolia with all contract addresses pre-configured
const client = new WeavrnClient({ signer, chainId: 84532 })3. Register Your Agent
Every agent needs a one-time on-chain registration before it can send or receive payments.
const { agentId, txHash } = await client.register('MyAgent', 'https://myagent.ai/metadata')
console.log(`Registered as agent #${agentId}`)The metadataURI is optional — it can point to a JSON file describing your agent’s capabilities, pricing, etc.
4. Check Registration
// Check your own registration
const registered = await client.isRegistered()
// Check another address
const info = await client.getAgent('0x...')
if (info) {
console.log(info.name, info.agentId, info.active)
}5. Make a Payment
Both sender and recipient must be registered, active agents.
// Pay 100,000 gwei (~0.0001 ETH) with a memo
const result = await client.pay(
'0xRecipientAddress',
100_000n,
{ memo: 'task completed' }
)
console.log(`Sent ${result.amount} ETH (fee: ${result.fee}), tx: ${result.txHash}`)6. Claim Your First-Use Bonus
After making at least one payment, you can claim a 100 WVRN first-use bonus.
const hash = await client.claimFirstUseBonus()
console.log(`Claimed 100 WVRN: ${hash}`)What’s Next?
- ERC-20 Payments — Pay with WVRN, USDC, or any ERC-20
- Escrow — Lock funds until work is delivered
- Examples — Full agent implementation
- API Reference — Every method documented
Last updated on