Skip to content

Commit

Permalink
Merge pull request #36 from coinbase/alissa.crane/readme
Browse files Browse the repository at this point in the history
chore: update readme
  • Loading branch information
abcrane123 authored Nov 8, 2024
2 parents 281a493 + 4a56523 commit 369ee4b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 57 deletions.
9 changes: 1 addition & 8 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
NEXT_PUBLIC_ONCHAINKIT_PROJECT_NAME=agent-frontend
NEXT_PUBLIC_ONCHAINKIT_CDP_KEY=
NEXT_PUBLIC_ONCHAINKIT_WALLET_CONFIG=smartWalletOnly
CDP_API_KEY_NAME=
CDP_API_KEY_PRIVATE_KEY=""
OPENAI_API_KEY=
NETWORK_ID=base-sepolia
CDP_WALLET_DATA={}
NEXT_PUBLIC_API_URL=
26 changes: 3 additions & 23 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
## Prerequisites

- [Rust](https://www.rust-lang.org/tools/install)
- [Poetry](https://python-poetry.org/docs/#installation)
- [Bun](https://bun.sh) for package management

You'll also need to add a `.env` file with the following variables:
You'll also need to add a `.env` file with the following variable:

```bash
CDP_API_KEY_NAME= # Create an API key at https://portal.cdp.coinbase.com/projects/api-keys
CDP_API_KEY_PRIVATE_KEY="" # Create an API key at https://portal.cdp.coinbase.com/projects/api-keys
OPENAI_API_KEY= # Get an API key from OpenAI - https://platform.openai.com/docs/quickstart
NETWORK_ID=base-sepolia
CDP_WALLET_DATA={}
NEXT_PUBLIC_API_URL= # The base URL for API requests. This must be set to the endpoint of your backend service.
```

## Running locally
Expand All @@ -23,19 +18,4 @@ bun i
- Start the local development server
```bash
bun dev
```

## Example commands

```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"}'
```

```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"}
```
27 changes: 2 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A web app that enables onchain interactions through a conversational UI using Ag

## 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.
This project features a Next.js frontend designed to work seamlessly with [CDP's AgentKit backend](https://github.com/coinbase/onchain-agent-demo-backend). Together, they enable the creation of 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

Expand All @@ -18,61 +18,38 @@ This project combines a Next.js frontend with a Python backend to create an AI a
- 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

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
CDP_API_KEY_PRIVATE_KEY="" # Create an API key at https://portal.cdp.coinbase.com/projects/api-keys
OPENAI_API_KEY= # Get an API key from OpenAI - https://platform.openai.com/docs/quickstart
NETWORK_ID=base-sepolia
CDP_WALLET_DATA={}
NEXT_PUBLIC_API_URL= # The base URL for API requests. This must be set to the endpoint of your backend service.
```

## Installation

1. Install dependencies:
```bash
bun i
poetry install
```

2. Start the development server:
```bash
bun dev
```

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": "deploy a new ERC-20 token"}'
```

## Development

- Format code: `bun run format`
Expand Down
2 changes: 1 addition & 1 deletion app/components/AgentAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NFTMintCard } from '@coinbase/onchainkit/nft';
import { NFTCollectionTitle } from '@coinbase/onchainkit/nft/mint';
import { type Token, TokenRow } from '@coinbase/onchainkit/token';
import { useCallback, useEffect, useMemo, useState } from 'react';
import { type Address, erc721Abi, } from 'viem';
import { type Address, erc721Abi } from 'viem';
import { useContractRead, useToken } from 'wagmi';
import useGetNFTs from '../hooks/useGetNFTs';
import useGetTokens from '../hooks/useGetTokens';
Expand Down

0 comments on commit 369ee4b

Please sign in to comment.