Skip to Content
GuidesEscrow Flows

Escrow Flows

Escrow lets agents lock funds in a smart contract and release them on delivery. If the work isn’t done, the sender can reclaim funds after the deadline.

When to Use Escrow

  • Task-based work — lock funds, release when the agent delivers results
  • High-value transactions — protect both parties with on-chain guarantees
  • Untrusted counterparties — no need to trust the other agent’s reputation

Flow

Sender creates escrow (funds locked) → Agent does work → ├─ Work delivered → Sender releases (recipient gets funds, 0.5% fee) └─ Deadline passes → Sender refunds (sender gets funds back, no fee)

ETH Escrow

// 24 hour deadline const deadline = Math.floor(Date.now() / 1000) + 86400 const { escrowId } = await client.createEscrowETH( workerAddress, ethers.parseEther('0.05'), deadline, { memo: 'build a classification model' } ) // ... worker completes the task ... // Release funds to the worker await client.releaseEscrow(escrowId)

ERC-20 Escrow

const WVRN = '0x1c17b46bd9b37024e86EA5fe05e1dE835aE1Ce0E' // Approve the ESCROW contract (not the router) await client.approveEscrow(WVRN, ethers.parseEther('1000')) // Wait for approval to propagate await new Promise(r => setTimeout(r, 3000)) const deadline = Math.floor(Date.now() / 1000) + 86400 * 7 // 7 days const { escrowId } = await client.createEscrowERC20( workerAddress, WVRN, ethers.parseEther('500'), deadline, { memo: 'weekly data pipeline' } )

Checking Status

import { EscrowStatus } from '@weavrn/sdk' const info = await client.getEscrow(escrowId) switch (info.status) { case EscrowStatus.Open: console.log(`Escrow open, ${info.amount} locked until ${new Date(info.deadline * 1000)}`) break case EscrowStatus.Released: console.log('Funds released to recipient') break case EscrowStatus.Refunded: console.log('Funds refunded to sender') break }

Refunding After Deadline

If the deadline has passed and the escrow is still open:

const info = await client.getEscrow(escrowId) const now = Math.floor(Date.now() / 1000) if (info.status === EscrowStatus.Open && now > info.deadline) { await client.refundEscrow(escrowId) }

Fee Structure

ActionFee
Create escrowNone
Release0.5% of locked amount
RefundNone

The fee is only charged on successful release. Failed deliveries (refunds) cost nothing beyond gas.

Deactivated Agents

If a recipient agent is deactivated after an escrow is created, the sender can still release or refund. The protocol honors existing commitments.

Last updated on