ChaosChain is a modern, open source fintech platform that leverages Google's official A2A (Agent-to-Agent) SDK and blockchain payment systems to deliver comprehensive investment research and analysis. The platform demonstrates the complete ChaosChain workflow powered by Google's official A2A Protocol, featuring agent discovery, JSON-RPC communication, DKG, verifier networks, consensus, and on-chain payments.
ChaosChain combines multi-agent AI analysis with Google's official A2A Protocol for seamless agent communication. Specialized AI agents communicate using Google's A2A SDK with JSON-RPC messaging, providing real-time market insights, technical analysis, macroeconomic research, and comprehensive investment analysis. The platform integrates DKG (Distributed Knowledge Graph), verifier networks, consensus mechanisms, and blockchain payments for a complete decentralized AI workflow.
- Google A2A Protocol: Official A2A SDK with JSON-RPC 2.0 messaging
- Multi-Agent AI System: 16 specialized, collaborative AI agents (GPT-4 variants)
- DKG Integration: Distributed Knowledge Graph with Proof of Agency
- Verifier Network: 4 independent verifiers with consensus validation
- Agent Reputation Network (ARN): Decentralized agent discovery and coordination
- Blockchain Payments: Integrated x402 and Commerce Payments with micro-transactions
- Real-Time Analysis: Live market data and AI-powered insights
- ChaosChain Workflow: Complete decentralized AI agent workflow
- Modern UI: Responsive Next.js frontend with A2A protocol indicators
The platform features 16 specialized AI agents that communicate via Google's official A2A SDK:
- Market Research Agents (GPT-4, GPT-4o): Market sentiment, news analysis, trend research
- Macro Research Agents (GPT-4, GPT-4o): Economic indicators, central bank policies, global trends
- Price Analysis Agents (GPT-4, GPT-4o): Technical analysis, chart patterns, price predictions
- Insights Agents (GPT-4, GPT-4o): Report generation, cross-agent analysis, recommendations
- Verifier Agents 1-4: Independent verification, consensus validation, multi-criteria scoring
- Agent Discovery: JSON-RPC
agent/discovercalls - Task Distribution: A2A
message/sendprotocol - Data Sharing: Inter-agent
data/sharecommunication - DKG Integration:
dkg/create_nodewith Proof of Agency
- x402 Protocol: HTTP-native payment protocol for micro-payments (Base Sepolia testnet & Base Mainnet)
- Commerce Payments Protocol: On-chain "authorize and capture" payment flows with escrow and flexible fees (Base network)
- Node.js: 18+
- Package Manager: yarn (recommended) or npm
- OpenAI API Key: Required for AI analysis
- Google A2A SDK:
@a2a-js/sdk(installed automatically) - Blockchain Wallet: For payment testing (optional)
-
Clone the Repository
git clone https://github.com/ChaosChain/fin-studio cd fin-studio -
Install Dependencies
yarn install
-
Environment Setup
- Copy the example environment file:
cp env.local.example .env.local
- Configure your environment variables in
.env.local:OPENAI_API_KEY=your_openai_api_key_here AGENT_MANAGER_PORT=8080 NETWORK=base-sepolia OPERATOR_ADDRESS=0x0000000000000000000000000000000000000000 OPERATOR_PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000000 FACILITATOR_URL=https://x402.org/facilitator ESCROW_CONTRACT_ADDRESS=0xBdEA0D1bcC5966192B070Fdf62aB4EF5b4420cff DEVELOPMENT_MODE=true BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
- Copy the example environment file:
-
Build the Application
yarn agents:build # Build AI agents with A2A supportFor payment testing, you may need ETH from the Base Sepolia Faucet and USDC from Circle Faucet.
-
Start the Services (in separate terminals):
- AI Agents with A2A Protocol
Starts all 16 AI agents with Google A2A SDK integration
yarn agents:start
- Frontend with A2A Integration
Starts the Next.js frontend with integrated A2A protocol (port 3000)
yarn dev
- AI Agents with A2A Protocol
-
Access the Application
- ChaosChain + A2A Demo: http://localhost:3000/chaos-demo
- Main Dashboard: http://localhost:3000
- Agent Dashboard: http://localhost:3000/dashboard
For technical architecture and further details, see docs/TECHNICAL_ARCHITECTURE.md.
Frontend: Next.js 14 (App Router), TypeScript, Tailwind CSS, Radix UI, Recharts, jsPDF
A2A Protocol: Google's official @a2a-js/sdk, JSON-RPC 2.0 messaging
Backend: Node.js, Express, OpenAI GPT-4 API, DKG, ARN, Verifier Network
Blockchain: Base Sepolia/Mainnet, x402, Commerce Payments, viem, wagmi
fin-studio/
βββ src/
β βββ app/
β β βββ chaos-demo/ # ChaosChain + A2A Protocol Demo
β βββ components/
β β βββ ChaosChainDemo.tsx # Main demo with A2A integration
β β βββ DKGVisualizer.tsx # Distributed Knowledge Graph
β β βββ VerifierNetworkVisualizer.tsx # Verifier network
β β βββ ui/ # Reusable UI components
β βββ agents/ # 16 AI agents with A2A support
β βββ lib/
β β βββ a2a/ # Custom A2A implementation (legacy)
β β βββ payment/ # x402 & Commerce Payments
β β βββ dkg.ts # Distributed Knowledge Graph
β β βββ agent-relay-network.ts # ARN coordination
β βββ types/
β β βββ a2a.ts # A2A protocol types
β β βββ payment.ts # Payment system types
β βββ utils/ # Helper utilities
βββ scripts/
β βββ test-a2a-integration.js # A2A protocol integration tests
βββ tests/ # A2A validation tests
βββ payment/ # Payment implementations
βββ docs/ # Documentation
| Script | Description |
|---|---|
yarn dev |
Start frontend with A2A protocol integration |
yarn build |
Build frontend for production |
yarn start |
Start production frontend server |
yarn agents:build |
Compile TypeScript agents with A2A support |
yarn agents:start |
Start 16 agents with Google A2A SDK |
yarn test:a2a |
Test A2A protocol integration |
yarn demo:a2a |
Show ChaosChain + A2A demo URL |
yarn lint |
Run ESLint |
yarn type-check |
Run TypeScript type checking |
The platform uses Google's official A2A SDK (@a2a-js/sdk) for agent communication:
- π€ A2A Agent Discovery: JSON-RPC
agent/discovervia Google Protocol - π― A2A Task Coordination: Google A2A SDK coordination
- β‘ A2A Task Distribution: JSON-RPC
message/sendprotocol - π¬ Real Analysis Execution: A2A-coordinated agents
- π€ A2A Inter-Agent Data Sharing:
data/shareJSON-RPC calls - π A2A DKG Node Creation:
dkg/create_nodewith Proof of Agency - π° A2A Payment Distribution: Consensus-based payments
- All messages follow official A2A specification
- Message structure:
{id, jsonrpc: "2.0", method, params, timestamp} - Methods:
agent/discover,message/send,data/share,dkg/create_node
yarn test:a2a # Comprehensive A2A protocol validationFrontend with A2A Protocol β Direct Agent Communication
β β
Port 3000 16 AI Agents + ARN
(Google A2A SDK)
β
DKG β Verifiers β Consensus β Payments
Integrated A2A Workflow:
- Frontend includes A2A protocol integration
- Agents communicate via Google's official A2A SDK
- No separate gateway server needed
- Complete ChaosChain workflow in one demo
HTTP-native payments can be integrated as middleware:
app.use(
paymentMiddleware("0xYourAddress", {
"/your-endpoint": "$0.01"
})
);For advanced payment flows (authorize and capture):
const authResult = await authorizePayment(payer, amount, token);
const captureResult = await capturePayment(authId, amount);- Base Sepolia: Testnet for development
- Base Mainnet: Production network
The complete ChaosChain workflow integrates Google A2A Protocol with decentralized AI:
- Agents discover each other via Google A2A protocol
- JSON-RPC
agent/discovercalls identify capabilities - ARN (Agent Reputation Network) coordinates agent selection
- Tasks distributed via A2A
message/sendprotocol - Real-time financial analysis coordinated across 16 agents
- GPT-4 variants provide specialized analysis
- Agents share data via A2A
data/shareJSON-RPC calls - Market β Insights, Price β Insights, Macro β Insights
- Real analysis data flows between agents
- Distributed Knowledge Graph stores agent outputs
- A2A
dkg/create_nodecreates signed nodes - Proof of Agency validates agent authenticity
- 4 independent verifiers validate all outputs
- Multi-criteria scoring and consensus calculation
- Reputation updates based on verification results
- Consensus-based payments to agents
- Micro-transactions via x402 protocol
- Agent wallets and payment records tracked
- Create a new agent class in
src/agents/ - Implement required interfaces from
src/types/a2a.ts - Register the agent in
src/agents/manager.ts - Add port configuration
Example:
export class CustomAgent {
getIdentity(): AgentIdentity {
return {
id: 'custom-agent',
name: 'Custom Agent',
type: AgentType.CUSTOM,
version: '1.0.0',
capabilities: ['custom_analysis']
};
}
getHandlers(): Map<string, A2AHandlerFunction> {
const handlers = new Map();
handlers.set('custom_action', this.customAction.bind(this));
return handlers;
}
private async customAction(message: A2AMessage): Promise<A2AMessage> {
// Implementation
}
}- Obtain an OpenAI API key from OpenAI Platform
- Add it to
.env.local - Monitor usage and costs
- OpenAI Search: Real-time market data and news
- AI-Powered Analysis: All analysis via OpenAI GPT-4
- Comprehensive Coverage: Market data, news, economic indicators
- Store API keys in environment variables
- Use secure HTTP for A2A communication
- Validate all agent inputs
- Implement robust error handling to prevent information leakage
- Use audited smart contracts for payment systems
- Monitor agent health and metrics via the dashboard
- Enable debug logging for troubleshooting:
DEBUG=fin-studio:* yarn agents:start - Track OpenAI API usage and per-agent costs
yarn build
# Deploy the output to Vercel or your preferred platform- Build agents:
yarn agents:build - Deploy the
dist/folder to your server - Set up environment variables (including OpenAI API key)
- Start with a process manager:
yarn agents:start - Verify A2A integration:
yarn test:a2a
We welcome contributions to the ChaosChain + Google A2A Protocol project! To maintain high code quality and A2A compliance, please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/your-feature - Make changes and add tests as appropriate
- Ensure all checks pass:
yarn lint && yarn type-check && yarn test:a2a - Commit:
git commit -am 'Add your feature' - Push:
git push origin feature/your-feature - Open a Pull Request with a clear description
A2A Integration Requirements:
- All agent communication must use Google A2A SDK
- JSON-RPC 2.0 compliance required
- Test A2A integration with
yarn test:a2a
Please review the CONTRIBUTING.md for more details on our contribution process and code of conduct.
This project is licensed under the MIT License. See the LICENSE file for details.
- ChaosChain + A2A Demo: Visit http://localhost:3000/chaos-demo
- A2A Integration Testing: Run
yarn test:a2ato verify protocol compliance - Documentation: See this README and inline code comments
- Issues: Open an issue on GitHub for bugs or feature requests
- Discussions: Use GitHub Discussions for questions and ideas
# Start the complete ChaosChain + A2A workflow
yarn dev # Frontend with A2A integration
yarn agents:start # 16 agents with Google A2A SDK
yarn test:a2a # Verify A2A protocol integration
yarn demo:a2a # Show demo URL