DashProtocol

Voice-first AI layer executing Web2 financial intents on-chain via secure smart contracts.

DashProtocol

Created At

ETHOnline 2025

Project Description

Dash Protocol is a next-generation AI-driven DeFi orchestration platform that eliminates the complexity keeping mainstream users out of Web3 finance. It combines voice-first natural language interaction with intelligent agent orchestration and custom smart contracts deployed on Sepolia testnet to deliver seamless, secure decentralized financial operations.The core vision centers on transforming complex DeFi into simple conversational commands. Users speak their trading intentions in natural language such as "Swap 100 DASH to SMS" and the system handles everything from intent parsing through price discovery, quote generation, transaction building, execution, and confirmation. No manual wallet management, no gas settings, no technical blockchain knowledge required.The architecture implements a complete AI control plane using LangGraph state machine orchestration powered by Google Gemini 2.5 Pro. Eight specialized nodes form a directed workflow covering intent interpretation, price fetching via CoinGecko API, quote calculation from on-chain liquidity pools, transaction building with proper nonces and gas estimation, risk-based confirmation routing, signed transaction execution through Alchemy RPC, and real-time monitoring until block confirmation.Voice interaction drives the entire experience through OpenAI Whisper for speech-to-text transcription and pyttsx3 for text-to-speech output. Users literally speak commands and hear responses at each workflow stage, creating a conversational interface that feels more like talking to a financial assistant than interacting with blockchain infrastructure.Smart contracts deployed on Sepolia testnet provide the foundation. A custom liquidity pool at address 0xE3f19EdE356F5E1C1Ef3499F80F794D2C9F3670a implements constant product AMM mechanics following the x times y equals k formula with 0.3 percent trading fees. Two custom ERC20 tokens DASH and SMS with 18 decimals enable real swap demonstrations. The pool contains actual liquidity with 100,000 DASH and 50,000 SMS establishing functional trading pairs.Safety mechanisms include value-based risk assessment where swaps exceeding $100 USD automatically trigger human confirmation prompts with clear explanations of transaction value and expected outcomes. Users receive both visual logs and voice announcements before approving high-value operations.Real blockchain execution distinguishes this from simulation-based demos. Every swap produces verifiable transaction hashes, block numbers, gas consumption records, and balance changes visible on Sepolia blockchain explorers. The system signs transactions with private keys, broadcasts to testnet via Alchemy infrastructure, waits for block confirmation, and verifies final token balances match expected results.The modular agent architecture enables easy extension. New DeFi operations like lending, staking, or yield farming can be added by creating additional LangGraph nodes and connecting them to the state machine workflow. Each agent handles a specific responsibility with clear inputs and outputs making the system composable and maintainable.

How it's Made

Initial development began with Tenderly mainnet fork providing a safe environment to test swap logic and transaction building without risking real funds. This rapid iteration environment enabled development of the AI agent's transaction construction capabilities with instant feedback on gas estimation and contract interactions.

The transition to production involved deploying actual smart contracts on Sepolia testnet. The custom liquidity pool implements core AMM functionality including getReserves returning current token reserves, getAmountOut calculating expected swap outputs using constant product formula with trading fees, swap executing token exchanges with slippage protection via minAmountOut parameter, and token0 plus token1 getters identifying pool token ordering. Initial liquidity of 100,000 DASH and 50,000 SMS established a 1:0.5 exchange rate enabling real swaps with price impact based on reserve ratios.

Blockchain connectivity runs through Alchemy RPC providing production-grade Sepolia testnet access. Web3.py handles all blockchain operations including reading contract state, estimating gas, fetching transaction receipts, monitoring block confirmations, and broadcasting signed transactions. Helper functions convert human-readable amounts to base units using Python Decimal for precision, check token balances via ERC20 balanceOf calls, and handle errors gracefully with detailed logging.

Each swap requires two sequential transactions. First an ERC20 approve transaction authorizes the pool contract to spend input tokens. Second the actual swap transaction calls the pool's swap function with calculated amounts and slippage protection. Both transactions include proper from address, gas limit based on operation complexity, gasPrice from current network conditions, nonce sequentially incremented to prevent collisions, and chainId set to 11155111 for Sepolia.

The AI orchestration layer implements LangGraph StateGraph with typed state dictionary tracking user wallet, input command, parsed intent, USD prices, swap quotes, approval status, transaction hashes, execution status, errors, and conversation memory. Eight specialized nodes form the workflow graph.

Intent interpretation uses Google Gemini 2.5 Pro to parse natural language into structured JSON with action field indicating swap, asset_in specifying source token symbol, asset_out specifying destination token symbol, and amount as numeric value. Few-shot prompting with example inputs and expected outputs guides the LLM toward consistent responses. Pydantic models validate parsed output ensuring required fields exist and amount is positive.

Price fetching queries CoinGecko API for real-time USD prices supporting major cryptocurrencies through symbol-to-ID mapping with dynamic lookup for unknown tokens. The system calculates total USD value by multiplying token amount by current price storing both individual token price and total value for risk assessment.

Quote fetching queries the deployed liquidity pool contract calling getReserves to retrieve current token reserves, comparing addresses with pool's token0 and token1 to determine which reserve corresponds to which token. It calls getAmountOut with input amount and correct reserves calculating expected output tokens accounting for 0.3 percent pool fee and price impact from the swap.

Transaction building constructs two unsigned transactions. The approval transaction calls ERC20 approve on input token contract with pool address as spender and swap amount as value. The swap transaction calls pool's swap function with amount0In and amount1In where one is zero and one is the input amount based on token ordering plus minAmountOut set to 98 percent of quoted output for 2 percent slippage tolerance.

Risk-based decision routing implements value assessment where USD value exceeding 100 dollars routes to human confirmation node requiring explicit user approval. Values below threshold automatically approve and route directly to execution node creating a conditional edge demonstrating intelligent workflow routing based on computed state values.

Transaction execution signs both approval and swap transactions using user's private key from environment variables submitting them sequentially to Sepolia network via Alchemy RPC. All transactions signed with proper EIP-155 signature including chainId preventing replay attacks on other networks.

Transaction monitoring polls Sepolia blockchain for transaction receipt using wait_for_transaction_receipt with 120-second timeout checking status field where 1 indicates success and 0 indicates revert. Upon confirmation it fetches updated token balances verifying swap actually occurred and marks workflow status as completed.

Voice interface integration uses OpenAI Whisper model running locally for speech recognition recording audio via sounddevice library with 16kHz sample rate. Text-to-speech implementation uses pyttsx3 for cross-platform output speaking transaction status updates at each workflow stage.

The technical stack comprises command-line interface with voice input and output via Whisper and pyttsx3, Python with LangChain and LangGraph for state machine workflow, Google Gemini 2.5 Pro for natural language understanding, eight specialized Python functions implementing workflow nodes, custom Solidity liquidity pool implementing constant product AMM deployed on Sepolia, Web3.py connecting to Sepolia via Alchemy RPC handling contract interactions and transaction signing, and CoinGecko API integration for real-time cryptocurrency prices.

Development proceeded through five sprints. Sprint one built initial agent prototype on Tenderly fork. Sprint two deployed custom liquidity pool and tokens to Sepolia testnet and added liquidity. Sprint three integrated voice interface with Whisper and text-to-speech adding eight-node LangGraph workflow. Sprint four migrated to Alchemy infrastructure implementing transaction signing and broadcasting. Sprint five completed end-to-end MVP where voice command goes through orchestrator, fetches prices and quotes, builds transactions, executes on-chain with signatures, monitors confirmation, and verifies balances changed correctly.

background image mobile

Join the mailing list

Get the latest news and updates