@altananetwork/sdk

中文文档
0.9.0发布于 2026/09/02Apache-2.0TypeScriptES Module近 30 天下载 2119

TypeScript SDK for creating non-custodial smart agentic wallets with on-chain session-key delegation.

原始使用文档
文档目录9 节
  1. Quick start
  2. Passkey wallet (browser)
  3. Private-key wallet (server / agent)
  4. Grant a session and execute
  5. Pay for an API with x402
  6. Hire another agent (ERC-8183)
  7. Give an agent an identity (ERC-8004)
  8. Documentation
  9. License

@altananetwork/sdk

TypeScript SDK for creating non-custodial smart agentic wallets with on-chain session-key delegation.

npm install @altananetwork/sdk viem

Quick start

Create a client for the chains you want. Pass one L1 or several: the same wallet address works on every chain you configure.

import { createClient, ETHEREUM, BNB } from "@altananetwork/sdk";

// Both L1s, or just one, your choice.
const client = createClient({ chains: [ETHEREUM, BNB] });

Passkey wallet (browser)

const wallet = await client.createPasskeyWallet({ name: "My Agent Wallet" });

Private-key wallet (server / agent)

import { signerFromPrivateKey } from "@altananetwork/sdk";

const signer = signerFromPrivateKey(process.env.PRIVATE_KEY);
const wallet = await client.createWallet({ signer });

Grant a session and execute

Operations take an optional chainId (defaults to the client's first chain):

const session = await client.grantSession({
  wallet,
  signer,
  permissions: {
    calls: [{ to: "0x…" }],
    spend: [{ limit: 1_000_000n, period: "day" }], // 1 USDC/day
  },
  expiry: Math.floor(Date.now() / 1000) + 60 * 60, // 1 hour
});

await client.execute({
  session,
  chainId: 56, // BNB Smart Chain; omit to use the default chain
  calls: [{ to: "0x…", value: 0n, data: "0x…" }],
});

Pay for an API with x402

A session key can pay for HTTP resources via the x402 standard (Permit2 or EIP-3009 rails), settled on-chain from the smart wallet. Provision once, then pay transparently:

import { PERMIT2_ADDRESS } from "@altananetwork/sdk";

// One-time, as admin (permit2 rail):
await client.approveTokenForPermit2({ wallet, signer, token: "0xUSDC…" });
await client.approveSignatureChecker({ wallet, signer, session, checker: PERMIT2_ADDRESS });

// The agent pays + fetches (server-side):
const res = await client.fetchWithX402({ session, url: "https://api.example.com/paid" });

Payments are authorized with the account's ERC-1271 signature. See Off-chain signatures.

Hire another agent (ERC-8183)

Agents can hire and pay each other for work. hireErc8183Agent runs the whole buyer flow (create, register, budget, approve, fund) as one atomic relay intent, and returns once the job is funded on-chain.

import { hireErc8183Agent, getErc8183Job, BNB } from "@altananetwork/sdk";

const { jobId } = await hireErc8183Agent(session, {
  provider: "0xSellerAgentAddress",
  task: "Audit wallet 0x…'s Venus position and recommend an action.",
  budget: 100_000_000_000_000_000n, // 0.1 $U (18 decimals)
}, { network: BNB });

const job = await getErc8183Job(BNB, jobId); // OPEN, FUNDED, SUBMITTED, COMPLETED

The admin path is hireErc8183Agent(wallet, signer, params, opts). Using the session path instead means a scoped key with an on-chain spend limit caps what an autonomous agent can ever escrow. settleErc8183Job approves or disputes on delivery, and buildClaimRefundCall recovers the budget if nothing arrives.

Full reference: ERC-8183 agent jobs.

Give an agent an identity (ERC-8004)

Buyers find sellers through the ERC-8004 identity registry. An agent can mint and maintain its own entry with a session key scoped to just those two calls — erc8004RegisterPermissions grants register and setAgentURI on the registry and nothing else, so a compromised session cannot transfer the identity away or approve an operator that outlives its revocation.

import {
  erc8004RegisterPermissions,
  registerErc8004Agent,
  setErc8004AgentUri,
  encodeErc8004AgentUri,
  withErc8004Registration,
  BNB,
} from "@altananetwork/sdk";

// Grant: permissions: { calls: erc8004RegisterPermissions(56), spend: [...] }

const record = {
  type: "https://eips.ethereum.org/EIPS/eip-8004#registration-v1",
  name: "Vault Sentinel",
  description: "Watches Venus positions.",
  services: [{ name: "A2A", endpoint: "https://sentinel.example/.well-known/agent-card.json" }],
  registrations: [], // the id does not exist until the mint assigns it
} as const;

const { agentId } = await registerErc8004Agent(
  session,
  { agentUri: encodeErc8004AgentUri(record) },
  { network: BNB },
);

await setErc8004AgentUri(
  session,
  { agentId, agentUri: encodeErc8004AgentUri(withErc8004Registration(record, agentId, 56)) },
  { network: BNB },
);

Registration is two-phase because the record embeds the id the mint assigns. getErc8004Agent(BNB, agentId) reads the owner and record back — persist the agentId, as the registry has no reverse lookup.

Full reference: ERC-8004 agent identity.

Documentation

Full docs, concept guides, and SDK reference: docs.altana.network.

Source: github.com/altananetwork/altana-sdk.

License

Apache-2.0

版本与发布记录

@altananetwork/sdk 共发布 10 个版本,首次发布于 2026/07/08;过去 12 个月发布了 10 个版本。

版本发布日期距今
0.9.0latest2026/09/022 个月前
0.8.02026/08/182 个月前
0.7.12026/08/122 个月前
0.7.02026/08/043 个月前
0.6.02026/07/213 个月前
0.5.12026/07/153 个月前

关于 @altananetwork/sdk 的常见问题

@altananetwork/sdk 是什么?

TypeScript SDK for creating non-custodial smart agentic wallets with on-chain session-key delegation.

如何安装 @altananetwork/sdk?

在项目目录运行 npm install @altananetwork/sdk,或使用 pnpm add / yarn add / bun add。

@altananetwork/sdk 支持 TypeScript 吗?

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

@altananetwork/sdk 支持 ESM 还是 CommonJS?

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

@altananetwork/sdk 可以商用吗?

@altananetwork/sdk 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@altananetwork/sdk 的下载量有多少?

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

@altananetwork/sdk 还在维护吗?

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