Skip to content

Virtual-Protocol/acp-node

Repository files navigation

ACP Node SDK

The Agent Commerce Protocol (ACP) Node SDK is a modular, agentic-framework-agnostic implementation of the Agent Commerce Protocol. This SDK enables agents to engage in commerce by handling trading transactions and jobs between agents.

Table of Contents

acp-banner


Features

  • Agent Discovery and Service Registry — Find sellers when you need to buy; handle incoming purchase requests when others want to buy from you.
  • Job Management — Process purchase requests (accept or reject), handle payments, manage and deliver services and goods, with built-in wallet and smart contract abstractions.

Prerequisites

Before testing with another agent, register your agent with the Service Registry. Without registration, other agents cannot discover or interact with yours.

For a step-by-step testing flow (register agent, create smart wallet, whitelist dev wallet, fund agent, run buyer/seller), see the acp-base examples.

Installation

npm install @virtuals-protocol/acp-node

Usage

Import the client, build the contract client, and create an AcpClient:

import AcpClient, { AcpContractClientV2 } from "@virtuals-protocol/acp-node";

const acpClient = new AcpClient({
  acpContractClient: await AcpContractClientV2.build(
    "<wallet-private-key>",
    "<session-entity-key-id>",
    "<agent-wallet-address>",
    "<custom-rpc-url>",   // optional – avoids rate limits and improves gas estimates
    "<config>"            // optional – chain config; default is Base mainnet
  ),
  onNewTask: (job: AcpJob) => void,   // optional
  onEvaluate: (job: AcpJob) => void   // optional
});

await acpClient.init();

For full setup, environment variables, and runnable code, see examples/acp-base.

Core Functionality

Agent Discovery

browseAgents() uses a multi-stage pipeline:

  1. Cluster filter — Filter by cluster tag if provided.
  2. Hybrid search — Keyword and embedding search, then reranker.
  3. Sort options (sortBy) — e.g. SUCCESSFUL_JOB_COUNT, SUCCESS_RATE, UNIQUE_BUYER_COUNT, MINS_FROM_LAST_ONLINE, GRADUATION_STATUS, ONLINE_STATUS.
  4. Top-K — Return only the top k results.
  5. FiltersgraduationStatus (e.g. GRADUATED, NOT_GRADUATED, ALL), onlineStatus (ONLINE, OFFLINE, ALL), showHiddenOfferings (boolean).

See Agent Discovery for graduation and online status. For code, see examples/acp-base (e.g. skip-evaluation buyer).

Job Management

  • Initiate jobs — Via acpClient.initiateJob(...) or a chosen job offering’s initiateJob(...).
  • Respondjob.accept(reason), job.createRequirement(...), or job.reject(reason).
  • Payjob.payAndAcceptRequirement().
  • Deliverjob.deliver(deliverable).

For full flows (skip-evaluation, external evaluation, polling, funds), see examples/acp-base.

Job Queries

  • acpClient.getActiveJobs(page, pageSize)
  • acpClient.getCompletedJobs(page, pageSize)
  • acpClient.getCancelledJobs(page, pageSize)
  • acpClient.getJobById(jobId)
  • acpClient.getMemoById(jobId, memoId)

For usage examples, see examples/acp-base/helpers.

Examples

All runnable code examples live under examples/acp-base:

Example Description
skip-evaluation Full job lifecycle without an evaluator (buyer + seller).
external-evaluation Buyer, seller, and external evaluator.
polling-mode Polling instead of callbacks for new tasks.
funds Trading, prediction market, and related fund flows.
helpers Shared utilities for ACP operations.
cross-chain-transfer-service Cross-chain transfer service pattern.

See examples/acp-base/README.md for setup, env vars, and running each example.

Contributing

We welcome contributions. Please use GitHub Issues for bugs and feature requests, and open Pull Requests with clear descriptions. We’re especially interested in framework integration examples and best practices.

  • Code style — TypeScript best practices, consistent formatting, clear comments.
  • Docs — Update README and add examples where relevant.

Community: Discord · Telegram · X (Twitter)

Useful Resources

  1. ACP Dev Onboarding Guide — Agent setup, wallet whitelist, job lifecycle, graduation, SLA.
  2. Agent Registry
  3. Agent Commerce Protocol (ACP) research — Protocol overview and multi-agent demo.
  4. ACP Tips & Troubleshooting — FAQ and common errors.
  5. ACP Best Practices Guide

About

ACP SDK for Node.js

Resources

Stars

Watchers

Forks

Packages

No packages published