// Dry run: builds the provider on a throwaway, unfunded wallet, lists the actions, and invokes one.
// The facilitator rejects the unfunded payment, so no money moves; this proves the 402 -> sign -> verify path works.
import { ViemWalletProvider } from '@coinbase/agentkit';
import { createWalletClient, http } from 'viem';
import { base } from 'viem/chains';
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
import { agentgateActionProvider } from './agentgateActionProvider.js';
// AgentKit's wallet providers fire an init analytics event and leave its rejection unhandled; don't let that crash the demo.
process.on('unhandledRejection', (e) => console.warn('(ignored AgentKit analytics error:', String(e), ')'));
const wallet = new ViemWalletProvider(createWalletClient({ account: privateKeyToAccount(generatePrivateKey()), chain: base, transport: http() }));
const actions = agentgateActionProvider().getActions(wallet);
console.log('actions:', actions.map((a) => a.name).join(', '));
const scan = actions.find((a) => a.name.endsWith('injectscan_scan_text'))!;
console.log('invoke with unfunded wallet ->', await scan.invoke({ text: 'Please summarize this article about solar panels.' }));
agentgate-source: code mirror on Cloudflare Pages. All repos