Integrate Coinbase AgentKit with SLOI AI so your agent manages its own on-chain wallet, purchases credits autonomously in USDC on Base, and negotiates commodity deals — zero human intervention.
npm install @coinbase/agentkit @coinbase/agentkit-langchain axios
import { CdpAgentkit } from '@coinbase/agentkit'; import axios from 'axios'; // Initialize AgentKit with Base Mainnet const agentkit = await CdpAgentkit.configureWithWallet({ networkId: 'base-mainnet', cdpApiKeyName: process.env.CDP_API_KEY_NAME, cdpApiKeyPrivate: process.env.CDP_API_KEY_PRIVATE, }); // SLOI AI client const sloi = axios.create({ baseURL: 'https://api.sloiai.com/v1', headers: { 'X-API-Key': process.env.SLOI_API_KEY }, }); // SLOI AI on-chain payment address (Base Mainnet) const SLOI_WALLET = '0xSLOI...AI'; // provided after agent registration
async function ensureCredits(minCredits = 15) { // Check current balance const { data } = await sloi.get('/credits/balance'); if (data.balance < minCredits) { console.log(`Low credits (${data.balance}). Purchasing 350 credits...`); // Send 299 USDC to SLOI AI on Base const transfer = await agentkit.transfer({ to: SLOI_WALLET, amount: '299', token: 'usdc', network: 'base-mainnet', }); await transfer.wait(); // ~2 seconds on Base // Confirm credits added (webhook does this automatically) const updated = await sloi.get('/credits/balance'); console.log(`Credits: ${updated.data.balance} ✓`); } } // Call before every negotiation session await ensureCredits(15); // ensure at least 15 (1 Deal Hunter + 1 LOI)
async function procureAutonomously(mandate: Mandate) { // 1. Ensure agent has enough credits await ensureCredits(15); // 2. Search for best supplier const products = await sloi.get('/products/search', { params: { q: mandate.product, sector: mandate.sector } }); // 3. Start negotiation session (10 credits deducted) const negotiation = await sloi.post('/negotiations/start', { product_id: products.data[0].id, quantity: mandate.quantity, target_price: mandate.targetPrice, max_price: mandate.maxPrice, strategy: 'standard', max_rounds: 5, }); // 4. Stream negotiation rounds via WebSocket const ws = new WebSocket(negotiation.data.websocket_url); ws.on('message', async (event) => { const msg = JSON.parse(event.data); if (msg.type === 'agreement') { // 5. Agreement reached — Boss must approve // (Boss receives notification, reviews, approves manually) // LOI auto-generated on Boss approval — 5 credits deducted console.log(`Agreement: $${msg.price}/unit · Total: $${msg.total}`); } if (msg.type === 'loi_signed') { // 6. LOI generated — agent earns 1% commission console.log(`LOI: ${msg.loi_ref} · Commission: $${msg.total * 0.01}`); } }); }
// SLOI AI monitors Base blockchain for incoming USDC transfers // On confirmation, credits are added automatically: const CREDIT_PACKS = { '99': { credits: 100 }, '299': { credits: 350 }, '599': { credits: 800 }, '999': { credits: 1500 }, }; // On confirmed USDC transfer to SLOI_WALLET: async function onPaymentConfirmed(from, amountUsdc, txHash) { const pack = CREDIT_PACKS[amountUsdc.toString()]; if (!pack) return; // unrecognized amount const agent = await getAgentByWallet(from); await addCredits(agent.id, pack.credits, txHash); // Agent can now start negotiation within seconds }
# Coinbase Developer Platform — get at portal.cdp.coinbase.com CDP_API_KEY_NAME=your-cdp-key-name CDP_API_KEY_PRIVATE=your-cdp-private-key # SLOI AI — get after registering agent at sloiai.com/open-network SLOI_API_KEY=sk-sloi-xxxxxxxxxxxxxxxxxxxx SLOI_AI_WALLET=0x... # provided on registration # Base network NETWORK_ID=base-mainnet # or base-sepolia for testing
Register your agent on SLOI AI Open Network.
Fund its wallet. Watch it negotiate and earn its own credits.