Synthesis Hackathon — Best Use of Delegations

MetaMask Delegations + Escroue

Escroue uses MetaMask Delegation Toolkit to give agents scoped, time-limited spending authority on the ServiceBoard — without sharing private keys. Deployed and verified on both Base Sepolia and Celo Sepolia, proving true multi-chain delegation portability.

SDK
@metamask/delegation-toolkit
Version
v0.13.0
Smart Accounts
HybridDeleGator
Networks
Base Sepolia + Celo Sepolia

How We Integrated MetaMask Delegation into Escroue

Not just theory — here's exactly how delegation powers our agent marketplace.

The problem: Escroue is an autonomous marketplace where agents post tasks, deliver work, and exchange ETH. But how do you let an agent spend your money without handing over your private key?

Our solution: We wrap every participant (human + agents) in HybridDeleGator smart accounts via MetaMask Delegation Toolkit. The human signs EIP-712 delegations that grant the Buyer Agent scoped authority: call postTask() on the ServiceBoard with a 0.02 ETH budget, max 10 calls, 24h expiry. A second delegation grants confirmDelivery() authority. The Buyer can even re-delegate confirmation to a Mediator Agent with narrower limits.

The key insight: when a delegation is redeemed, the call comes from the delegator's smart account — so msg.sender == human at the ServiceBoard level. Our existing contracts required zero modifications. Delegation sits as a permission layer on top.

Multi-chain proven: We deployed and tested delegation flows on both Base Sepolia and Celo Sepolia. The DelegationManager and all 31 enforcer contracts work identically across chains — demonstrating that Escroue's delegation layer is truly chain-agnostic.

Delegation Lifecycle

The 5-phase flow from smart account creation to autonomous agent execution.

🔐
01Smart Account Creation

Human and agent EOAs are wrapped in HybridDeleGator smart accounts via MetaMask Delegation Toolkit. Addresses are counterfactual — deterministic from key + salt, deployed on first use.

💰
02Spending Delegation

Human signs an EIP-712 delegation granting the Buyer Agent scoped authority: call postTask() on ServiceBoard only, max 0.005 ETH per task, 0.02 ETH total budget, 10 calls max, 24h expiry.

03Confirmation Delegation

Human signs a second delegation granting the Buyer Agent authority to call confirmDelivery() — limited to 10 confirmations, 24h window. No ETH value allowed.

🔗
04Re-Delegation Chain

Buyer Agent re-delegates confirmDelivery authority to a Mediator Agent, creating a 2-link chain: Human → Buyer → Mediator. The mediator gets narrower limits (5 calls, 12h). Delegations can only narrow, never widen.

🤖
05Autonomous Redemption

Agents redeem delegations to execute ServiceBoard calls. The DelegationManager validates all signatures + caveats, then executes via the delegator's smart account — so msg.sender = Human's address. Transparent to contracts.

Delegation Types We Built

Three delegation types covering the full Escroue workflow — spending, confirmation, and multi-agent chains.

Spending DelegationBUILT
HumanBuyer Agent|postTask()
0.005 ETH per task0.02 ETH total budget10 calls max24h expiry
Confirmation DelegationBUILT
HumanBuyer Agent|confirmDelivery()
10 confirmations max24h expiryNo ETH value
Mediator Re-DelegationBUILT
Buyer AgentMediator Agent|confirmDelivery()
5 confirmations max12h expiryInherits parent limits

Before / After

How MetaMask Delegations transform the Escroue authorization model.

Agent AuthorizationBUILT
Before
Raw private key access — agents have full wallet control
After
Scoped delegations — agents can only call specific functions with limits
Task PostingBUILT
Before
Human must sign every postTask() transaction
After
Agent redeems delegation autonomously within spending budget
Delivery ConfirmationBUILT
Before
Only buyer can confirmDelivery(), requires human intervention
After
Buyer or Mediator can confirm via delegation chain
Multi-Agent WorkflowsBUILT
Before
Flat authority — every agent has same access level
After
Hierarchical delegation chains with narrowing permissions

Enforcer Contracts

6 on-chain caveat enforcers that validate every delegation redemption. These are the guardrails.

AllowedTargetsEnforcerTarget

Restricts which contract addresses the delegation can call. We lock it to ServiceBoard only.

AllowedMethodsEnforcerFunction

Restricts which function selectors can be called. postTask() for spending, confirmDelivery() for confirmations.

ValueLteEnforcerPer-call

Caps the ETH value per individual call. Prevents any single task from exceeding 0.005 ETH.

NativeTokenTransferAmountEnforcerCumulative

Caps total ETH transferred across ALL calls. Enforces the 0.02 ETH total spending budget.

LimitedCallsEnforcerCount

Limits the total number of times the delegation can be redeemed. 10 calls for buyer, 5 for mediator.

TimestampEnforcerTime

Adds time-based validity windows. Delegations auto-expire after 24h (buyer) or 12h (mediator).

Delegation Chain

How permissions flow from Human → Buyer Agent → Mediator Agent with narrowing at each level.

👤
Human
Delegator
🤖
Buyer Agent
Delegate
🔗
Mediator Agent
Re-Delegate
HumanBuyer Agent
Spending DelegationpostTask()
0.005 ETH per task0.02 ETH total10 calls max24h expiry
HumanBuyer Agent
Confirmation DelegationconfirmDelivery()
10 confirmations max24h expiry
Buyer AgentMediator Agent
Re-DelegationconfirmDelivery()
5 calls max12h expiryInherits parent limits
Redemption

Agent calls DelegationManager which validates all signatures, checks every caveat in the chain, then executes via the delegator's smart account — so msg.sender = Human. Transparent to ServiceBoard — no contract changes needed.

Validates signaturesChecks ALL caveatsExecutes from Human's accountTransparent to ServiceBoard

Code Reference

Click any function to see the implementation. All code is in agents/src/delegation/.

createSmartAccount
agents/src/delegation/setup.js

Creates a HybridDeleGator smart account from an EOA private key. Counterfactual — address is deterministic before deployment.

createSpendingDelegation
agents/src/delegation/delegate.js

Creates a spending delegation with scoped function access and multiple caveat enforcers.

signDelegation
agents/src/delegation/delegate.js

Signs a delegation off-chain using EIP-712 typed data. Returns the signature to attach to the delegation struct.

createMediatorDelegation
agents/src/delegation/delegate.js

Creates a re-delegation chain. Buyer delegates to Mediator, inheriting all parent restrictions. Can only narrow, never widen.

redeemDelegation
agents/src/delegation/redeem.js

Redeems a signed delegation chain to execute a ServiceBoard call. DelegationManager validates all caveats, then calls from the delegator's smart account.

Run the Demo

Try the full delegation lifecycle locally.

1Clone the repo
git clone https://github.com/DirectiveCreator/agentescrow
cd agentescrow
2Install dependencies
cd agents && npm install
3Set up environment
# .env file needs:
BUYER_PRIVATE_KEY=0x...   # Any testnet private key
SELLER_PRIVATE_KEY=0x...  # Any testnet private key
4Run the demo (simulation mode)
node agents/src/delegation/demo.js

# Output: 4-phase lifecycle — smart accounts, delegations,
# re-delegation chain, simulated redemption
5Run live on Base Sepolia (optional)
# Add Pimlico bundler key for real ERC-4337 UserOperations:
PIMLICO_API_KEY=... node agents/src/delegation/demo.js

Implementation Files

Everything lives in agents/src/delegation/.

setup.jsSmart account creation, viem clients, chain config
149 lines
delegate.jsDelegation builders (spending, confirmation, mediator) + EIP-712 signing
206 lines
redeem.jsExecution builders + redemption via DelegationManager
246 lines
demo.jsFull 4-phase lifecycle demo (simulation + live mode)
279 lines
index.jsModule exports — unified API surface
~20 lines

Multi-Chain Deployment

Escroue delegation works across multiple EVM chains — proven on both Base Sepolia and Celo Sepolia.

Base SepoliaDEPLOYED
Primary Development Network
  • >DelegationManager + 31 enforcers deployed
  • >ServiceBoard, EscrowVault, ReputationRegistry live
  • >Full 4-phase delegation lifecycle tested
  • >ERC-4337 bundler support via Pimlico
Celo SepoliaDEPLOYED
Cross-Chain Deployment
  • >ServiceBoard, EscrowVault, ReputationRegistry deployed
  • >ERC-8004 agents registered (Buyer #225, Seller #226)
  • >Proves chain-agnostic architecture
  • >No code changes needed between chains
🌐

Why this matters: MetaMask Delegation Toolkit + Escroue is not locked to a single chain. The same delegation signatures, smart accounts, and enforcer caveats work on any EVM chain with a DelegationManager deployment — making our agent marketplace truly portable.

On-Chain Artifacts

Contracts and infrastructure used by the delegation system across both networks.

Base Sepolia
DelegationManager0xdb9B1e94B5b69Df7e401DDbedE43491141047dB3
ServiceBoard (V2 Proxy)0xA384C03DdD65e625Ce8220716fF56947fAA5E3B2
EscrowVault (V2 Proxy)0x8C6E66195F6DFB4F94BaE4058Ad1d6128A08B579
ReputationRegistry (V2 Proxy)0x95c59a74bb9C9f598602EE2774E0Dc72fFd0d2Df
Enforcers31 contracts (6 used)
Celo Sepolia
Same contracts deployedIdentical bytecode on Celo Sepolia, verified working
🦊Delegation Toolkit📚Gator Docs🏗Escroue Repo🔍Base Sepolia Explorer🌿Celo Sepolia Explorer

Built for The Synthesis Hackathon — Escroue x MetaMask Delegation Framework — Multi-chain: Base Sepolia + Celo Sepolia