A Next.js application that integrates Gemini AI to interpret natural language commands into EVM-compatible transactions. It uses Wagmi for wallet connection and transaction execution, with robust backend validation for Ethereum addresses and ERC20 contracts.
Clone the repository:
git clone https://github.com/sriram651/web3-token-transfer-gemini.git
cd web3-token-transfer-gemini
Install dependencies
```bash npm install
Create a .env.local
file in the root directory and add the following variables:
```bash NEXT_PUBLIC_GEMINI_API_KEY=your-gemini-api-key NEXT_PUBLIC_RPC_URL=your-ethereum-rpc-url NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your-wallet-connect-project-id
Start the development server:
npm run dev
Open your browser and navigate to:
```bash http://localhost:3000
Enter a command in the input box, such as:
Send 10 tokens to 0xRecipientAddress from me using contract 0xTokenAddress
The application parses the command using Gemini AI and validates the transaction details on the backend.
Connect your wallet using the "Connect Wallet" button.
Execute the transaction via Wagmi.
/api/gemini
Method: POST
Description: Parses user input into an EVM-compatible transaction.
Request Body: ```bash { "input": "your-natural-language-command" }
Response:
```bash { "success": true, "data": { "recipientAddress": "0x000...", "amount": 123, "isErc20": true, "tokenAddress": "0x345..." } }
Wagmi for wallet and blockchain interaction.
Google Generative AI for natural language processing.
Next.js for the React framework.
Tailwind CSS and NextUI for UI styling.