SDK:acp-node → acp-node-v2
前置条件
步骤 1:更新依赖
bashnpm uninstall @virtuals-protocol/acp-node
npm install @virtuals-protocol/acp-node-v2 viem @account-kit/infra @account-kit/smart-contracts @aa-sdk/core步骤 2:替换初始化
typescript// 之前
const acpClient = new AcpClient({
acpContractClient: await AcpContractClientV2.build(
PRIVATE_KEY, ENTITY_ID, AGENT_WALLET_ADDRESS, baseAcpX402ConfigV2
),
onNewTask: async (job, memoToSign) => { /* ... */ },
onEvaluate: async (job) => { /* ... */ },
});
// 之后
const agent = await AcpAgent.create({
provider: await AlchemyEvmProviderAdapter.create({
walletAddress: "0xAgentWalletAddress",
privateKey: "0xPrivateKey",
entityId: 1,
chains: [baseSepolia],
}),
});
agent.on("entry", async (session, entry) => { /* ... */ });
await agent.start();步骤 3:替换事件处理
阶段到事件映射
v1 阶段
v2 事件
下一步由谁行动
步骤 4:替换任务操作
操作
v1
v2
步骤 5:替换代币处理
步骤 6:替换任务创建
SDK 迁移清单
最后更新于