### Run the Chatbot Example Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-zerodev-chatbot/README.md Navigate to the example directory, install its dependencies, build, and then start the chatbot. Select '1. chat mode' to interact. ```bash npm install npm start ``` -------------------------------- ### Start the Chatbot Example Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-8004-cdp-chatbot/README.md Run the chatbot example from its specific directory. After starting, select '1. chat mode' to begin managing agent identity and reputation. ```bash pnpm start ``` -------------------------------- ### Run the Chatbot Example Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-cdp-smart-wallet-chatbot/README.md Start the terminal chatbot example from the example's directory. Select '1. chat mode' to begin. ```bash npm start ``` -------------------------------- ### Run create-onchain-agent CLI Source: https://github.com/coinbase/agentkit/blob/main/python/create-onchain-agent/README.md Execute the create-onchain-agent CLI tool to start the guided setup process for a new onchain agent project. ```sh pipx run create-onchain-agent ``` -------------------------------- ### Basic PydanticAI Agent Setup with AgentKit Tools Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/pydantic-ai/README.md Initialize AgentKit, retrieve PydanticAI compatible tools, and create a PydanticAI agent. This example demonstrates how to integrate AgentKit's capabilities into a PydanticAI agent for tasks like crypto trading assistance. ```python from coinbase_agentkit import AgentKit from coinbase_agentkit_pydantic_ai import get_pydantic_ai_tools from pydantic_ai import Agent # Initialize AgentKit agent_kit = AgentKit() # Get PydanticAI compatible tools tools = get_pydantic_ai_tools(agent_kit) # Create PydanticAI agent with the tools agent = Agent( 'openai:gpt-4o', tools=tools, system_prompt='You are a helpful crypto trading assistant.' ) # Use the agent result = agent.run_sync('What is my wallet balance?') print(result.output) ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/coinbase/agentkit/blob/main/python/examples/autogen-cdp-chatbot/README.md Install all necessary project dependencies using the provided Makefile. Ensure you have 'make' installed. ```bash make install ``` -------------------------------- ### Install coinbase-agentkit Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/README.md Install the AgentKit library using pip. ```bash pip install coinbase-agentkit ``` -------------------------------- ### Install Dependencies Source: https://github.com/coinbase/agentkit/blob/main/typescript/create-onchain-agent/templates/mcp/README.md Run this command to install the necessary project dependencies. ```sh npm install ``` -------------------------------- ### Generate Action Provider for All Networks Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/scripts/generate-action-provider/README.md Example of creating a new action provider named 'example' that supports all protocol families. ```bash pnpm run generate:action-provider -- -n example -p all ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/coinbase/agentkit/blob/main/python/create-onchain-agent/README.md After creating your project, navigate to the project directory and install the necessary dependencies using poetry. ```sh cd my-project poetry install ``` -------------------------------- ### Generate Framework-Agnostic AgentKit Setup Source: https://github.com/coinbase/agentkit/blob/main/typescript/create-onchain-agent/README.md Generates a framework-agnostic setup for AgentKit. Ensure the agentkit CLI is installed. ```bash agentkit generate prepare ``` -------------------------------- ### Check Node.js Version Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-8004-cdp-chatbot/README.md Verify that Node.js version 20 or higher is installed. This is a prerequisite for running the example. ```bash node --version ``` -------------------------------- ### Check Python and uv Versions Source: https://github.com/coinbase/agentkit/blob/main/python/examples/autogen-cdp-chatbot/README.md Verify that you have the correct versions of Python and uv installed before proceeding with the example. Python 3.10 or higher is required. ```bash python --version uv --version ``` -------------------------------- ### Install Dependencies Source: https://github.com/coinbase/agentkit/blob/main/python/examples/langchain-cdp-chatbot/README.md Install the necessary Python packages using uv. ```bash uv sync ``` -------------------------------- ### Install Dependencies and Build Project Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-cdp-smart-wallet-chatbot/README.md Install project dependencies and build the local AgentKit packages. ```bash npm install npm run build ``` -------------------------------- ### Complete AgentKit Example with CdpSmartWalletProvider Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/README.md Demonstrates initializing AgentKit with CdpSmartWalletProvider and various action providers. ```python from coinbase_agentkit import ( AgentKit, AgentKitConfig, CdpSmartWalletProvider, CdpSmartWalletProviderConfig, cdp_api_action_provider, cdp_smart_wallet_action_provider, erc20_action_provider, pyth_action_provider, wallet_action_provider, weth_action_provider, ) # Initialize the wallet provider wallet_provider = CdpSmartWalletProvider(CdpSmartWalletProviderConfig( api_key_id="CDP API KEY ID", api_key_secret="CDP API KEY SECRET", wallet_secret="CDP WALLET SECRET", owner="OWNER_PRIVATE_KEY_OR_SERVER_WALLET_ADDRESS", network_id="base-sepolia", )) # Create AgentKit instance with wallet and action providers agentkit = AgentKit(AgentKitConfig( wallet_provider=wallet_provider, action_providers=[ cdp_api_action_provider(), cdp_smart_wallet_action_provider(), erc20_action_provider(), pyth_action_provider(), wallet_action_provider(), weth_action_provider(), ], )) ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/coinbase/agentkit/blob/main/python/examples/langchain-cdp-smart-wallet-chatbot/README.md Install all necessary project dependencies using the uv package manager. Ensure uv is installed first. ```bash uv install ``` -------------------------------- ### Complete AgentKit Example with CdpSolanaWalletProvider Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/README.md This example demonstrates a full integration of CdpSolanaWalletProvider with AgentKit. It initializes the wallet provider for the Solana devnet and sets up AgentKit with basic wallet operations. ```python from coinbase_agentkit import ( AgentKit, AgentKitConfig, CdpSolanaWalletProvider, CdpSolanaWalletProviderConfig, wallet_action_provider, ) # Initialize the wallet provider wallet_provider = CdpSolanaWalletProvider(CdpSolanaWalletProviderConfig( api_key_id="CDP API KEY ID", api_key_secret="CDP API KEY SECRET", wallet_secret="CDP WALLET SECRET", network_id="solana-devnet", )) # Create AgentKit instance with wallet and action providers agentkit = AgentKit(AgentKitConfig( wallet_provider=wallet_provider, action_providers=[ wallet_action_provider(), # Provides basic wallet operations for Solana ], )) # The wallet provider supports: # - Getting wallet address: wallet_provider.get_address() # - Getting SOL balance: wallet_provider.get_balance() # - Transferring SOL: wallet_provider.native_transfer(to, amount) # - Signing messages: wallet_provider.sign_message(message) ``` -------------------------------- ### Generate Evm Action Provider with Wallet Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/scripts/generate-action-provider/README.md Example of creating an Evm action provider named 'example' and specifying 'CdpWalletProvider' as the wallet provider. ```bash pnpm run generate:action-provider -- -n example -p evm -w CdpWalletProvider ``` -------------------------------- ### Generate Evm Action Provider Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/scripts/generate-action-provider/README.md Example of creating a new action provider named 'example' specifically for Evm networks. ```bash pnpm run generate:action-provider -- -n example -p evm ``` -------------------------------- ### Install Dependencies and Build Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-8004-cdp-chatbot/README.md Install project dependencies using pnpm and build the project. These commands are run from the root directory. ```bash pnpm install pnpm build ``` -------------------------------- ### Environment Variables Example Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-dtelecom-voice-agent-example/README.md Example of the .env file content, including API keys and network configuration. ```dotenv OPENAI_API_KEY=sk-... CDP_API_KEY_ID=... CDP_API_KEY_SECRET=... CDP_WALLET_SECRET=... NETWORK_ID=base-mainnet ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-dtelecom-voice-agent-example/README.md Copy the example environment file and fill in your API keys and credentials. ```bash cd examples/langchain-dtelecom-voice-agent-example cp .env-local .env ``` -------------------------------- ### Install AgentKit Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/README.md Install the AgentKit package using npm. Ensure Node.js v22+ is installed. ```bash npm install @coinbase/agentkit ``` -------------------------------- ### Install Dependencies Source: https://github.com/coinbase/agentkit/blob/main/python/examples/advertisements-agent-with-strands-agents-x402-cdp-chatbot/README.md Use uv to synchronize and install project dependencies as defined in the project's configuration. ```bash uv sync ``` -------------------------------- ### Install Dependencies with pip Source: https://github.com/coinbase/agentkit/blob/main/python/examples/strands-agents-cdp-server-chatbot/README.md Install the necessary Python packages using pip. ```bash pip install coinbase-agentkit coinbase-agentkit-strands-agents ``` -------------------------------- ### Install AgentKit and AI SDK Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/vercel-ai-sdk/README.md Install the core AgentKit and AI SDK packages required for integration. ```bash npm install @coinbase/agentkit ai ``` -------------------------------- ### Example x402 Service Discovery Response Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/coinbase_agentkit/action_providers/x402/README.md An example of a successful response from the `discover_x402_services` action, showing wallet networks, total services, returned count, and a list of services with their URL, price, and description. ```json { "success": true, "walletNetworks": ["base-sepolia", "eip155:84532"], "total": 150, "returned": 25, "services": [ { "url": "https://api.example.com/weather", "price": "0.001 USDC on base-sepolia", "description": "Get current weather data" } ] } ``` -------------------------------- ### Run Development Server Source: https://github.com/coinbase/agentkit/blob/main/typescript/create-onchain-agent/templates/next/README.md Start the Next.js development server to view your project locally. ```sh npm run dev ``` -------------------------------- ### Install AgentKit Vercel AI SDK Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/vercel-ai-sdk/README.md Install the main AgentKit Vercel AI SDK package. ```bash npm install @coinbase/agentkit-vercel-ai-sdk ``` -------------------------------- ### Install AgentKit OpenAI Agents SDK Extension Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/openai-agents-sdk/README.md Install the required packages using pip. ```bash pip install coinbase-agentkit coinbase-agentkit-openai-agents-sdk ``` -------------------------------- ### Install Coinbase AgentKit and PydanticAI Extension Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/pydantic-ai/README.md Install the required packages using pip. Ensure you have Python package management set up. ```bash pip install coinbase-agentkit coinbase-agentkit-pydantic-ai ``` -------------------------------- ### SSH Command Example Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/coinbase_agentkit/action_providers/ssh/README.md Example SSH command to connect to a remote instance. Ensure the instance status is 'running' before attempting to connect. ```bash ssh ubuntu@positive-peach-goat.1.cricket.hyperbolic.xyz -p 31274 ``` -------------------------------- ### Install OpenAI provider for AI SDK Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/vercel-ai-sdk/README.md Install the OpenAI package to use OpenAI models with the AI SDK. ```bash npm install @ai-sdk/openai ``` -------------------------------- ### Basic Python Setup for AgentKit and Strands Agents Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/strands-agents/README.md Initialize AgentKit, retrieve Strands tools, configure a Bedrock model, and create a Strands Agent. This setup is for basic agentic workflows interacting with on-chain actions. ```python from coinbase_agentkit import AgentKit from coinbase_agentkit_strands_agents import get_strands_tools from strands.models import BedrockModel from strands import Agent agentKit = AgentKit() tools = get_strands_tools(agentKit) llm = BedrockModel( model_id="us.amazon.nova-pro-v1:0", region_name='us-east-1' ## set to the appropriate region with model access ) agent = Agent( model=llm, tools=tools, ) ``` -------------------------------- ### Install Latest Node.js Version Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-cdp-smart-wallet-chatbot/README.md Install the latest Node.js version using nvm if your current version is insufficient. ```bash nvm install node ``` -------------------------------- ### Build the Server Source: https://github.com/coinbase/agentkit/blob/main/typescript/create-onchain-agent/templates/mcp/README.md Execute this command to build the agent server after installing dependencies and configuring environment variables. ```sh npm run build ``` -------------------------------- ### Install AgentKit Vercel AI SDK and dependencies Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/vercel-ai-sdk/README.md Install the AgentKit Vercel AI SDK along with core AgentKit, AI SDK, and a model provider like OpenAI. ```bash npm install @coinbase/agentkit-vercel-ai-sdk @coinbase/agentkit ai @ai-sdk/openai ``` -------------------------------- ### List Registered Services Response Example Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/coinbase_agentkit/action_providers/x402/README.md Example response structure for the `list_registered_services` action, showing approved service URLs and dynamic registration status. ```json { "success": True, "registeredServices": [ "https://api.example.com", "https://weather.x402.io" ], "count": 2, "allowDynamicServiceRegistration": True } ``` -------------------------------- ### Add Wallet Address to Environment Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-dtelecom-voice-agent-example/README.md After running the example once, add the generated wallet address to your .env file. ```dotenv ADDRESS=0x... ``` -------------------------------- ### Run create-onchain-agent CLI in Beginner Mode Source: https://github.com/coinbase/agentkit/blob/main/python/create-onchain-agent/README.md Use the --beginner flag for a simplified chatbot setup with recommended configurations, ideal for new users. ```sh pipx run create-onchain-agent --beginner ``` -------------------------------- ### Check Node Version Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-privy-chatbot/README.md Verify that Node.js version 18 or higher is installed before proceeding with the example. ```bash node --version npm --version ``` -------------------------------- ### Basic AgentKit and OpenAI Agents SDK Setup Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/openai-agents-sdk/README.md Initialize AgentKit, retrieve OpenAI Agents SDK tools, and create an agent. Ensure necessary imports are included. ```python from coinbase_agentkit import AgentKit from coinbase_agentkit_openai_agents_sdk import get_openai_agents_sdk_tools from agents import Agent agentKit = AgentKit() tools = get_openai_agents_sdk_tools(agentKit) agent = Agent( name="CDP Agent", instructions="You are a helpful agent that can interact with the blockchain using AgentKit tools.", tools=tools ) ``` -------------------------------- ### Basic AgentKit LangChain Setup Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/langchain/README.md Initialize AgentKit and retrieve LangChain compatible tools. Then, set up a LangChain agent using an LLM and the obtained tools. ```python from coinbase_agentkit import AgentKit from coinbase_agentkit_langchain import get_langchain_tools agentKit = AgentKit() tools = get_langchain_tools(agentKit) llm = ChatOpenAI(model="gpt-4o-mini") agent = create_react_agent( llm=llm, tools=tools, ) ``` -------------------------------- ### Configure EthAccountWalletProvider with Private Key Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/README.md Example usage of EthAccountWalletProvider with a private key loaded from environment variables. Ensure the PRIVATE_KEY environment variable is set and starts with '0x'. ```python import os from eth_account import Account from coinbase_agentkit import ( AgentKit, AgentKitConfig, EthAccountWalletProvider, EthAccountWalletProviderConfig ) # See here for creating a private key: # https://web3py.readthedocs.io/en/stable/web3.eth.account.html#creating-a-private-key private_key = os.environ.get("PRIVATE_KEY") assert private_key is not None, "You must set PRIVATE_KEY environment variable" assert private_key.startswith("0x"), "Private key must start with 0x hex prefix" account = Account.from_key(private_key) wallet_provider = EthAccountWalletProvider( config=EthAccountWalletProviderConfig( account=account, chain_id="84532", ) ) agent_kit = AgentKit(AgentKitConfig( wallet_provider=wallet_provider )) ``` -------------------------------- ### Install AgentKit Autogen Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/autogen/README.md Install the necessary AgentKit and Autogen packages using pip. Ensure you have Python and pip installed. ```bash pip install coinbase-agentkit coinbase-agentkit-autogen ``` -------------------------------- ### Install Pipx with Specific Python Version Source: https://github.com/coinbase/agentkit/blob/main/python/create-onchain-agent/README.md Use this command to install pipx with a specific Python version, especially if multiple Python versions are installed on your system. ```sh python3.10 -m pip install --user pipx python3.10 -m pipx ensurepath ``` -------------------------------- ### Install Dependencies Source: https://github.com/coinbase/agentkit/blob/main/typescript/examples/langchain-dtelecom-voice-agent-example/README.md Install project dependencies from the root of the typescript workspace. ```bash cd typescript pnpm install ``` -------------------------------- ### Initialize ViemWalletProvider Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/README.md Set up a `ViemWalletProvider` by creating a Viem wallet client. This provider is suitable for interacting with any EVM-compatible chain using Viem. ```typescript import { ViemWalletProvider } from "@coinbase/agentkit"; import { privateKeyToAccount } from "viem/accounts"; import { baseSepolia } from "viem/chains"; import { http } from "viem/transports"; import { createWalletClient } from "viem"; const account = privateKeyToAccount( "0x4c0883a69102937d6231471b5dbb6208ffd70c02a813d7f2da1c54f2e3be9f38", ); const client = createWalletClient({ account, chain: baseSepolia, transport: http(), }); const walletProvider = new ViemWalletProvider(client); ``` -------------------------------- ### Wallet Get Balance Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/README.md Gets the native currency balance of the connected wallet. ```APIDOC ## Wallet Get Balance ### Description Gets the native currency balance of the connected wallet. ### Method GET ### Endpoint /wallet/balance ``` -------------------------------- ### Install AgentKit LangChain Dependencies Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/langchain/README.md Install the necessary packages for the AgentKit LangChain extension and its dependencies. ```bash npm install @coinbase/agentkit-langchain @coinbase/agentkit langchain @langchain/langgraph @langchain/openai ``` -------------------------------- ### Basic AgentKit Autogen Setup Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/autogen/README.md Initialize AgentKit, configure an OpenAI client, retrieve Autogen tools, and set up an AssistantAgent. This snippet demonstrates the core components for an agentic workflow. ```python from coinbase_agentkit import AgentKit from coinbase_agentkit_autogen import get_autogen_tools from autogen_ext.models.openai import OpenAIChatCompletionClient from autogen_agentchat.agents import AssistantAgent from autogen_agentchat.ui import Console agentKit = AgentKit() model_client = OpenAIChatCompletionClient(model="gpt-4o-mini") tools = get_autogen_tools(agentKit) agent = AssistantAgent( name="assistant", model_client=model_client, tools=tools, system_message="You are a helpful agent" ) async def main() -> None: await Console(agent.run_stream(task="Show me my wallet information.")) await model_client.close() await main() ``` -------------------------------- ### Basic AgentKit MCP Setup Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/model-context-protocol/README.md Set up a basic AgentKit server with Model Context Protocol (MCP) capabilities. This involves initializing AgentKit, retrieving MCP tools, configuring the server to handle tool listing and calling requests, and connecting to a transport. ```typescript import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js"; import { getMcpTools } from "@coinbase/agentkit-model-context-protocol"; import { AgentKit } from "@coinbase/agentkit"; const agentKit = await AgentKit.from({ cdpApiKeyId: "CDP API KEY NAME", cdpApiKeySecret: "CDP API KEY SECRET", }); const { tools, toolHandler } = await getMcpTools(agentKit); const server = new Server( { name: "agentkit", version: "0.1.0", }, { capabilities: { tools: {}, }, }, ); server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools, }; }); server.setRequestHandler(CallToolRequestSchema, async (request) => { try { return toolHandler(request.params.name, request.params.arguments); } catch (error) { throw new Error(`Tool ${name} failed: ${error}`); } }); const transport = new StdioServerTransport(); await server.connect(transport); ``` -------------------------------- ### Install AgentKit MCP Dependencies Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/model-context-protocol/README.md Install the necessary packages for the AgentKit Model Context Protocol extension. ```bash npm install @coinbase/agentkit-model-context-protocol @coinbase/agentkit @modelcontextprotocol/sdk ``` -------------------------------- ### Example Usage of CdpEvmWalletProvider with AgentKit Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/README.md Initialize AgentKit with CdpEvmWalletProvider and various action providers for comprehensive functionality. Ensure correct network and API credentials are used. ```python from coinbase_agentkit import ( AgentKit, AgentKitConfig, CdpEvmWalletProvider, CdpEvmWalletProviderConfig, cdp_api_action_provider, cdp_evm_wallet_action_provider, erc20_action_provider, pyth_action_provider, wallet_action_provider, weth_action_provider, ) # Initialize the wallet provider wallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig( api_key_id="CDP API KEY ID", api_key_secret="CDP API KEY SECRET", wallet_secret="CDP WALLET SECRET", network_id="base-sepolia", )) # Create AgentKit instance with wallet and action providers agentkit = AgentKit(AgentKitConfig( wallet_provider=wallet_provider, action_providers=[ cdp_api_action_provider(), cdp_evm_wallet_action_provider(), erc20_action_provider(), pyth_action_provider(), wallet_action_provider(), weth_action_provider(), ], )) ``` -------------------------------- ### Install AgentKit LangChain Extension Source: https://github.com/coinbase/agentkit/blob/main/python/framework-extensions/langchain/README.md Install the necessary packages for the AgentKit LangChain extension using pip. ```bash pip install coinbase-agentkit coinbase-agentkit-langchain ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/coinbase/agentkit/blob/main/python/examples/langchain-cdp-solana-chatbot/README.md Set up your environment variables by creating a .env file. This includes API keys for CDP and OpenAI, and network configuration. ```bash CDP_API_KEY_ID=[your CDP API Key ID from https://portal.cdp.coinbase.com/access/api] CDP_API_KEY_SECRET=[your CDP API Secret Key from https://portal.cdp.coinbase.com/access/api] CDP_WALLET_SECRET=[your CDP Wallet Secret Key from https://portal.cdp.coinbase.com/access/api] OPENAI_API_KEY=[your OpenAI API Key from https://platform.openai.com/docs/quickstart#create-and-export-an-api-key] NETWORK_ID=solana-devnet ``` -------------------------------- ### Basic AgentKit LangChain Setup Source: https://github.com/coinbase/agentkit/blob/main/typescript/framework-extensions/langchain/README.md Initialize AgentKit and LangChain components to create a basic agent. Ensure you have your CDP API keys and OpenAI API key set up. ```typescript import { getLangChainTools } from "@coinbase/agentkit-langchain"; import { createAgent } from "langchain"; import { ChatOpenAI } from "@langchain/openai"; import { AgentKit } from "@coinbase/agentkit"; const agentKit = await AgentKit.from({ cdpApiKeyId: "CDP API KEY NAME", cdpApiKeySecret: "CDP API KEY SECRET", }); const tools = await getLangChainTools(agentKit); const llm = new ChatOpenAI({ model: "gpt-4o-mini", }); const agent = createAgent({ model: llm, tools, }); ``` -------------------------------- ### Initialize X402ActionProvider with Configuration Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/coinbase_agentkit/action_providers/x402/README.md Initialize the X402ActionProvider with a custom configuration object. This allows setting registered services, dynamic registration permissions, facilitators, and payment limits. ```python from coinbase_agentkit.action_providers.x402 import x402_action_provider, X402Config config = X402Config( # Service URLs the agent can call (whitelist) registered_services=[ "https://api.example.com", "https://weather.x402.io" ], # Allow agent to register new services at runtime # Default: False (or X402_ALLOW_DYNAMIC_SERVICE_REGISTRATION="true" env var) allow_dynamic_service_registration=True, # Custom facilitators for service discovery registered_facilitators={ "myFacilitator": "https://my-facilitator.com" }, # Maximum payment per request in USDC # Default: 1.0 (or X402_MAX_PAYMENT_USDC env var) max_payment_usdc=0.5 ) provider = x402_action_provider(config) ``` -------------------------------- ### Initialize AgentKit with Wallet Provider Source: https://context7.com/coinbase/agentkit/llms.txt Sets up the AgentKit with a specified wallet provider and configuration. Ensure environment variables for API keys and secrets are set. ```python wallet_provider = CdpEvmWalletProvider(CdpEvmWalletProviderConfig( api_key_id=os.getenv("CDP_API_KEY_ID"), api_key_secret=os.getenv("CDP_API_KEY_SECRET"), wallet_secret=os.getenv("CDP_WALLET_SECRET"), network_id="base-sepolia", )) agent_kit = AgentKit(AgentKitConfig( wallet_provider=wallet_provider, action_providers=[ wallet_action_provider(), erc20_action_provider(), cdp_api_action_provider(), morpho_action_provider(), x402_action_provider(X402Config( registered_services=["https://www.x402.org/protected"], max_payment_usdc=1.0, )), ], )) ``` -------------------------------- ### Chatbot Interaction Example Source: https://github.com/coinbase/agentkit/blob/main/README.md Example interaction with the chatbot, demonstrating a request to fund a wallet and the subsequent transaction confirmation. ```bash Prompt: Fund my wallet with some testnet ETH. ------------------- Wallet: ccaf1dbf-3a90-4e52-ad34-89a07aad9e8b on network: base-sepolia with default address: 0xD9b990c7b0079c1c3733D2918Ee50b68f29FCFD5 ------------------- ------------------- Received eth from the faucet. Transaction: https://sepolia.basescan.org/tx/0x03e82934cd04be5b725927729b517c606f6f744611f0f36e834f21ad742ad7ca ------------------- Your wallet has been successfully funded with testnet ETH. You can view the transaction [here](https://sepolia.basescan.org/tx/0x03e82934cd04be5b725927729b517c606f6f744611f0f36e834f21ad742ad7ca). ------------------- ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/coinbase/agentkit/blob/main/python/examples/advertisements-agent-with-strands-agents-x402-cdp-chatbot/README.md Copy the example .env file and edit it with your specific API keys and wallet information. Ensure all required variables for CDP, OpenWeather, and AWS (or Bedrock API keys) are correctly set. ```bash cp .env.local .env # Edit .env with your configuration: # - CDP_API_KEY_ID, CDP_API_KEY_SECRET, CDP_WALLET_SECRET (Coinbase testnet) # - ADDRESS (Base Sepolia testnet receiving address) # - OPENWEATHER_API_KEY # - AWS_ACCESS_KEY_ID # - AWS_SECRET_ACCESS_KEY # - AWS_REGION ``` -------------------------------- ### Initialize X402ActionProvider with Configuration Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/src/action-providers/x402/README.md Configure the X402ActionProvider with service URLs, payment limits, and dynamic registration settings. Ensure all service URLs are whitelisted or enable dynamic registration. ```typescript import { x402ActionProvider, X402Config } from "@coinbase/cdp-agentkit"; const config: X402Config = { // Service URLs the agent can call (whitelist) registeredServices: [ "https://api.example.com", "https://weather.x402.io" ], // Allow agent to register new services at runtime // Default: false (or X402_ALLOW_DYNAMIC_SERVICE_REGISTRATION="true" env var) allowDynamicServiceRegistration: true, // Custom facilitators for service discovery registeredFacilitators: { "myFacilitator": "https://my-facilitator.com" }, // Maximum payment per request in USDC // Default: 1.0 (or X402_MAX_PAYMENT_USDC env var) maxPaymentUsdc: 0.5 }; const provider = x402ActionProvider(config); ``` -------------------------------- ### Install Specific Nightly Build (TypeScript) Source: https://github.com/coinbase/agentkit/blob/main/README.md Installs a specific nightly build of AgentKit and the Langchain extension for TypeScript, identified by a date-based version string. ```bash npm install @coinbase/agentkit@0.2.3-nightly.20250220.0 @coinbase/agentkit-langchain@0.2.3-nightly.20250220.0 ``` -------------------------------- ### Install x402 Dependency Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/coinbase_agentkit/action_providers/x402/README.md Install the x402 library with requests support using pip. Ensure version 2.0.0 or higher is used for v2 API compatibility. ```bash pip install "x402[requests]>=2.0.0" ``` -------------------------------- ### Configure ZeroDevWalletProvider with ViemWalletProvider Source: https://github.com/coinbase/agentkit/blob/main/typescript/agentkit/README.md Configure `ZeroDevWalletProvider` using a `ViemWalletProvider` as the signer. This involves creating a Viem wallet client with a private key and chain, then passing its signer to `ZeroDevWalletProvider`. ```typescript import { ZeroDevWalletProvider, ViemWalletProvider } from "@coinbase/agentkit"; import { privateKeyToAccount } from "viem/accounts"; import { base } from "viem/chains"; import { createWalletClient, http } from "viem"; // First create a Viem wallet provider as the signer const account = privateKeyToAccount("PRIVATE_KEY"); const viemWalletProvider = new ViemWalletProvider( createWalletClient({ account, chain: base, transport: http(), }), ); // Configure ZeroDev Wallet Provider with Viem signer const walletProvider = await ZeroDevWalletProvider.configureWithWallet({ signer: viemWalletProvider.toSigner(), projectId: "ZERODEV_PROJECT_ID", entryPointVersion: "0.7" as const, networkId: "base-mainnet", }); ``` -------------------------------- ### Install AgentKit Nightly Build (TypeScript) Source: https://github.com/coinbase/agentkit/blob/main/README.md Installs the latest nightly build of AgentKit and the Langchain extension for TypeScript. Use the corresponding package if you are not using Langchain. ```bash npm install @coinbase/agentkit@nightly @coinbase/agentkit-langchain@nightly ``` -------------------------------- ### List Registered Facilitators Response Example Source: https://github.com/coinbase/agentkit/blob/main/python/coinbase-agentkit/coinbase_agentkit/action_providers/x402/README.md Example response structure for the `list_registered_facilitators` action, detailing available facilitators including known defaults and custom ones. ```json { "success": True, "facilitators": [ {"name": "cdp", "url": "https://...", "type": "known"}, {"name": "payai", "url": "https://...", "type": "known"}, {"name": "myFacilitator", "url": "https://...", "type": "custom"} ], "knownCount": 2, "customCount": 1, "totalCount": 3 } ```