@ar.io/solana-contracts

中文文档
1.5.0发布于 2026/10/09AGPL-3.0-or-laterTypeScriptES Module构建来源已验证近 30 天下载 2866

TypeScript client for the AR.IO Solana programs (ario-core, ario-gar, ario-arns, ario-ant, ario-ant-escrow). Codama-generated per-program clients plus hand-written helpers for things the IDL doesn't expose (e.g. the ANT-escrow canonical-message builders s

原始使用文档
文档目录10 节
  1. Install
  2. Use
  3. What is this?
  4. Versioning
  5. Cluster coupling (resolved — ADR-024)
  6. Local dev
  7. Publishing
  8. First publish (chicken-and-egg)
  9. Dist-tags
  10. License

@ar.io/solana-contracts

Codama-generated TypeScript client for the AR.IO Solana programs.

ProgramSubpath
ario-core (ARIO SPL token, vaults, primary names)@ar.io/solana-contracts/core
ario-gar (Gateway Address Registry, staking, epochs, rewards)@ar.io/solana-contracts/gar
ario-arns (ArNS name registry, demand factor, pricing)@ar.io/solana-contracts/arns
ario-ant (Arweave Name Token — Metaplex Core NFT)@ar.io/solana-contracts/ant
ario-ant-escrow (trustless multi-protocol ANT custody)@ar.io/solana-contracts/ant-escrow

Built on @solana/kit (peer dependency). Generated with Codama.

Install

yarn add @ar.io/solana-contracts @solana/kit
# or
npm install @ar.io/solana-contracts @solana/kit

Use

import { getBalanceEncoder } from '@ar.io/solana-contracts/core';
import { PurchaseType }      from '@ar.io/solana-contracts/arns';
import { GatewayStatus }     from '@ar.io/solana-contracts/gar';

const bytes = getBalanceEncoder().encode({
  owner: '...',
  amount: 1_000_000n,
  bump: 254,
});

Each subpath exposes Codama's standard surface:

  • accounts/ — typed encoders/decoders for every PDA (getBalanceEncoder, getBalanceDecoder, getBalanceCodec, etc.)
  • types/ — instruction-argument structs + enums (PurchaseType, GatewayStatus, Protocol)
  • instructions/ — async / sync instruction builders (getJoinNetworkInstructionAsync, etc.)
  • pdas/ — PDA derivation helpers (findBalancePda, etc.)
  • errors/ — typed Anchor error constants per program
  • programs/ — Codama's program factory + identify*Instruction helpers

What is this?

The AR.IO Network's on-chain programs run on Solana. They live in this repo under programs/; this package is the auto-generated TypeScript client that downstream consumers (the public AR.IO SDK, third-party integrators) import from.

Generated artifacts (src/<program>/ + lib/) are not committed — every release runs anchor build && yarn codegen && yarn build from a clean checkout and publishes the resulting tarball.

Versioning

Independent semver. Wire-format changes in the underlying Anchor programs (IDL-affecting source edits) bump the major. Additive surface changes bump the minor. Patch versions cover non-breaking codegen fixes.

The package version is not locked to the deployed program version — program identity is given by the chain-deployed program IDs, not by the client package version.

Cluster coupling (resolved — ADR-024)

Historically two zero-copy registry accounts used #[cfg(feature = "devnet-shrunk")] to swap fixed-array sizes between mainnet and a shrunk devnet, so the Codama encoders (which embed those sizes at codegen time) only matched one cluster at a time.

That feature was retired (ADR-024). Every cluster — localnet, staging (on Solana devnet), and mainnet — now compiles the same production-sized registries:

AccountAll clusters
GatewayRegistry.gateways3,000 slots
NameRegistry.names50,000 slots (expandable to 200,000)
Epoch.failure_counts3,000 slots

So a single published package matches every deploy — there is no encoder/account-size mismatch to reason about, and the staging vs @latest dist-tags differ only by release channel, not by encoded sizes.

Local dev

git clone https://github.com/ar-io/ar-io-solana-contracts.git
cd ar-io-solana-contracts
anchor build              # produces target/idl/*.json
cd clients/ts
yarn install              # postinstall regenerates src/<program>/
yarn build:tsc            # compiles to lib/

CLUSTER (staging | mainnet, default staging) now only selects the npm release channel; registry sizes are identical across clusters (see "Cluster coupling" above).

Publishing

CI workflow .github/workflows/release-clients-ts.yml is [workflow_dispatch]-triggered with cluster (staging | mainnet), optional version override, and optional dry_run.

Auth uses npm OIDC Trusted Publishing — same model as @ar.io/sdk. No NPM_TOKEN secret in CI. The workflow declares id-token: write; npm CLI ≥9.5 negotiates the OIDC handshake with npmjs.com and attests both publisher identity AND build provenance.

First publish (chicken-and-egg)

Trusted publishers are configured per package on npm, so the package must exist before the trusted-publisher rule can be added. One-time bootstrap:

  1. Publish 0.1.0-staging.0 manually from a local checkout with npm publish --access public --tag staging (using your personal npm credentials).
  2. On npmjs.com: navigate to @ar.io/solana-contracts → Settings → Trusted Publishers → Add Trusted Publisher:
    • Publisher: GitHub Actions
    • Organization: ar-io
    • Repository: ar-io-solana-contracts
    • Workflow filename: release-clients-ts.yml
    • Environment: (leave blank)
  3. Subsequent releases (staging rebuilds, mainnet promotion, version bumps) all run through CI — no token, no manual step.

Dist-tags

TagClusterUse for
@latestmainnetyarn add @ar.io/solana-contracts
@stagingstaging (Solana devnet)yarn add @ar.io/solana-contracts@staging

License

AGPL-3.0-or-later.

版本与发布记录

@ar.io/solana-contracts 共发布 19 个版本,首次发布于 2026/05/12;过去 12 个月发布了 19 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.5.0latest2026/10/0929 天前
1.4.02026/09/261 个月前
1.4.0-staging.33staging2026/09/221 个月前
1.4.0-staging.312026/09/171 个月前
1.3.02026/09/161 个月前
1.2.02026/08/302 个月前

其他发布通道:devnet → 0.2.0-devnet.9,staging → 1.4.0-staging.33。

关于 @ar.io/solana-contracts 的常见问题

@ar.io/solana-contracts 是什么?

TypeScript client for the AR.IO Solana programs (ario-core, ario-gar, ario-arns, ario-ant, ario-ant-escrow). Codama-generated per-program clients plus hand-written helpers for things the IDL doesn't expose (e.g. the ANT-escrow canonical-message builders s

如何安装 @ar.io/solana-contracts?

在项目目录运行 npm install @ar.io/solana-contracts,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@solana/kit(>=6 <7)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@ar.io/solana-contracts 支持 TypeScript 吗?

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

@ar.io/solana-contracts 支持 ESM 还是 CommonJS?

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

@ar.io/solana-contracts 可以商用吗?

@ar.io/solana-contracts 使用 AGPL-3.0-or-later 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@ar.io/solana-contracts 的下载量有多少?

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

@ar.io/solana-contracts 还在维护吗?

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