Skip to content

Commit

Permalink
Update README & .env.local name (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
fakepixels authored Nov 7, 2024
1 parent 90b1278 commit 6c71770
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 13 deletions.
File renamed without changes.
67 changes: 54 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"}
```
## 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.

0 comments on commit 6c71770

Please sign in to comment.