{"id":31243487,"url":"https://github.com/coinbase/onchain-agent-demo-backend","last_synced_at":"2025-09-23T01:08:35.880Z","repository":{"id":261876609,"uuid":"885055524","full_name":"coinbase/onchain-agent-demo-backend","owner":"coinbase","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-08T01:13:45.000Z","size":165,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-08T02:18:40.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coinbase.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-07T21:50:57.000Z","updated_at":"2024-12-08T01:13:49.000Z","dependencies_parsed_at":"2024-11-09T00:25:31.320Z","dependency_job_id":"61e4f2ed-0a18-4344-b2e0-0cf6a061d513","html_url":"https://github.com/coinbase/onchain-agent-demo-backend","commit_stats":null,"previous_names":["coinbase/onchain-agent-demo-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/coinbase/onchain-agent-demo-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fonchain-agent-demo-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fonchain-agent-demo-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fonchain-agent-demo-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fonchain-agent-demo-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coinbase","download_url":"https://codeload.github.com/coinbase/onchain-agent-demo-backend/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coinbase%2Fonchain-agent-demo-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":276498444,"owners_count":25653010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-22T02:00:08.972Z","response_time":79,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-23T01:03:12.929Z","updated_at":"2025-09-23T01:08:35.874Z","avatar_url":"https://github.com/coinbase.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Onchain Agent Backend Demo\n\n![Token-creation](https://github.com/user-attachments/assets/016c26cd-c599-4f7c-bafd-c8090069b53e)\n\nA 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).\n\n## Overview\n\nThis project features a Python backend designed to work seamlessly with CDP's AgentKit 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.\n\n## Modules\n\n- The `agent` module contains functions for interacting with the onchain agent.\n    - `initialize_agent` creates (or loads) an agent from CDP Wallet Data.\n    - `run_agent` invokes the agent.\n    - `handle_action_agent` handles agent actions - in our demo, we just save the addresses of deployed NFTs and ERC-20s to a SQLite database, but you can customize this behavior for your application.\n- The `agent.custom_actions` module contains an example for adding custom actions to the agent.\n    - `get_latest_block` is a custom action we've added that retrieves the latest Base Sepolia block information for the agent.\n    - You can add additional custom actions to this module, following our example.\n\n## Key Features\n\n- **AI-Powered Chat Interface**: Interactive chat interface for natural language interactions onchain\n- **Onchain Operations**: Ability to perform various blockchain operations through Agentkit:\n  - Deploy and interact with ERC-20 tokens\n  - Create and manage NFTs\n  - Check wallet balances\n  - Request funds from faucet\n- **Real-time Updates**: Server-Sent Events (SSE) for streaming responses\n- **Multi-language Support**: Built-in language selector for internationalization\n- **Responsive Design**: Modern UI built with Tailwind CSS\n- **Wallet Integration**: Secure wallet management through CDP Agentkit\n\n## Tech Stack\n\n- **Backend**: Python with Flask\n- **AI/ML**: LangChain, GPT-4\n- **Blockchain**: Coinbase Developer Platform (CDP) Agentkit\n\n## Prerequisites\n\n- [Rust](https://www.rust-lang.org/tools/install)\n- [Poetry](https://python-poetry.org/docs/#installation)\n\n## Environment Setup\n\nCreate a `.env` file with the following variables:\n\n```bash\nCDP_API_KEY_NAME= # Create an API key at https://portal.cdp.coinbase.com/projects/api-keys\nCDP_API_KEY_PRIVATE_KEY=\"\" # Create an API key at https://portal.cdp.coinbase.com/projects/api-keys\nOPENAI_API_KEY= # Get an API key from OpenAI - https://platform.openai.com/docs/quickstart\nNETWORK_ID=base-sepolia\n```\n\n## Installation\n\n1. Install dependencies:\n```bash\npoetry install\n```\n\n2. Start the development server:\n```bash\npoetry run python index.py\n```\n\nThis will start the Python backend server.\n\n## Agent Wallet\n\n**Note**: when running your agent from the first time, the SDK will automatically generate a wallet for you. The wallet information will be logged to the console, and saved to the `wallets` table in the SQLite DB.\n\n**Important**: This is for demo purposes, and we do not recommend this approach for a production application. Please save your wallet information somewhere safe.\n\nAgents will by default be re-instantiated through the SQLite DB.\n\nYou can also instantiate your agent from the following environment variables.\n\n```\nCDP_WALLET_ID=\"\",\nCDP_WALLET_SEED=\"\"\n```\n\n## API Usage\n\nThe application exposes a chat endpoint that accepts natural language commands for blockchain interactions:\n\n```bash\ncurl -X POST http://localhost:5000/api/chat \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"input\": \"deploy a new ERC-20 token\", \"conversation_id\": 0}'\n```\n\n\nRetrieve a list of NFTs deployed by the agent:\n\n```bash\ncurl http://localhost:5000/nfts \n```\n\nRetrieve a list of ERC-20s deployed by the agent:\n\n```bash\ncurl http://localhost:5000/tokens\n```\n\n## Deploying to Replit\n\n- [Frontend Template](https://replit.com/@alissacrane1/onchain-agent-demo-frontend?v=1)\n- [Backend Template](https://replit.com/@alissacrane1/onchain-agent-demo-backend?v=1)\n\nSteps:\n- Sign up for a Replit account, or login to your existing one.\n- Navigate to the template links, and click `Use Template` on the top right hand side.\n- Under `Secrets` in `Workspace Features`, add the environment variables below.\n  - Tip: You can click `Edit as JSON` and copy the values below in.\n- Click `Deploy` in the top right.\n  - Tip: Deploy your backend first, as you'll need the deployment URL for the frontend's `NEXT_PUBLIC_API_URL` environment variable.\n\n**Backend**\n```\n{\n  \"CDP_API_KEY_NAME\": \"get this from https://portal.cdp.coinbase.com/projects/api-keys\",\n  \"CDP_API_KEY_PRIVATE_KEY\": \"get this from https://portal.cdp.coinbase.com/projects/api-keys\",\n  \"OPENAI_API_KEY\": \"get this from https://platform.openai.com/api-keys\",\n  \"NETWORK_ID\": \"base-sepolia\"\n}\n```\n\n**Important: Replit resets the SQLite template on every deployment, before sending funds to your agent or using it on Mainnet be sure to read [Agent Wallet](#agent-wallet) and save your wallet ID and seed in a safe place.**\n\n**Frontend**\n```\n{\n  \"NEXT_PUBLIC_API_URL\": \"your backend deployment URL here\"\n}\n```\n\n## License\n\nSee [LICENSE.md](LICENSE.md) for details.\n\n## Contributing\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fonchain-agent-demo-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoinbase%2Fonchain-agent-demo-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoinbase%2Fonchain-agent-demo-backend/lists"}