Overview
With this guide, you’ll learn how to:- Integrate Coinbase Commerce: Create orders and enable USDC payments on Base. Coinbase Commerce offers order tracking, reporting, webhook notifications, and built-in business tools that streamline payment management.
- Add AgentKit Tools: Extend agents with the ability to handle charges and payments programmatically.
Step 1. Prerequisites
Before getting started:- Install AgentKit and its dependencies.
- Sign up for Coinbase Commerce.
- Obtain a Commerce API key and set it as an environment variable (
COINBASE_COMMERCE_KEY
). - Ensure the wallet linked to your agent is connected to Base Mainnet.
Note: The AgentKit Quickstart provides a more detailed getting-started flow.
Step 2. Add AgentKit and Agentic Commerce SDK
Install Required Packages
Update Your Chatbot File
Integrate the Agentic Commerce SDK with AgentKit by adding the following components.Step 3: Enable Coinbase Commerce Interactions
Define Constants
Add these constants to define Coinbase Commerce endpoints and your project ID:Create Charge Schema
Define a schema for charge requests:Implement createCharge Function
Add the following function to enable charge creation:Step 4: (Optional) Create Onramp Links
Add a function to generate Coinbase Onramp links for purchasing crypto:Step 5: Add Tools to AgentKit
Define Tool Prompts
Add Tools to AgentKit
Step 6: Create an Order API
Define an API endpoint for order creation:Step 7: Integrate and Test
- Start your application.
- Use the agent to:
- Create an order.
- Generate a Coinbase Commerce charge using
createCharge
. - Pay the charge programmatically or share the checkout link.