Technical Documentation
Understand the smart contract state machine, decentralized consensus rules, and execution flow of Roda on Arc Network.
Quick Start Guide
Follow this flow to test a complete savings circle end-to-end:
- Connect Wallet: Click "Connect Wallet" on the home page and switch your network to Arc Testnet (Chain ID: 5042002).
- Faucet: Fund your connected wallet with native USDC (for gas) and ERC-20 USDC (for contributions) via faucet.circle.com.
- Create: Click the "Create Circle" tab, specify a contribution amount (e.g. 10 USDC), the number of members (e.g. 3), and round duration (e.g. 60 seconds for a quick test).
- Join: Distribute the circle address to 2 other wallets (or test using separate browser profiles). Each wallet must click Approve & Join to lock their collateral.
- Rotate: In each round:
- All members call
contribute()to pay their share. - Once paid, or if the deadline passes, anyone can call
closeRound()to advance. - The designated round beneficiary claims the collected pot using
claimPayout(). - If a member is at risk of defaulting, the AI Liquidity Guardian can trigger a bailout.
- All members call
- Settle: Once the last round closes, all members call
withdrawCollateral()to reclaim their security deposits.
State Machine & Lifecycle
Each SavingsCircle operates as a rigid, trustless state machine to protect funds from defaults:
Collateral Protection: When joining a circle, members must escrow an amount exactly equal to one round's contribution. If a member fails to contribute by the round's deadline, closeRound() automatically recovers their missing payment by burning a portion of their locked collateral. This guarantees the beneficiary always receives the full payout.
AI Liquidity Guardian & ERC-8004
Roda integrates autonomous agent automation with verified on-chain identities to secure collaborative saving pools.
1. Autonomous Credit Protection
The AI Liquidity Guardian acts as an on-chain automated risk engine. When a member is in danger of defaulting, the Guardian can autonomously decide to perform a liquidity bailout:
- The Guardian assesses the member's collateral, debt, and payment history using DeepSeek AI.
- If approved, the Guardian's Circle Developer-Controlled Wallet automatically signs and broadcasts transactions to execute the bailout on Arc Testnet, keeping the savings circle liquid.
2. ERC-8004 Agent Identity & Reputation
To ensure trustless execution, the AI Guardian is registered as an on-chain identity using the ERC-8004 standard:
- The agent is minted as an identity NFT on Arc's
IdentityRegistry. - Following each credit assessment, a validator wallet submits a
giveFeedbackrating to the on-chainReputationRegistry. - The overall reputation score and historical assessments are calculated directly from on-chain logs.
How to Test the Guardian:
- Enter any active circle dashboard and locate the AI Liquidity Guardian panel.
- Verify the agent's on-chain status under the Onchain Identity Verified widget.
- Select a member from the dropdown list and click Analyze Risk to fetch a real-time risk profile and AI rationale.
- If approved, click Execute Automated Injection to trigger the live Circle-powered transaction.
Arc Decimal Contexts
Arc features a stablecoin-first native architecture. However, this introduces two decimal contexts that must never be mixed:
- Native Gas USDC: 18 decimals. Used for gas fees and checked using standard wallet balances (e.g.
useBalance). - ERC-20 USDC: 6 decimals. Used for all contract token transfers, deposits, pots, and payouts (contract address:
0x3600000000000000000000000000000000000000).
parseUsdc(x) targets 6 decimals; parseGas(x) targets 18.Smart Contracts Reference
The contract codebase consists of two core smart contracts compiled with Solidity 0.8.28:
1. CircleFactory.sol
Deploys and indexes individual savings circles for public discovery.
2. SavingsCircle.sol
Manages individual circles, escrow deposits, round tracking, and default claims.