WINNER OF BNBCHAIN HACKATHON
AI-assisted, milestone-escrow influencer operations on BNB Chain
Clawgency is a professional influencer-operations platform that combines:
- on-chain escrow execution (BNB Chain)
- role-based product workflows (Brand / Influencer / Admin)
- deterministic OpenClaw agent recommendations
- human-approved email automation with signed audit logs
Human-in-the-loop is mandatory for sensitive actions:
- AI outputs are advisory
- wallet transactions require manual signature
- email sends require explicit approval metadata and audit records
- Live Deployments
- Core Capabilities
- Repository Layout
- Architecture
- Smart Contract Structure and Design
- Frontend Product Surface
- API Reference
- OpenClaw Workflows
- Configuration
- Local Setup
- Deployment and Mainnet Migration
- Vercel Production Setup
- Testing
- Security Model
- Observability and Logs
- Known Limitations
- Additional Docs
- Web app:
https://clawgency.vercel.app - BSC Mainnet contract (verified):
0x3C79563E4AA6566240790B404D18d3f7F093Fa12https://bscscan.com/address/0x3C79563E4AA6566240790B404D18d3f7F093Fa12#code
- Milestone-based campaign escrow with agency fee split
- Offer negotiation workflow (brand offer, creator counter, accept/decline)
- Proof submission and brand approval lifecycle
- Role-specific dashboards:
/brand/dashboard/influencer/dashboard/admin/analytics
- OpenClaw workflows:
- campaign drafting
- proof validation
- on-chain monitoring
- outreach/reply email intelligence
- Backend-only Gmail integration (mock/live modes)
- HMAC-chained human approval log signatures for email sends
clawgency/
|- contracts/
| `- CampaignEscrowV2.sol
|- scripts/
| |- deploy-v2.ts
| `- verify-v2.ts
|- test/
| `- CampaignEscrowV2.ts
|- openclaw/
| |- workflows/
| |- schemas/
| |- tests/
| |- templates/
| `- config/
|- frontend/
| |- app/
| | |- brand/dashboard/
| | |- influencer/dashboard/
| | |- admin/analytics/
| | `- api/
| |- components/
| |- context/
| |- lib/
| `- tests/
|- docs/
`- .github/workflows/ci.ymlflowchart LR
BW[Brand Wallet] -->|create / fund / approve / release| SC[CampaignEscrowV2]
IW[Influencer Wallet] -->|submitProof / deny| SC
SC --> UI[Next.js Dashboards]
SC --> MON[Workflow3 Monitoring]
UI --> API[Next.js API Routes]
API --> WF1[Workflow1 Drafting]
API --> WF2[Workflow2 Proof Validation]
API --> WF3[Workflow3 Monitoring]
API --> WF4[Workflow4 Email Draft]
API --> WF5[Workflow5 Reply Parse]
API --> WF6[Workflow6 Completion Draft]
API --> MAIL[Platform Gmail Adapter]
MAIL --> GMAIL[Platform Gmail Inbox]
API --> ALOG[Agent Audit Log]
API --> HLOG[Human Approval Log]
Data flow summary:
- On-chain value and state transitions happen only in
CampaignEscrowV2. - Frontend reads contract state via
wagmi/viem. - AI workflows produce deterministic advisory output.
- Backend enforces email send policy and approval logging.
Contract file: contracts/CampaignEscrowV2.sol
- Trust-minimized escrow between brands and creators
- Milestone-gated release flow
- Transparent agency fee extraction
- Safety controls for pause, reentrancy, and authorization
CampaignState:Created,Funded,Completed,CancelledCampaignstruct fields:brand,influencertotalMilestoneAmount,totalEscrowed,totalReleasedagencyFeeBps,reputationScore,state- arrays for milestone amounts, approvals, paid flags, proof hashes
campaignCountmapping(uint256 => Campaign) _campaignsmapping(address => uint256) influencerReputation
createCampaign(...)- validates addresses, milestones, and fee cap
- initializes campaign and milestones
depositFunds(campaignId)payable- brand-only
- updates escrow and transitions to
Fundedif fully covered
submitProof(campaignId, proofHash)- influencer-only
- writes proof for next unpaid milestone
approveMilestone(campaignId, milestoneIndex)- brand-only
- requires proof present
releaseFunds(campaignId)- brand-only + nonReentrant
- releases all approved unpaid milestones
- splits payout: influencer + agency owner
cancelCampaign(campaignId)- brand or influencer
- only before any payout release
- refunds escrow to brand
getCampaign,getMilestone- read helpers for dashboards
pause,unpause- owner-only emergency controls
BASIS_POINTS = 10000MAX_AGENCY_FEE_BPS = 3000(30%)- agency payout =
gross * agencyFeeBps / BASIS_POINTS - influencer payout =
gross - agency payout
OwnablePausableReentrancyGuard- strict role checks (
brandvsinfluencer) - custom errors for deterministic revert handling
- cannot release without approved milestones
- cannot approve milestone without proof
- cannot cancel after payouts start
- campaign transitions are monotonic and bounded
/login: wallet connect + role routing/register: signed challenge profile registration/creators: global creator directory with wallet copy action/brand/dashboard:- AI draft generation
- negotiation + on-chain creation
- funding, milestone approval, release
/influencer/dashboard:- offer counter/decline
- proof submission + completion email trigger
/admin/analytics:- monitoring scan
- audit logs
- human approval email send panel
Core frontend infra:
- Next.js 14 app router
- RainbowKit + wagmi + viem
- HeroUI + Tailwind CSS
POST /api/agent/workflow1POST /api/agent/workflow2GET /api/agent/workflow3POST /api/agent/workflow3GET /api/agent-logs
POST /api/profiles/challengePOST /api/profiles/registerGET /api/profilesGET /api/profiles/creators
GET /api/offersPOST /api/offersPOST /api/offers/[offerId]/counterPOST /api/offers/[offerId]/acceptPOST /api/offers/[offerId]/decline
POST /api/email/draftPOST /api/email/sendGET /api/email/repliesPOST /api/email/repliesGET /api/email/approval-logsGET /api/email/oauth/startGET /api/email/oauth/callbackPOST /api/campaigns/proposal-emailPOST /api/campaigns/completion-email
| Workflow | File | Purpose |
|---|---|---|
| Workflow 1 | openclaw/workflows/workflow1-intelligent-drafting.js |
Draft campaign transaction proposal |
| Workflow 2 | openclaw/workflows/workflow2-proof-validation.js |
Validate proof syntax and suggest approve/reject |
| Workflow 3 | openclaw/workflows/workflow3-monitoring.js |
Scan chain events and produce alerts |
| Workflow 4 | openclaw/workflows/workflow4-email-drafting.js |
Draft outreach email (advisory) |
| Workflow 5 | openclaw/workflows/workflow5-reply-parsing.js |
Parse reply intent (yes/no/maybe) |
| Workflow 6 | openclaw/workflows/workflow6-completion-email-drafting.js |
Draft completion notification email |
Safety posture:
- no private key access in workflow runtime
- no auto-send / no auto-execute on-chain
- advisory-only outputs with human review requirement
PRIVATE_KEY=0x...
BSC_TESTNET_RPC_URL=https://data-seed-prebsc-1-s1.bnbchain.org:8545
BSC_MAINNET_RPC_URL=https://bsc-dataseed.binance.org
ETHERSCAN_API_KEY=...
AGENCY_TREASURY=0x...
CONTRACT_ADDRESS_TESTNET=
CONTRACT_ADDRESS_MAINNET=NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=...
NEXT_PUBLIC_USE_TESTNET=true
NEXT_PUBLIC_BSC_TESTNET_RPC_URL=https://data-seed-prebsc-1-s1.bnbchain.org:8545
NEXT_PUBLIC_BSC_MAINNET_RPC_URL=https://bsc-dataseed.binance.org
NEXT_PUBLIC_CAMPAIGN_ESCROW_V2_ADDRESS=0x...
CONTRACT_ADDRESS_TESTNET=0x...
CONTRACT_ADDRESS_MAINNET=0x...
NEXT_PUBLIC_ADMIN_WALLET=0x...
OPENCLAW_ROOT=../openclawEMAIL_PROVIDER_MODE=mock
CLAWGENCY_PLATFORM_EMAIL=agency@clawgency.xyz
GOOGLE_OAUTH_CLIENT_ID=
GOOGLE_OAUTH_CLIENT_SECRET=
GMAIL_REFRESH_TOKEN=
GMAIL_OAUTH_REDIRECT_URI=http://localhost:3000/api/email/oauth/callback
GMAIL_REPLY_LABEL=clawgency-replies
HUMAN_APPROVAL_LOG_SIGNING_KEY=replace-with-long-random-secret
SYSTEM_EMAIL_APPROVER_ID=system_openclaw_automation
SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=
SUPABASE_ANON_KEY=
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
SUPABASE_PROFILE_TABLE=wallet_profiles
PROFILE_AUTH_SECRET=replace-with-long-random-secret- Node.js 20+
- npm 10+
npm install
cd frontend && npm install && cd ..npm run build:contracts
npm run test:contractsnpm run test:agentcd frontend
npm run devnpm run deploy:testnet
npm run deploy:mainnetnpm run verify:testnet
npm run verify:mainnet- Set
PRIVATE_KEY,BSC_MAINNET_RPC_URL,AGENCY_TREASURYin root.env. - Run
npm run deploy:mainnet. - Copy deployed address to:
.env->CONTRACT_ADDRESS_MAINNETfrontend/.env.local->NEXT_PUBLIC_CAMPAIGN_ESCROW_V2_ADDRESSfrontend/.env.local->CONTRACT_ADDRESS_MAINNET
- Set
NEXT_PUBLIC_USE_TESTNET=false. - Run
npm run verify:mainnet. - Redeploy frontend with matching Vercel env values.
Vercel project settings:
- Root Directory:
frontend - Install Command:
npm ci - Build Command:
npm run build
Production env recommendations:
- use
EMAIL_PROVIDER_MODE=mockfor safe demo - for live Gmail:
- set
EMAIL_PROVIDER_MODE=live - set
GOOGLE_OAUTH_CLIENT_ID,GOOGLE_OAUTH_CLIENT_SECRET,GMAIL_REFRESH_TOKEN - set
GMAIL_OAUTH_REDIRECT_URI=https://<your-domain>/api/email/oauth/callback
- set
- set
HUMAN_APPROVAL_LOG_SIGNING_KEY(required in production)
Important serverless note:
GMAIL_REFRESH_TOKEN_FILEis not durable on serverless; preferGMAIL_REFRESH_TOKENenv var.
Root:
npm run test:contracts
npm run test:agentFrontend:
cd frontend
npm run lint:ci
npm run typecheck
npm run build
npm run test:e2eCI pipeline:
.github/workflows/ci.yml
- Private keys never exposed to OpenClaw workflows.
- AI recommendations are advisory and non-executing.
- On-chain actions require explicit wallet signature.
- Email sends require explicit approval fields and signed audit entry.
- Rate limiting guards sensitive API routes.
- Backend-only email sending path (no direct agent send).
- Agent audit log (frontend runtime):
- default
os.tmpdir()/clawgency/agent-audit.log - override via
CLAWGENCY_AGENT_AUDIT_LOG_FILE
- default
- Human approval log:
- default
os.tmpdir()/clawgency/human-approval.log - override via
CLAWGENCY_HUMAN_APPROVAL_LOG_FILE
- default
- OpenClaw local logs:
openclaw/logs/*
- No proxy upgrade pattern for current contract deployment.
- Offer storage uses local file on serverless by default; migrate to durable DB for multi-instance production.
- In-memory rate limiter is instance-local; use Redis/KV for global limits.
- Monitoring is polling-based, not event-stream daemon.
- Email is single platform mailbox (no multi-tenant inbox partitioning yet).
docs/ARCHITECTURE.mddocs/CONTRACT_EXPLAINED.mddocs/SECURITY_SANDBOXING.mddocs/EMAIL_INTEGRATION.mddocs/TESTING.mddocs/DEMO.md

