@agenticprimitives/contracts

中文文档
1.0.0-alpha.46发布于 2026/10/26MITTypeScriptES Module零依赖近 30 天下载 4812

Solidity contracts + ABIs + flattened sources + per-network deployment addresses for the agenticprimitives stack.

原始使用文档
文档目录8 节
  1. What's in src/
  2. How it's different
  3. Setup
  4. Deploy to Anvil
  5. Deploy to Base Sepolia
  6. Audit posture
  7. Status
  8. Incremental ontology scripts

@agenticprimitives/contracts

Part of Agentic Primitives — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. Developer kit · All packages

Contracts and SDK are one artifact.

This is the on-chain enforcement layer of the agenticprimitives substrate — 42 Solidity sources, all present and audited under src/, none of them stubs. ERC-4337 v0.7 Smart Agent core, ERC-7710-style delegation manager with caveat enforcers, an ERC-7579 modular CustodyPolicy, a three-mode paymaster, .agent TLD naming with hierarchical subregistries, ontology and profile resolvers, identity facets, and an ERC-6492-aware UniversalSignatureValidator. The package publishes ABI subpaths, per-network deployment JSON, flattened sources, and the Solidity itself — so a TypeScript consumer pulls addresses and ABIs from the same artifact the auditors read.

"One artifact" is CI-enforced, not aspirational: TypeScript typehashes are locked to the Solidity constants (pnpm check:eip712-typehash-equality), ABIs are sync-gated, and storage layouts are snapshot-gated (pnpm check:storage-layouts). You cannot drift the client from the chain.

Part of agenticprimitives — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.

What's in src/

  • AgentAccount.sol — UUPSUpgradeable + ERC-7579 + ERC-1271 + WebAuthn-supporting Smart Agent; a thin modular core where custody, threshold, and session machinery are modules, not inlined features
  • AgentAccountFactory.sol — CREATE2 deterministic deploys; salt from auth methods + scope (NEVER from a name)
  • SmartAgentPaymaster.sol — verifying-paymaster + allowlist + devMode (testnet only) modes
  • agency/DelegationManager.sol + enforcers/{AllowedMethods,AllowedTargets,Timestamp,Value,Quorum,CallDataHash}Enforcer.sol — scoped delegation with on-chain caveat enforcement
  • custody/CustodyPolicy.sol — 16-action ERC-7579 module, T4/T5/T6 quorum tiers + 24h default T5 timelock
  • naming/{AgentNameRegistry,AgentNameUniversalResolver,AgentNameAttributeResolver,PermissionlessSubregistry}.sol
  • identity/AgentProfileResolver.sol + ontology/{OntologyTermRegistry,ShapeRegistry,AttributeStorage}.sol
  • relationships/{AgentRelationship,RelationshipTypeRegistry}.sol (⚠ Privacy Fork — experimental surface; see AUDIT.md § 3.9)
  • governance/{AgenticGovernance,GovernanceManaged}.sol — system pause + governance base
  • libraries/{WebAuthnLib,P256Verifier,SignatureSlotRecovery,MultiSendCallOnly}.sol — security-critical primitives
  • UniversalSignatureValidator.sol — single signature entrypoint (ERC-6492 + ERC-1271 + raw ECDSA fanout per spec 214 SB-4)
  • ApprovedHashRegistry.sol — v=1 pre-approved hash signature path

Behind it: 774 Foundry tests including invariant suites, plus Halmos symbolic proofs, Echidna and Medusa fuzzing campaigns, and PR-blocking static analysis (Slither, Aderyn, CodeQL, Solhint).

Deployed addresses (Base Sepolia testnet): deployments-base-sepolia.json — committed, public, and surfaced to TypeScript consumers via the generated @agenticprimitives/contracts/deployments/base-sepolia subpath.

How it's different

Compared to Safe, ZeroDev, or Alchemy's contract stacks, the difference is scope and coupling. Those projects ship an account (and ship it well); the rest of the trust chain — who the account is, what it may delegate, how custody recovers it — is left to integrations with other vendors' contracts. Here the account, delegation manager, caveat enforcers, custody module, naming registry, and signature validator are designed and audited as one system, sharing one identity anchor. There is no third-party multi-sig dependency: custody quorums are our own ERC-7579 module, with Safe-style signature packing ported as a pattern rather than inherited as a runtime dependency. And the consumption model is different — most contract suites hand you addresses and a block explorer link; this package hands you versioned ABIs, deployments, and flattened sources as npm subpaths, CI-locked to the TypeScript SDK that consumes them.

Setup

First time only:

bash setup.sh    # clones OpenZeppelin, forge-std, account-abstraction into lib/
forge build

setup.sh is idempotent. It clones into lib/ (gitignored) rather than using git submodule add so this repo doesn't take a submodule dependency.

Deploy to Anvil

# Start Anvil in another terminal
anvil

# Then in this directory:
pnpm deploy:anvil

Writes deployed addresses to deployments-anvil.json. The demo apps (apps/demo-web, apps/demo-a2a, apps/demo-mcp) read this file on startup.

Deploy to Base Sepolia

export BASE_SEPOLIA_RPC=https://sepolia.base.org
export PRIVATE_KEY=0x...     # funded deployer
pnpm deploy:base-sepolia

Writes to deployments-base-sepolia.json. CI and hosted deploys read this. Demo idle cost: ~$0.

Audit posture

Trust infrastructure should be the most transparent code you depend on, so the audit trail is public by default:

Status

Testnet/pilot-ready. Production launch is gated on the public checklist in the root README — including third-party contract audit and governance key rotation. Track every security finding live in docs/audits/findings.yaml.

Production deployment is deliberately deferred: the testnet uses a publicly disclosed deployer EOA on purpose (it keeps the demo reproducible). The production rotation runbook is AUDIT.md § 4.1.

Incremental ontology scripts

ScriptAddsNotes
script/AddAgentTypeRoots.s.soltyped roots + atl:AgentTypeEnum members (spec 346)one PermissionlessSubregistry per root
script/AddVerticalRoots.s.solapp-registered vertical roots + atl:agentSubtype (spec 346 §2.4)vocabulary is the app's
script/AddDistributionPredicate.s.solatl:distribution (string JSON per AgentDistributionV1, spec 347 §8.5)idempotent; run 2026-08-30 on faithchain (34348) + Base Sepolia
script/AddCardPredicates.s.solatl:cardDigest (bytes32) + atl:cardUri (string) (spec 347 §8.3); UPDATE_SHAPE=true refreshes atl:AgentName to shape v2 (14 props)idempotent; run 2026-08-30 on faithchain (34348) + Base Sepolia

版本与发布记录

@agenticprimitives/contracts 共发布 45 个版本,首次发布于 2026/06/01;过去 12 个月发布了 45 个版本。

版本发布日期距今
1.0.0-alpha.46latest2026/10/2612 天前
1.0.0-alpha.452026/10/2612 天前
1.0.0-alpha.442026/10/1721 天前
1.0.0-alpha.432026/10/1722 天前
1.0.0-alpha.422026/10/1622 天前
1.0.0-alpha.412026/10/1622 天前

其他发布通道:alpha → 0.1.0-alpha.2。

关于 @agenticprimitives/contracts 的常见问题

@agenticprimitives/contracts 是什么?

Solidity contracts + ABIs + flattened sources + per-network deployment addresses for the agenticprimitives stack.

如何安装 @agenticprimitives/contracts?

在项目目录运行 npm install @agenticprimitives/contracts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:viem(^2.52.2)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@agenticprimitives/contracts 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agenticprimitives/contracts 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agenticprimitives/contracts 可以商用吗?

@agenticprimitives/contracts 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@agenticprimitives/contracts 的下载量有多少?

根据 npm 官方下载统计,@agenticprimitives/contracts 在 2026/10/05 – 2026/11/03 这 30 天内被下载 4,812 次,日均约 160 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agenticprimitives/contracts 还在维护吗?

最新版本 1.0.0-alpha.46 发布于 2026/10/26(12 天前);至今共发布 45 个版本,其中过去 12 个月发布了 45 个;首次发布于 2026/06/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。