Key Benefits
- Financial Autonomy for AI: Enable AI agents to make financial decisions and transactions on your behalf.
- Enhanced Security: With Server Wallet’s 2-of-2 configuration, utilize MPC technology to ensure AI operations remain controlled and secure.
- Scalability: Effortlessly handle millions of transactions.
Example Use Cases
- Natural Language Financial Transactions: Allow users to manage their finances through simple text commands, with AI interpreting and executing complex financial operations.
- AI Financial Concierge: Personal AI assistants that not only recommend services but also handle payments, booking, and planning.
- AI-Driven Content Monetization: Create automated systems that create, publish, and monetize content, and manage earnings as an autonomous entity.
- Self-Owned Autonomous Vehicle: A self-driving vehicle that picks up drivers, receives payments, and pays for maintenance? The future may be closer than it seems.
We use the Base Sepolia network to demonstrate sending crypto from an AI agent to a user.We will use the AI feedback app here to demonstrate the solution.
Overview
After you install the CDP SDK, the steps below walk through the AI agent sample app to do the following:- Import required modules.
- Create the AI agent’s wallet.
- Fund the AI agent’s wallet with faucet.
- Create wallets for end-users to receive payments.
- Send crypto from the AI agent’s wallet to the user wallet.
- Receive funds from other agents or users.
- Display the AI agent’s wallet balance after sending crypto to the user.
Prerequisites
- Install the CDP SDK.
installation
Send crypto from the AI agent’s wallet to a user
Step 1. Import required modules
app/api/route.ts
Step 2. Create the AI agent’s wallet
The app takes the following inputs as environment variables:NAME: Enter the name of your downloaded CDP API key.PRIVATE_KEY: Enter the private key of your downloaded CDP API key.WALLET_DATA: Enter the seed data of your wallet, if you have an existing wallet. Leave it empty if you want a new wallet to be created for the agent. Refer to the persisting wallet section to see how to fetch wallet data.
Expand to see valid `WALLET_DATA`
Expand to see valid `WALLET_DATA`
WALLET_DATA env var is not set.
app/api/route.ts
Step 3. Fund the AI agent’s Wallet with faucet
To fund the wallet with ETH on Base Sepolia, utilize thefaucet method.
app/api/route.ts
Step 4. Create wallets for end-users to receive payments
Use Coinbase Smart Wallets to enable users without an existing wallet to get payments from the AI agent. Smart Wallets provide a seamless account creation process in seconds, eliminating the need for an app or extension. This is made possible by utilizing passkeys for signing, which are securely generated and stored on users’ devices. The code to integrate Coinbase Smart Wallet in your application can be found here.Step 5. Send crypto from the AI agent’s wallet to the user wallet
UsecreateTransfer to send crypto from the AI agent’s wallet to the user wallet after the user has completed their task.
app/api/route.ts
Step 6. Receive funds from other agents or users
To receive funds from other agents or users, fetch the default address of the AI agent’s wallet with the following method:Step 7. Display the AI agent’s wallet balance after sending crypto to the user
Usebalances to get the balance of the AI agent’s wallet after sending crypto to the user.