How olamilekan-oluwayomi/guardrail-dapp works
Purpose and Runtime
This repository is a client-side Next.js dashboard for an AgentExpenseGuardrail Vyper smart contract deployed on Arc Testnet. It lets MetaMask users inspect contract state and invoke role-gated owner/agent operations.
Primary application entry points:
• app/page.tsx — dashboard logic, wallet/contract interaction, and UI state.
• app/layout.tsx — Next.js root layout.
• app/globals.css — global visual styling.
Application Shell
Next.js App Router provides the page runtime and document shell. Tailwind CSS is used for styling, with likely custom/global styles layered in the app stylesheet.
Paths:
• app/layout.tsx
• app/page.tsx
• app/globals.css
• tailwind.config.ts
Wallet and Network Boundary
The browser Ethereum provider is accessed through MetaMask. The app connects the active account, requests/switches to Arc Testnet chain ID 5042002, and reacts to wallet-supplied identity/network state.
The provider type boundary is declared locally rather than supplied by a wallet SDK:
• types/ethereum.d.ts
• app/page.tsx
External dependency: MetaMask/EIP-1193 provider and an Arc RPC endpoint configured in the page implementation.
Contract Integration
The dashboard binds a configured deployed contract address to the ABI and uses RPC/provider calls for reads and signed transactions. The ABI is kept as a repository artifact, while the page is the integration orchestrator.
Paths:
• AgentExpenseGuardrail_abi.json
• app/page.tsx
The deployed address is intentionally environment/deployment-specific and must be updated in app/page.tsx; no contract source or deployment scripts are included.
Role-Based Control Surfaces
After connection, the UI determines whether the wallet is the contract owner, configured agent, or another account. This role result controls which transaction actions are exposed:
• Owner: update daily limit, replace agent, toggle paused state.
• Agent: execute spend(recipient, amount, memo).
• Any caller: deposit funds, where exposed by the interface.
The contract is the authorization boundary; UI role checks are presentation and workflow guards, not the source of enforcement.
Paths:
• app/page.tsx
• AgentExpenseGuardrail_abi.json
State Read and Refresh Flow
app/page.tsx reads guardrail state from the contract—such as owner/agent configuration, limits, paused status, and balances/spending data—and refreshes it on a five-second interval. Wallet connection or completed transactions should trigger the same reload path so the dashboard converges on chain state.
Flow: MetaMask account/provider → Arc RPC/contract read calls → React page state → role-specific dashboard panels.
Transaction Flow and Failure Boundary
User input is converted into contract-call arguments, submitted through MetaMask for signing, then broadcast to Arc Testnet. The UI must handle provider rejection, RPC/chain errors, pending confirmation, and post-transaction refresh.
Flow: form action in app/page.tsx → contract ABI encoding from AgentExpenseGuardrail_abi.json → MetaMask signature → Arc network transaction → refreshed contract reads.
Build and Deployment Context
The project is a Node.js/Next.js application, suitable for standard Next.js hosting. It has no backend service, database, indexer, or API route in the supplied tree; browser-to-chain communication is the core runtime architecture.
Paths:
• package.json
• next.config.js
• app/page.tsx
Main entry points: page.tsx Guardrail dashboard · layout.tsx Root layout · globals.css Global styles · AgentExpenseGuardrail_abi.json Guardrail ABI
Components 14
Next.js client
- Node.js project
package.json - Next configuration
next.config.js - Root layout
app/layout.tsx - Guardrail dashboard · Orchestrates wallet, contract calls, UI state, and refreshes.
app/page.tsx - Global styles
app/globals.css - Tailwind styling
tailwind.config.ts - Role-based panels · Shows owner, agent, or general actions based on read contract state.
app/page.tsx - Transaction actions · Prepares deposits, owner changes, and agent spend calls from form input.
app/page.tsx
Wallet and network
- Ethereum provider types
types/ethereum.d.ts - MetaMask provider · Supplies account, chain state, signatures, and wallet errors.
- Arc Testnet · Target chain ID 5042002 and RPC boundary.
Contract integration
- Guardrail ABI
AgentExpenseGuardrail_abi.json - AgentExpenseGuardrail · Authorization boundary for owner, agent, and caller operations.
- State reads and refresh · Reloads contract state on connection, transaction completion, and every five seconds.
app/page.tsx
Connections 18
- Node.js project → Guardrail dashboard: builds
- Next configuration → Guardrail dashboard: configures
- Root layout → Guardrail dashboard: hosts
- Global styles → Root layout: styles
- Tailwind styling → Global styles: configures
- Ethereum provider types → Guardrail dashboard: types provider
- Guardrail dashboard → MetaMask provider: connects and listens
- Guardrail dashboard → State reads and refresh: triggers reload
- State reads and refresh → Guardrail ABI: encodes reads with
- State reads and refresh → AgentExpenseGuardrail: reads state
- AgentExpenseGuardrail → Arc Testnet: deployed on
- State reads and refresh → Role-based panels: updates UI state
- Role-based panels → Transaction actions: exposes allowed actions
- Transaction actions → Guardrail ABI: encodes calls with
- Transaction actions → MetaMask provider: requests signature
- MetaMask provider → Arc Testnet: switches and broadcasts
- Arc Testnet → AgentExpenseGuardrail: executes transaction
- Transaction actions → State reads and refresh: refreshes after confirmation