aoconnect

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AOConnect Skill

AOConnect Skill

A command-line interface for interacting with AO processes using the
@permaweb/aoconnect
library.
一款基于
@permaweb/aoconnect
库的命令行界面工具,用于与AO进程进行交互。

Phrase Mappings

短语映射

User RequestCommand
"use aoconnect to spawn"
spawn
"use aoconnect to message"
message
"use aoconnect to read result"
result
"use aoconnect to dryrun"
dryrun
"use aoconnect to monitor"
monitor
"use aoconnect to connect"
connect
用户请求命令
"使用aoconnect生成"
spawn
"使用aoconnect发送消息"
message
"使用aoconnect读取结果"
result
"使用aoconnect试运行"
dryrun
"使用aoconnect监控"
monitor
"使用aoconnect连接"
connect

Installation

安装

Install the aoconnect skill and its dependency:
bash
npx skills add https://github.com/permaweb/skills --skill aoconnect
npm install --save @permaweb/aoconnect
Or manually:
bash
cd skills/aoconnect
npm install @permaweb/aoconnect
安装aoconnect skill及其依赖:
bash
npx skills add https://github.com/permaweb/skills --skill aoconnect
npm install --save @permaweb/aoconnect
或手动安装:
bash
cd skills/aoconnect
npm install @permaweb/aoconnect

Prerequisites

前提条件

  • Node.js 18+
  • @permaweb/aoconnect package installed
  • Arweave wallet (JWK format) for signing messages
  • Node.js 18+
  • 已安装**@permaweb/aoconnect**包
  • Arweave钱包(JWK格式),用于签名消息

Available Functions

可用功能

Spawn an AO Process

生成AO进程

sh
node skills/aoconnect/index.mjs spawn \
  --wallet ./wallet.json \
  --module <module-txid> \
  --scheduler <scheduler-address>
Options:
  • --wallet <path>
    - Path to Arweave wallet JSON
  • --module <txid>
    - The arweave TxID of the ao Module
  • --scheduler <address>
    - The Arweave wallet address of a Scheduler Unit
  • --data <string>
    - Optional data to include in spawn message
Example:
sh
node skills/aoconnect/index.mjs spawn \
  --wallet ./wallet.json \
  --module "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
  --scheduler "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
Output:
json
{
  "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
  "processId": "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg",
  "height": 587540,
  "tags": [
    { "name": "App-Process", "value": "l3hbt..." },
    { "name": "App-Name", "value": "arweave-ao" }
  ]
}
sh
node skills/aoconnect/index.mjs spawn \
  --wallet ./wallet.json \
  --module <module-txid> \
  --scheduler <scheduler-address>
选项:
  • --wallet <path>
    - Arweave钱包JSON文件路径
  • --module <txid>
    - AO模块的Arweave交易ID
  • --scheduler <address>
    - 调度单元的Arweave钱包地址
  • --data <string>
    - 生成消息中可包含的可选数据
示例:
sh
node skills/aoconnect/index.mjs spawn \
  --wallet ./wallet.json \
  --module "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
  --scheduler "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA"
输出:
json
{
  "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
  "processId": "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg",
  "height": 587540,
  "tags": [
    { "name": "App-Process", "value": "l3hbt..." },
    { "name": "App-Name", "value": "arweave-ao" }
  ]
}

Send a Message to an AO Process

向AO进程发送消息

sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process <process-id> \
  --data=<message-data> \
  --tags Name=Value,Another=Tag
Options:
  • --wallet <path>
    - Path to Arweave wallet JSON (required)
  • --process <id>
    - The ao Process ID (required)
  • --data <string>
    - Message data (optional, random string if not provided)
  • --tags <name=value,another=value>
    - Message tags (optional)
Example:
sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
  --data="Hello from AO!" \
  --tags "Action=greet", "User=Rakis"
Output:
json
{
  "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
  "height": 587540,
  "tags": [
    { "name": "Action", "value": "greet" },
    { "name": "User", "value": "Rakis" },
    { "name": "Original-Message", "value": "l3hbt..." }
  ]
}
sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process <process-id> \
  --data=<message-data> \
  --tags Name=Value,Another=Tag
选项:
  • --wallet <path>
    - Arweave钱包JSON文件路径(必填)
  • --process <id>
    - AO进程ID(必填)
  • --data <string>
    - 消息数据(可选,未提供则使用随机字符串)
  • --tags <name=value,another=value>
    - 消息标签(可选)
示例:
sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
  --data="Hello from AO!" \
  --tags "Action=greet", "User=Rakis"
输出:
json
{
  "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
  "height": 587540,
  "tags": [
    { "name": "Action", "value": "greet" },
    { "name": "User", "value": "Rakis" },
    { "name": "Original-Message", "value": "l3hbt..." }
  ]
}

Read the Result of an AO Message Evaluation

读取AO消息执行结果

sh
node skills/aoconnect/index.mjs result \
  --message=<message-id> \
  --process=<process-id>
Options:
  • --message=<id>
    - The ao message ID to evaluate (required)
  • --process=<id>
    - The ao Process ID (required)
Example:
sh
node skills/aoconnect/index.mjs result \
  --message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
  --process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"
Output:
json
{
  "messages": [
    {
      "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
      "tags": [
        { "name": "Action", "value": "greet" },
        { "name": "User", "value": "Rakis" }
      ],
      "data": "Hello from AO!"
    }
  ],
  "spawns": [],
  "output": {
    "messages": [
      {
        "from": "address",
        "to": "process-id",
        "target": "process-id",
        "tags": [
          { "name": "Response", "value": "Hello from AO!" }
        ],
        "data": "",
        "height": 587541
      }
    ],
    "size": 256
  },
  "error": null
}
sh
node skills/aoconnect/index.mjs result \
  --message=<message-id> \
  --process=<process-id>
选项:
  • --message=<id>
    - 要执行的AO消息ID(必填)
  • --process=<id>
    - AO进程ID(必填)
示例:
sh
node skills/aoconnect/index.mjs result \
  --message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
  --process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"
输出:
json
{
  "messages": [
    {
      "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
      "tags": [
        { "name": "Action", "value": "greet" },
        { "name": "User", "value": "Rakis" }
      ],
      "data": "Hello from AO!"
    }
  ],
  "spawns": [],
  "output": {
    "messages": [
      {
        "from": "address",
        "to": "process-id",
        "target": "process-id",
        "tags": [
          { "name": "Response", "value": "Hello from AO!" }
        ],
        "data": "",
        "height": 587541
      }
    ],
    "size": 256
  },
  "error": null
}

Dry Run a Message (No Memory Commit)

试运行消息(不提交内存)

sh
node skills/aoconnect/index.mjs dryrun \
  --message=<message-id> \
  --process=<process-id>
Options:
  • --message=<id>
    - The ao message ID to dry run (required)
  • --process=<id>
    - The ao Process ID (required)
Example:
sh
node skills/aoconnect/index.mjs dryrun \
  --message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
  --process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"
Output:
json
{
  "messages": [
    {
      "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
      "tags": [
        { "name": "Action", "value": "greet" }
      ]
    }
  ],
  "spawns": [],
  "output": {
    "messages": [
      {
        "from": "address",
        "to": "process-id",
        "target": "process-id",
        "tags": [
          { "name": "Response", "value": "Hello from AO!" }
        ],
        "height": 587541
      }
    ],
    "size": 256
  },
  "error": null
}
Note: Dry run evaluates the message but doesn't save it to memory. Perfect for testing without committing to the chain.
sh
node skills/aoconnect/index.mjs dryrun \
  --message=<message-id> \
  --process=<process-id>
选项:
  • --message=<id>
    - 要试运行的AO消息ID(必填)
  • --process=<id>
    - AO进程ID(必填)
示例:
sh
node skills/aoconnect/index.mjs dryrun \
  --message="l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc" \
  --process="5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg"
输出:
json
{
  "messages": [
    {
      "messageId": "l3hbt-rIJ_dr9at-eQ3EVajHWMnxPNm9eBtXpzsFWZc",
      "tags": [
        { "name": "Action", "value": "greet" }
      ]
    }
  ],
  "spawns": [],
  "output": {
    "messages": [
      {
        "from": "address",
        "to": "process-id",
        "target": "process-id",
        "tags": [
          { "name": "Response", "value": "Hello from AO!" }
        ],
        "height": 587541
      }
    ],
    "size": 256
  },
  "error": null
}
注意: 试运行会执行消息但不会将其保存到内存,非常适合在不提交到链上的情况下进行测试。

Monitor Messages

监控消息

sh
node skills/aoconnect/index.mjs monitor \
  --process <process-id> \
  --on-message "<callback>"
Options:
  • --process <id>
    - The ao Process ID to monitor (required)
  • --on-message "<function>"
    - JavaScript function to call for each new message (required)
Example:
sh
node skills/aoconnect/index.mjs monitor \
  --process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
  --on-message 'return { tags: msg.tags, data: msg.data }'
Note: In chat interface, use this pattern:
bash
node skills/aoconnect/index.mjs monitor --process <id> --on-message "{console.log(msg.tags)}"
sh
node skills/aoconnect/index.mjs monitor \
  --process <process-id> \
  --on-message "<callback>"
选项:
  • --process <id>
    - 要监控的AO进程ID(必填)
  • --on-message "<function>"
    - 每条新消息触发的JavaScript函数(必填)
示例:
sh
node skills/aoconnect/index.mjs monitor \
  --process "5SGJUlPwlenkyuG9-xWh0Rcf0azm8XEd5RBTiutgWAg" \
  --on-message 'return { tags: msg.tags, data: msg.data }'
注意: 在聊天界面中,使用以下格式:
bash
node skills/aoconnect/index.mjs monitor --process <id> --on-message "{console.log(msg.tags)}"

Connect to Custom Nodes

连接到自定义节点

sh
node skills/aoconnect/index.mjs connect --mu <url> --cu <url> --gateway <url>
Options:
  • --mu <url>
    - Message Unit URL (optional)
  • --cu <url>
    - Compute Unit URL (optional)
  • --gateway <url>
    - Arweave gateway URL (optional)
Example:
sh
node skills/aoconnect/index.mjs connect \
  --mu "https://mu.ao-testnet.xyz" \
  --cu "https://cu.ao-testnet.xyz" \
  --gateway "https://arweave.net"
sh
node skills/aoconnect/index.mjs connect --mu <url> --cu <url> --gateway <url>
选项:
  • --mu <url>
    - 消息单元URL(可选)
  • --cu <url>
    - 计算单元URL(可选)
  • --gateway <url>
    - Arweave网关URL(可选)
示例:
sh
node skills/aoconnect/index.mjs connect \
  --mu "https://mu.ao-testnet.xyz" \
  --cu "https://cu.ao-testnet.xyz" \
  --gateway "https://arweave.net"

Usage with AI Tools

与AI工具配合使用

Claude Code / OpenCode will automatically invoke the aoconnect skill when you:
bash
use aoconnect to spawn <process>
use aoconnect to message <process> --data=<string>
use aoconnect to read result --message=<id>
use aoconnect to dryrun --message=<id>
The skill will prompt for wallet path if not configured.
当你输入以下命令时,Claude Code / OpenCode会自动调用aoconnect skill:
bash
use aoconnect to spawn <process>
use aoconnect to message <process> --data=<string>
use aoconnect to read result --message=<id>
use aoconnect to dryrun --message=<id>
如果未配置钱包路径,该skill会提示你提供。

Common Use Cases

常见使用场景

Send a Transfer Message

发送转账消息

sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process "ao-token-demo-AOe5Hdg4UQhOiE0ZYvRjB_8YDhROi3pA0YCEhPzb_KQ" \
  --data=<raw-balance-value> \
  --tags "Action=Transfer", "Recipient=<address>"
sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process "ao-token-demo-AOe5Hdg4UQhOiE0ZYvRjB_8YDhROi3pA0YCEhPzb_KQ" \
  --data=<raw-balance-value> \
  --tags "Action=Transfer", "Recipient=<address>"

Dry Run Before Committing

提交前先试运行

Always dry run first to verify your message works:
sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process <process-id> \
  --data="test"

node skills/aoconnect/index.mjs dryrun \
  --message=<message-id> \
  --process=<process-id>
始终先进行试运行以验证消息是否可用:
sh
node skills/aoconnect/index.mjs message \
  --wallet ./wallet.json \
  --process <process-id> \
  --data="test"

node skills/aoconnect/index.mjs dryrun \
  --message=<message-id> \
  --process=<process-id>

Monitor Active Process

监控活跃进程

sh
node skills/aoconnect/index.mjs monitor \
  --process "<active-process-id>" \
  --on-message "{console.log('New message:', msg.tags)}"
sh
node skills/aoconnect/index.mjs monitor \
  --process "<active-process-id>" \
  --on-message "{console.log('New message:', msg.tags)}"

Error Handling

错误处理

Missing Wallet

缺少钱包

Error: walletPath is required. Please provide a path to your Arweave wallet JSON file.
Solution: Provide a wallet path:
sh
--wallet ./wallet.json
Error: walletPath is required. Please provide a path to your Arweave wallet JSON file.
解决方案: 提供钱包路径:
sh
--wallet ./wallet.json

Invalid Process ID

无效进程ID

Error: Failed to send message: Invalid process ID
Solution: Verify the process ID is correct and valid.
Error: Failed to send message: Invalid process ID
解决方案: 验证进程ID是否正确有效。

Authentication Failures

认证失败

Error: Failed to send message: Unauthorized
Solution: Ensure your wallet has sufficient balance and proper permissions.
Error: Failed to send message: Unauthorized
解决方案: 确保你的钱包有足够的余额和适当的权限。

API Reference

API参考

messageAo(processId, options)

messageAo(processId, options)

Send a message to an ao Process.
Parameters:
  • processId
    (string): The ao Process ID
  • options
    (Object): Message options
    • data
      (string): Message data
    • tags
      (Array): Message tags
    • walletPath
      (string): Path to wallet JSON
Returns: Promise<Object> - Message result
向AO进程发送消息。
参数:
  • processId
    (string): AO进程ID
  • options
    (Object): 消息选项
    • data
      (string): 消息数据
    • tags
      (Array): 消息标签
    • walletPath
      (string): 钱包JSON文件路径
返回值: Promise<Object> - 消息结果

resultAo(options)

resultAo(options)

Read the result of an ao message evaluation.
Parameters:
  • options
    (Object)
    • message
      (string): The message ID
    • process
      (string): The Process ID
Returns: Promise<Object> - Result object
读取AO消息执行结果。
参数:
  • options
    (Object)
    • message
      (string): 消息ID
    • process
      (string): 进程ID
返回值: Promise<Object> - 结果对象

dryrunAo(options)

dryrunAo(options)

Dry run a message without committing to memory.
Parameters:
  • options
    (Object)
    • message
      (string): The message ID
    • process
      (string): The Process ID
Returns: Promise<Object> - Dry run result
试运行消息,不提交到内存。
参数:
  • options
    (Object)
    • message
      (string): 消息ID
    • process
      (string): 进程ID
返回值: Promise<Object> - 试运行结果

spawnAo(options)

spawnAo(options)

Spawn an ao Process.
Parameters:
  • options
    (Object)
    • module
      (string): Module TxID
    • scheduler
      (string): Scheduler address
    • walletPath
      (string): Path to wallet JSON
    • tags
      (Array): Tags for spawn message
Returns: Promise<Object> - Spawn result
生成AO进程。
参数:
  • options
    (Object)
    • module
      (string): 模块交易ID
    • scheduler
      (string): 调度器地址
    • walletPath
      (string): 钱包JSON文件路径
    • tags
      (Array): 生成消息的标签
返回值: Promise<Object> - 生成结果

monitorAo(options)

monitorAo(options)

Monitor messages from a Process.
Parameters:
  • options
    (Object)
    • process
      (string): Process ID
    • onMessage
      (Function): Callback for new messages
Returns: string - Monitor ID
监控进程的消息。
参数:
  • options
    (Object)
    • process
      (string): 进程ID
    • onMessage
      (Function): 新消息的回调函数
返回值: string - 监控ID

unmonitorAo(monitorId)

unmonitorAo(monitorId)

Stop monitoring messages.
Parameters:
  • monitorId
    (string): Monitor ID
停止监控消息。
参数:
  • monitorId
    (string): 监控ID

connectAo(config)

connectAo(config)

Connect to ao nodes with custom configuration.
Parameters:
  • config
    (Object)
    • MU_URL
      (string): Message Unit URL
    • CU_URL
      (string): Compute Unit URL
    • GATEWAY_URL
      (string): Arweave gateway URL
Returns: Object - aoconnect functions
使用自定义配置连接到AO节点。
参数:
  • config
    (Object)
    • MU_URL
      (string): 消息单元URL
    • CU_URL
      (string): 计算单元URL
    • GATEWAY_URL
      (string): Arweave网关URL
返回值: Object - aoconnect函数集合

getConnection(config)

getConnection(config)

Get connected aoconnect functions.
Parameters:
  • config
    (Object): Connection config
Returns: Object - aoconnect functions
获取已连接的aoconnect函数。
参数:
  • config
    (Object): 连接配置
返回值: Object - aoconnect函数集合

Node.js vs Browser

Node.js与浏览器对比

This skill works in both Node.js and browser environments.
该skill可在Node.js和浏览器环境中使用。

Node.js

Node.js

javascript
import { messageAo, createDataItemSigner } from "./index.mjs";
import { readFileSync } from "node:fs";

const wallet = JSON.parse(readFileSync("./wallet.json", "utf-8"));
const result = await messageAo("process-id", {
  walletPath: "./wallet.json",
  data: "Hello AO!",
  tags: [{ name: "Action", value: "greet" }]
});
javascript
import { messageAo, createDataItemSigner } from "./index.mjs";
import { readFileSync } from "node:fs";

const wallet = JSON.parse(readFileSync("./wallet.json", "utf-8"));
const result = await messageAo("process-id", {
  walletPath: "./wallet.json",
  data: "Hello AO!",
  tags: [{ name: "Action", value: "greet" }]
});

Browser

浏览器

javascript
import { messageAo, createDataItemSigner } from "./index.mjs";

const result = await messageAo("process-id", {
  walletPath: "/path/to/wallet.json", // or loaded from localStorage
  data: "Hello AO!",
  tags: [{ name: "Action", value: "greet" }]
});
javascript
import { messageAo, createDataItemSigner } from "./index.mjs";

const result = await messageAo("process-id", {
  walletPath: "/path/to/wallet.json", // 或从localStorage加载
  data: "Hello AO!",
  tags: [{ name: "Action", value: "greet" }]
});

See Also

另请参阅