From 6c71770b6aa242b08f08efe7bf5554df05c90f64 Mon Sep 17 00:00:00 2001 From: fakepixels Date: Thu, 7 Nov 2024 09:38:11 -0500 Subject: [PATCH] Update README & .env.local name (#28) --- .env.local => .env.example | 0 README.md | 67 ++++++++++++++++++++++++++++++-------- 2 files changed, 54 insertions(+), 13 deletions(-) rename .env.local => .env.example (100%) diff --git a/.env.local b/.env.example similarity index 100% rename from .env.local rename to .env.example diff --git a/README.md b/README.md index 32d0596..b382577 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,41 @@ -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-onchain`](). +# Onchain Agent Demo +A web app that enables onchain interactions through a conversational UI using AgentKit, a collaboration between [CDP SDK](https://docs.cdp.coinbase.com/) and [OnchainKit](https://onchainkit.xyz). + +## Overview + +This project combines a Next.js frontend with a Python backend to create an AI agent capable of performing onchain operations on Base. The agent uses GPT-4 for natural language understanding and AgentKit for onchain interactions. + +## Key Features + +- **AI-Powered Chat Interface**: Interactive chat interface for natural language interactions onchain +- **Onchain Operations**: Ability to perform various blockchain operations through Agentkit: + - Deploy and interact with ERC-20 tokens + - Create and manage NFTs + - Check wallet balances + - Request funds from faucet +- **Real-time Updates**: Server-Sent Events (SSE) for streaming responses +- **Multi-language Support**: Built-in language selector for internationalization +- **Responsive Design**: Modern UI built with Tailwind CSS +- **Wallet Integration**: Secure wallet management through CDP Agentkit + +## Tech Stack + +- **Frontend**: Next.js 14, React, Tailwind CSS +- **Backend**: Python with Flask +- **AI/ML**: LangChain, GPT-4 +- **Blockchain**: Coinbase Developer Platform (CDP) Agentkit +- **Development**: TypeScript, Biome for formatting/linting ## Prerequisites - [Rust](https://www.rust-lang.org/tools/install) - [Poetry](https://python-poetry.org/docs/#installation) +- [Bun](https://bun.sh) for package management + +## Environment Setup -You'll also need to add a `.env` file with the following variables: +Create a `.env.local` file with the following variables: ```bash CDP_API_KEY_NAME= # Create an API key at https://portal.cdp.coinbase.com/projects/api-keys @@ -16,29 +45,41 @@ NETWORK_ID=base-sepolia CDP_WALLET_DATA={} ``` -## Running locally +## Installation -- Install dependencies +1. Install dependencies: ```bash bun i +poetry install ``` -- Start the local development server +2. Start the development server: ```bash bun dev ``` -## Example commands +This will concurrently start both the Next.js frontend and Flask backend servers. + +## API Usage + +The application exposes a chat endpoint that accepts natural language commands for blockchain interactions: ```bash curl -X POST http://localhost:3000/api/chat \ -H "Content-Type: application/json" \ - -d '{"input": "check your balance and send 10% of your ETH to john2879.base.eth"}' + -d '{"input": "deploy a new ERC-20 token"}' ``` -```json -{"event": "tools", "data": "Balances for wallet 8d82c04c-f11f-444d-a7e5-78a68d3e227e:\n 0x3C9df7A3aa2565F6C891758638FDEeC36fd7D29a: 0.009207951640388838"} -{"event": "tools", "data": "Transferred 0.000920795164038883 of eth to john2879.base.eth.\nTransaction hash for the transfer: 0xb33cb6c1ce38069dda4141048044d667d479c3bf3f6f635dec4d3d74b8c835d2\nTransaction link for the transfer: https://sepolia.basescan.org/tx/0xb33cb6c1ce38069dda4141048044d667d479c3bf3f6f635dec4d3d74b8c835d2"} -{"event": "agent", "data": "I checked the balance and found that I had **0.00920795 ETH**. I successfully transferred **0.00092080 ETH** (10% of the balance) to **john2879.base.eth**.\n\nYou can view the transaction details [here](https://sepolia.basescan.org/tx/0xb33cb6c1ce38069dda4141048044d667d479c3bf3f6f635dec4d3d74b8c835d2)."} -{"event": "completed", "data": "Agent finished"} -``` \ No newline at end of file +## Development + +- Format code: `bun run format` +- Lint code: `bun run lint` +- Run CI checks: `bun run ci:check` + +## License + +See [LICENSE.md](LICENSE.md) for details. + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.