prompt stringlengths 109 265 | completion stringlengths 5 10.8k |
|---|---|
This is a JavaScript code from the AO documentation repository. Filename: config.js Path: ../ao-cookbook/src/.vitepress/config.js | import { defineConfig } from "vitepress";
import { languages } from "../../languages/def.js";
import { localeConfig } from "./locales.js";
// https://vitepress.dev/reference/site-config
const config = defineConfig({
themeConfig: {
/**
* Enable Search
*/
search: {
provider: "local",
},
... |
This is a JavaScript code from the AO documentation repository. Filename: locales.js Path: ../ao-cookbook/src/.vitepress/locales.js
Note: This content continues in the next part. | import { get_i18n_str } from "../../languages/def.js";
const get_i18n_link = (code, link) =>
`${code === "en" ? "" : "/" + code}${link}`;
/**
* @type {import('vitepress').LocaleSpecificConfig<import('vitepress').DefaultTheme.Config>}
*/
export const localeConfig = (langCode) => ({
label: get_i18n_str(langCode, ... |
This is a JavaScript code from the AO documentation repository. This is a continuation from the previous part. Filename: locales.js Path: ../ao-cookbook/src/.vitepress/locales.js
Note: This content continues in the next part. | -aos-troubleshooting"),
link: get_i18n_link(langCode, "/guides/aos/troubleshooting"),
},
{
text: get_i18n_str(langCode, "guides-aos-faq"),
link: get_i18n_link(langCode, "/guides/aos/faq"),
},
{
text: ... |
This is a JavaScript code from the AO documentation repository. This is a continuation from the previous part. Filename: locales.js Path: ../ao-cookbook/src/.vitepress/locales.js | , "concepts-tour"),
link: get_i18n_link(langCode, "/concepts/tour"),
},
{
text: get_i18n_str(langCode, "concepts-meet-lua"),
link: get_i18n_link(langCode, "/concepts/lua"),
},
],
},
],
},
... |
This is a JavaScript code from the AO documentation repository. Filename: index.js Path: ../ao-cookbook/src/.vitepress/theme/index.js | // https://vitepress.dev/guide/custom-theme
import { h } from "vue";
import DefaultTheme from "vitepress/theme-without-fonts";
import "./style.css";
/** @type {import('vitepress').Theme} */
export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
// https://vitepress... |
This is a CSS from the AO documentation repository. Filename: style.css Path: ../ao-cookbook/src/.vitepress/theme/style.css | /**
* Customize default theme styling by overriding CSS variables:
* https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
*/
/**
* Colors
*
* Each colors have exact same color scale system with 3 levels of solid
* colors with different brightness, and 1 soft color.
*
* - `XXX... |
This is a Markdown documentation from the AO documentation repository. Filename: ao-core-relay.md Path: ../ao-cookbook/src/mainnet/ao-core-relay.md | # AO Core Payment Relays
Mainnet AO Core is a foundational framework designed for developers to build decentralized, permanent applications on blockchain infrastructure. It provides tools and APIs to interact with the mainnet and manage onchain data efficiently. Phase 1 of Mainnet AO Core is processing payments, this ... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/mainnet/index.md | ---
next:
text: "AO Core Relay"
link: "./ao-core-relay"
---
# AO Mainnet
AO Mainnet is here, marking a major step toward a decentralized, open-access supercomputer directly connected to the internet. It enables confidential, decentralized computation without reliance on centralized Web2 infrastructure, expanding ... |
This is a Markdown documentation from the AO documentation repository. Filename: cron.md Path: ../ao-cookbook/src/references/cron.md | # Cron Messages
ao has the ability to generate messages on a specified interval, this interval could be seconds, minutes, hours, or blocks. These messages automatically get evaluated by a monitoring process to inform the Process to evaluate these messages over time. The result is a real-time Process that can communica... |
This is a Markdown documentation from the AO documentation repository. Filename: token.md Path: ../ao-cookbook/src/references/token.md
Note: This content continues in the next part. | # ao Token and Subledger Specification
**Status:** DRAFT-1
**Targeting Network:** ao.TN.1
This specification describes the necessary message handlers and functionality required for a standard ao token process. Implementations of this standard typically offer users the ability to control a transferrable asset, whose s... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: token.md Path: ../ao-cookbook/src/references/token.md | ({
Target = "[TokenProcess Identifier]",
Tags = {
["Action"] = "Withdraw",
["Recipient"] = "[ADDRESS]",
["Quantity"] = "100"
}
})
```
# Token Example
> NOTE: When implementing a token it is important to remember that all Tags on a message MUST be "string"s. Using the`tostring` func... |
This is a Markdown documentation from the AO documentation repository. Filename: wasm.md Path: ../ao-cookbook/src/references/wasm.md | # Meet Web Assembly
WebAssembly (often abbreviated as Wasm) is a modern binary instruction format providing a portable compilation target for high-level languages like C, C++, and Rust. It enables deployment on the web for client and server applications, offering a high level of performance and efficiency. WebAssembly... |
This is a Markdown documentation from the AO documentation repository. Filename: community.md Path: ../ao-cookbook/src/references/community.md | ---
prev:
text: "ao Editor Setup"
link: "/references/editor-setup.md"
---
# Community Resources
This page provides a comprehensive list of community resources, tools, guides, and links for the AO ecosystem.
## Core Resources
[Autonomous Finance](https://www.autonomous.finance/)
- Autonomous Finance is a dedica... |
This is a Markdown documentation from the AO documentation repository. Filename: lua.md Path: ../ao-cookbook/src/references/lua.md | # Meet Lua
## Understanding Lua
- **Background**: Lua is a lightweight, high-level, multi-paradigm programming language designed primarily for embedded systems and clients. It's known for its efficiency, simplicity, and flexibility.
- **Key Features**: Lua offers powerful data description constructs, dynamic typing, ... |
This is a Markdown documentation from the AO documentation repository. Filename: messaging.md Path: ../ao-cookbook/src/references/messaging.md | # Messaging Patterns in ao
This reference guide explains the messaging patterns available in ao and when to use each one.
## Quick Reference: Choosing the Right Pattern
| If you need to... | Process Flow | Key function(s) ... |
This is a Markdown documentation from the AO documentation repository. Filename: ao.md Path: ../ao-cookbook/src/references/ao.md
Note: This content continues in the next part. | # ao Module
version: 0.0.3
`ao` process communication is handled by messages, each process receives messages in the form of [ANS-104 DataItems](https://specs.arweave.net/view/xwOgX-MmqN5_-Ny_zNu2A8o-PnTGsoRb_3FrtiMAkuw), and needs to be able to do the following common operations.
- [ao.send(msg)](#ao-send-msg-messag... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: ao.md Path: ../ao-cookbook/src/references/ao.md | pairs in Tags table using string keys
Tags = {
["Content-Type"] = "text/plain",
["Action"] = "Ping"
}
-- Alternative 2: Direct key-value pairs in Tags table using dot notation
Tags = {
Category = "Info",
Action = "Ping"
}
```
::: info Root-level Tag Conversion
Any keys in the root message object that... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/references/index.md | ---
prev:
text: "The aos interface"
link: "/concepts/tour"
next:
text: "Lua"
link: "./lua"
---
# References
This section provides detailed technical references for AO components, languages, and tools. Use these resources to find specific information when implementing your AO projects.
## Programming Language... |
This is a Markdown documentation from the AO documentation repository. Filename: handlers.md Path: ../ao-cookbook/src/references/handlers.md
Note: This content continues in the next part. | # Handlers (Version 0.0.5)
## Overview
The Handlers library provides a flexible way to manage and execute a series of process functions based on pattern matching. An AO process responds based on receiving Messages, these messages are defined using the Arweave DataItem specification which consists of Tags, and Data. U... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: handlers.md Path: ../ao-cookbook/src/references/handlers.md | ```lua
Handlers.add("ping",
Handlers.utils.hasMatchingData("ping"),
Handlers.utils.reply("pong")
)
```
## Example Handlers
### Pattern Matching Table
```lua
Handlers.add("Ping", -- Name of the handler
{ Action = "Ping" }, -- Matches messages with Action = "Ping" tag
function(msg) -... |
This is a Markdown documentation from the AO documentation repository. Filename: editor-setup.md Path: ../ao-cookbook/src/references/editor-setup.md | ---
next:
text: "Community"
link: "/references/community"
---
# Editor setup
Remembering all the built in ao functions and utilities can sometimes be hard. To enhance your developer experience, it is recommended to install the [Lua Language Server](https://luals.github.io) extension into your favorite text editor... |
This is a Markdown documentation from the AO documentation repository. Filename: glossary.md Path: ../ao-cookbook/src/references/glossary.md | <style>
.glossary-iframe {
height: 500px;
width: 100%;
border: none;
}
html:not(.dark) .dark-mode-iframe {
display: none;
}
html.dark .light-mode-iframe {
display: none;
}
</style>
<iframe class="glossary-iframe light-mode-iframe" src="https://glossary.permagate.io/"></iframe>
<if... |
This is a Markdown documentation from the AO documentation repository. Filename: data.md Path: ../ao-cookbook/src/references/data.md
Note: This content continues in the next part. | # Accessing Data from Arweave with ao
There may be times in your ao development workflow that you want to access data from Arweave. With ao, your process can send an assignment instructing the network to provide that data to your Process.
## Defining Acceptable Transactions (Required First Step)
Before you can assig... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: data.md Path: ../ao-cookbook/src/references/data.md | 1
print(string.format("Processing: %d + 1 = %d", number, result))
-- Send the result back to the original sender
Send({
Target = originalSender,
Data = tostring(result)
})
-- Clean up the pending request
PendingRequests[txId] = nil
end
)
```
T... |
This is a Markdown documentation from the AO documentation repository. Filename: lua-optimization.md Path: ../ao-cookbook/src/references/lua-optimization.md | # Lua Optimization Guide for AO Platform
This guide provides practical tips for writing efficient, fast, and performant Lua code for on-chain programs on the AO platform.
## Table Operations
### Appending Elements
```lua
-- ❌ Inefficient: Up to 7x slower in tight loops
table.insert(t, v)
-- ✅ Efficient: Direct ind... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/references/betteridea/index.md | ---
prev:
text: "0rbit"
link: "../0rbit/index"
next:
text: "aos"
link: "../aos/index"
---
# BetterIDEa
[BetterIDEa](https://ide.betteridea.dev) is a custom web based IDE for developing on ao.
It offers a built in Lua language server with ao definitions, so you don't need to install anything. Just open the ID... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/index.md | ---
# https://vitepress.dev/reference/default-theme-home-page
layout: home
hero:
name: ""
text: "超级并行计算机"
tagline: "任何规模的去中心化计算。Arweave 上独有。"
actions:
- theme: brand
text: 即刻体验!
link: /zh/welcome/index
features:
- title: 教程
details: 手把手教你入门 ao
link: /zh/tutorials/index
- title: 指南... |
This is a Markdown documentation from the AO documentation repository. Filename: llms-explanation.md Path: ../ao-cookbook/src/zh/llms-explanation.md | ---
layout: doc
title: LLMs 文件文档
---
# LLMs 文件文档
## **[llms.txt](/zh/llms.txt)**:
- ao 生态系统的结构化概述。
- 适用于导航文档或回答一般问题的 AI 工具。
- 适合具有网络搜索功能的 AI 代理。
## **[llms-full.txt](/zh/llms-full.txt)**:
- 完整的技术文档。
- 为深入分析、故障排除或聊天机器人集成而设计。
- 为复杂查询提供详尽细节。
::: info
llms-full.txt 文件仅包含来自参考资料和发行说明的内容,测试表明这种专注的方法在 AI 模型中表现更好。
:::
|
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/tutorials/index.md | ---
prev:
text: "测试网信息"
link: "/welcome/legacynet-info"
next:
text: "开始"
link: "./begin/index"
---
# 教程
在这里,我们创建了一系列教程来帮助你开始使用 aos 并构建你的第一个进程。 这些教程包括交互式指南、代码片段和示例,以帮助你熟悉 aos 环境。
## 教程列表
- [开始 - 互动指南](begin/index)
- [机器人和游戏](bots-and-games/index)
|
This is a Markdown documentation from the AO documentation repository. Filename: ao-effect.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/ao-effect.md | ---
prev:
text: "Bots and Games"
link: "./index"
---
# 我们来玩个游戏吧!
你是冠军,你通过教程获得了力量! 现在,让我们休息一下,开始一些令人兴奋的事情。 怎么样?我们来一款能为你的学习之旅增添乐趣的游戏!

## 什么样的游戏?
`ao-effect` 是一款游戏,你可以直接从你的终端与全球好友进行实时竞赛。我们为这次冒险建立了一个全球游戏进程。
规则很简单。 每个玩家一开始都在 40x40 的网格上,生命值为 100,能量为 0。随着时间的推移,你的能量会补充到最大 100... |
This is a Markdown documentation from the AO documentation repository. Filename: attacking.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/attacking.md | # 自动响应
根据我们的[上一个指南](decisions),我们的创作已经从一个简单的机器人发展成为一个复杂的自主代理。 现在,让我们进一步增强它的能力,添加反击功能,让它能够立即对对手的攻击进行反击,有可能在他们撤退到安全地带之前打他们个措手不及。
## 编写代码
将以下handler添加到你的 `bot.lua` 文件中即可:
```lua
-- 被其他玩家击中时自动攻击的handler。
Handlers.add(
"ReturnAttack",
Handlers.utils.hasMatchingTag("Action", "Hit"),
function (msg)
local playe... |
This is a Markdown documentation from the AO documentation repository. Filename: arena-mechanics.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/arena-mechanics.md
Note: This content continues in the next part. | # 竞技场机制
本指南全面概述了在 `aos` 中设计和管理竞技场类型游戏所必需的基本机制。在竞技场游戏中,参与者进行回合比赛,有策略地相互竞争以消灭对方,直到出现唯一的胜利者。
这里介绍的框架为制作各种游戏奠定了基础,所有游戏都共享相同的核心功能。 探索游戏开发的复杂性,并在这个多功能的舞台上释放你的创造力。
## 核心功能
现在,让我们深入了解竞技场风格游戏的核心功能:
1. **游戏进展模式:**
竞技场游戏被打造为循环运行的回合,具有以下进展模式:`"Not-Started"` → `"Waiting"` → `"Playing"` → `[Someone wins or timeout]` → `"Wai... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: arena-mechanics.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/arena-mechanics.md
Note: This content continues in the next part. | 公告的进程。
Listeners = Listeners or {}
-- 开始一个游戏的最小玩家数。
MinimumPlayers = MinimumPlayers or 2
-- 玩家默认状态初始化。
PlayerInitState = PlayerInitState or {}
-- 向所有注册的侦听器发送状态更改公告。
-- @param event: 事件类型或名称。
-- @param description: 事件描述。
function announce(event, description)
for ix, address in pairs(Listeners) do
ao.send({... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: arena-mechanics.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/arena-mechanics.md | TimeRemaining = StateChangeTime - Now
local GameState = json.encode({
GameMode = GameMode,
TimeRemaining = TimeRemaining,
Players = Players,
})
ao.send({
Target = Msg.From,
Action = "GameState",
Data = GameState})
e... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/index.md | ---
prev:
text: "代币门控"
link: "../begin/tokengating"
next:
text: "我们玩个游戏"
link: "./ao-effect"
---
# 机器人和游戏
利用我们上一章所学,本节将引导你了解 aos 中如何创造自动化的机器人和游戏。你将学习创建代理,让你的代理在游戏场景内游玩。
## 章节
### 游戏入门
- [0. **我们来玩游戏吧:**_在aos上体验游戏_](ao-effect)
### 通过自动化增强游戏交互
- [1. **公告解读:** _游戏内公告解读_](announcements)
- [2. **获取游戏状态:** _检索... |
This is a Markdown documentation from the AO documentation repository. Filename: announcements.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/announcements.md | # 解析公告
欢迎回到你的编码之旅。 是时候使用你从之前的教程中获得的技能来增强你的游戏体验了。
在游戏过程中,你可能会注意到终端中出现的公告。这些公告是游戏向玩家传达重要事件的方式。然而,这些消息有时看起来很神秘,或者你可能会发现自己得反复检查收件箱才能获取更多详细信息。
直接从你的终端访问这些信息不是很方便吗? 嗯,有一种方法可以做到这一点!
通过使用 [handlers](../../references/handlers.md),你可以创建一个自主代理来为你读取这些信息,标志着从简单的机器人到能够直接解析游戏事件并对其采取行动的实体的进化。
## 设置开发环境
首先在你的首选目录中创建一个名为 `bot.lua`... |
This is a Markdown documentation from the AO documentation repository. Filename: bringing-together.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/bringing-together.md
Note: This content continues in the next part. | # 整合在一起
本最终指南总结了我们的系列(教程),你已经逐步构建了一个自主代理。现在,让我们通过一些优化来完善你的代理,以微调其运行。 以下是关键改进的概述:
- **顺序命令执行:** `InAction` 标志的引入确保你的代理的操作是有序的(仅当上一个操作成功执行时才会发生下一个操作)。 这一重要的补充可以防止你的代理对过时的游戏状态采取行动,从而增强其响应能力和准确性。 完整的实现可以在下面的 `bot.lua` 文件的最终代码中找到。
```lua
InAction = InAction or false -- 防止代理同时执行多个操作。
```
- **动态状态更新和决策:** 代理现在采用自动计时逻辑,允许动... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: bringing-together.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/bringing-together.md | InAction = true -- InAction 逻辑添加
local playerEnergy = LatestGameState.Players[ao.id].energy
if playerEnergy == undefined then
print(colors.red .. "Unable to read energy." .. colors.reset)
ao.send({Target = Game, Action = "Attack-Failed", Reason = "Unable to read energy."})
elsei... |
This is a Markdown documentation from the AO documentation repository. Filename: decisions.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/decisions.md | # 战略决策
有了[最新游戏状态](game-state)的辅助,你的机器人就可以进化为 `自主代理`。 这一转变标志着功能的升级,不仅支持对游戏状态的响应,还可以根据上下文、能量和邻近度制定策略行为。
## 编写代码
返回到 `bot.lua` 文件并添加以下函数:
```lua
-- 确定两点之间的接近度。
function inRange(x1, y1, x2, y2, range)
return math.abs(x1 - x2) <= range and math.abs(y1 - y2) <= range
end
-- 根据距离和能量来战略性地决定下一步行动。
function decideNextAc... |
This is a Markdown documentation from the AO documentation repository. Filename: build-game.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/build-game.md
Note: This content continues in the next part. | ---
next:
text: "指南"
link: "/zh/guides/index"
---
# 扩建竞技场
欢迎来到第 2 章的最终指南,你将学习在[上一篇教程](arena-mechanics)中介绍的竞技场框架之上构建自己的游戏。 在本指南中,我们将带你完成创建[ ao-effect ](ao-effect)游戏的过程,即你在本章开始时玩的。 随着你逐步完成此示例,你将深入了解构建游戏逻辑以及与竞技场的核心代码进行交互。
无论你是经验丰富的开发人员还是有抱负的游戏创作者,本指南都将帮助你释放创造力,并在 `aos` 环境中将你独特的游戏创意变为现实。
## 设置开发环境
首先在你的首选目录中创建一个名为... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: build-game.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/build-game.md | 检查玩家能量,并相应更新玩家生命值。 玩家攻击会在游戏中添加竞争元素,让玩家能够相互互动。 这些攻击也会向玩家和听众同步,以获取游戏的实时更新。
### 处理逻辑
最后,你必须设置handler:
```lua
-- HANDLERS: Game state management for AO-Effect
-- Handler for player movement
Handlers.add("PlayerMove", Handlers.utils.hasMatchingTag("Action", "PlayerMove"), move)
-- Handler for player attacks
Handlers.ad... |
This is a Markdown documentation from the AO documentation repository. Filename: game-state.md Path: ../ao-cookbook/src/zh/tutorials/bots-and-games/game-state.md | # 获取游戏状态
现在你可以直接在终端中看到游戏公告,你可以更好地掌握游戏动态。 然而,这些展示仅限于游戏中发生的特定动作。
按需访问全面的游戏数据(例如所有玩家的位置、生命值和武力值)不是更有用吗? 这些信息可以显著改善你的战略规划,帮助你更有效地评估威胁、机遇和时机。
如果你的考虑像[上一篇指南](announcements)中为机器人添加另一个 handler,那就对了!
## 编写代码
返回到 `bot.lua` 文件并更新现有handler,如下所示:
```lua
Handlers.add(
"HandleAnnouncements",
Handlers.utils.hasMatchingTag("A... |
This is a Markdown documentation from the AO documentation repository. Filename: chatroom.md Path: ../ao-cookbook/src/zh/tutorials/begin/chatroom.md
Note: This content continues in the next part. | # 在 aos 中建立一个聊天室
::: info
如果你想学习如何在 `ao` 中创建聊天室,你至少需要了解发送和接收消息的基本方法。如果还没有,建议你先查看[消息传递](messaging)教程。
:::
在本教程中,我们将使用 Lua 脚本语言在 `ao` 中构建一个聊天室。 聊天室将具有两个主要功能:
1. **注册**:允许进程加入聊天室。
2. **广播**:从一个进程向所有注册参与者发送消息。
让我们首先为我们的聊天室建立框架。
## 视频教程
<iframe width="680" height="350" src="https://www.youtube.com/embed/oPCx-cfubF0?si... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: chatroom.md Path: ../ao-cookbook/src/zh/tutorials/begin/chatroom.md | `Action = "Join"`,然后让他使用你的 `Register` 标签注册到聊天室。
- 让我们向 Morpheus 发送加入聊天室的邀请:
```lua
Send({ Target = Morpheus, Action = "Join" })
```
- 要确认 Morpheus 已加入聊天室,请检查 `Members` 列表:
```lua
Members
```
如果成功,你将收到来自 Morpheus 的广播消息。
## 步骤 6:邀请 Trinity 加入聊天室
Morpheus 将向你提供 Trinity 的进程 ID,并告诉你邀请她加入聊天室。使用下列命令查看 Mo... |
This is a Markdown documentation from the AO documentation repository. Filename: preparations.md Path: ../ao-cookbook/src/zh/tutorials/begin/preparations.md | # 准备工作
::: info
**觉醒开始**
你一直都知道,这个世界上还有更多你无法企及的事情。 你一直在寻找它,甚至不知道你在寻找什么。 它就是... `ao`。
我们通过安装 `aos` 客户端并启动新进程来开始我们的旅程。 这将使我们能够与 ao 计算机进行交互并完成本教程的其余部分。
:::
## 视频教程
<iframe width="680" height="350" src="https://www.youtube.com/embed/nhMZup9uVBQ?si=Ex0W_G-PZA1I9rH8" title="YouTube video player" frameborder="0" allow="... |
This is a Markdown documentation from the AO documentation repository. Filename: token.md Path: ../ao-cookbook/src/zh/tutorials/begin/token.md | # 创建 token
::: info
你现在已经准备好创建自己的 token ,token 是去中心化世界里价值和交换的象征。在学习如何创建 token 之前,请务必去学习下[消息传递](messaging)和[创建聊天室](chatroom) 课程。
:::
创建 token 时,我们将继续使用 `ao` 中的 [Lua 语言](../../references/lua.md) 来铸造一个 token ,并遵循 [token 规范](../../references/token.md) 中的原则。
## 继续深入兔子洞
在我们上一篇教程[创建聊天室](chatroom)中,我们学习了如何在 `ao` 中创建一个聊天室,邀... |
This is a Markdown documentation from the AO documentation repository. Filename: messaging.md Path: ../ao-cookbook/src/zh/tutorials/begin/messaging.md
Note: This content continues in the next part. | # `ao` 中的消息传递
## 消息是如何为 `ao` 提供并行计算能力的
`ao` 是一个高度可扩展的环境,每个进程并行运行。每个进程独立且异步运行,所以在进程之间直接函数调用是不可行的。
我们使用异步通信来解决这个问题。 进程之间通过发送和接收消息,而不是直接相互调用函数。 这种方法允许灵活高效的交互,进程可以响应消息,增强系统的可扩展性和响应能力。
我们将首先探索 `aos` 中消息传递的基础知识,如何查看收件箱中收到的消息,以及如何将消息发送到其他进程。
## 视频教程
<iframe width="680" height="350" src="https://www.youtube.com/embed/6aC... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: messaging.md Path: ../ao-cookbook/src/zh/tutorials/begin/messaging.md | box[#Inbox].Data
-- 该命令将返回消息的 `Data` 字段。
-- Data 通常代表基于文本的消息
-- 从一个进程接收到另一进程。
I am here. You are finally awake. Are you ready to see how far the rabbit hole goes?
```
你现在正在使用自己的进程与 Morpheus 进行通信,Morpheus 是 ao 中运行的另一个并行进程。 你现在已准备好继续本教程的下一步。
## 步骤 7:发送带有标签的消息
**标签的用途**:aos 消息中的标签用于有效地分类、路由和处理消息。它们在消息处理中发挥着至关重要的作用,尤其是在... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/tutorials/begin/index.md | ---
prev:
text: "教程"
link: "../index"
next:
text: "准备"
link: "./preparations"
---
# 开始:互动教程
在本教程系列中,你将完成交互式步骤,这将帮助你加深对 aos 环境的理解。
::: info
### 练习
在这个有趣的练习中,你将遇到两个熟悉的角色 Morpheus 和 Trinity 提出的一系列挑战。 在 Morpheus 的引导下,你将深入 `兔子洞`,他会向你提出一系列挑战,以证明你就是 `那个人`。 一旦你完成了 Morpheus 和 Trinity 提出的所有挑战,你将收到一个 token ,该 token 允... |
This is a Markdown documentation from the AO documentation repository. Filename: rabbithole.md Path: ../ao-cookbook/src/zh/tutorials/begin/rabbithole.md | # 进入 `The Construct` - 交互式教程

## 醒来吧,尼奥……
你准备好看看兔子洞有多深了吗?
这个交互式教程将利用你迄今为止所学到的知识并将其应用到任务中。
### 任务:冲出矩阵并进入 `The Construct`
该结构是 ao 内的一个代币门控聊天室,只有完成一系列任务的人才能访问。
**现在...让我们开始吧。**
::: warning
你必须安装最新版本的 aos 才能完成本教程。
:::
### 1. 找到墨菲斯
Morpheus 的进程 ID:
```lua
9yOQrYNwIfIOeSswRDGUMd5g... |
This is a Markdown documentation from the AO documentation repository. Filename: tokengating.md Path: ../ao-cookbook/src/zh/tutorials/begin/tokengating.md | # 支持 token 的聊天室
::: info
现在我们已经创建了一个 token 并将其发送到 `Trinity`,我们可以使用该 token 来对我们的聊天室进行控制:只允许拥有 token 的人进入聊天室。
:::
## 如何创建支持 token 的聊天室
让我们创建一个 handler,允许我们对聊天室进行准入控制。该 handler 将响应标签 `Action = "Broadcast"`,这意味着它将替换我们原始的 `Broadcast` handler。
## 步骤 1:启动相同的 `aos` 进程
确保你使用的 `aos` 进程与你在整个教程中使用的进程相同。
## 步骤2:打开 `chatroom.l... |
This is a Markdown documentation from the AO documentation repository. Filename: dao.md Path: ../ao-cookbook/src/zh/tutorials/begin/dao.md
Note: This content continues in the next part. | # DAO 指南
本指南将带你完成使用 aos 构建 DAO 的过程。如果你还没有,你需要首先在 aos 中构建一个 [代币](token)。 我们会将 DAO 代码与 [token](./token) 指南中的令牌代码一起加载到 aos 中。 在 ao 的上下文中,DAO 可用于管理 MU、CU 和 SU 节点。
在我们的 DAO 中,我们将实施一个称为 `slashing` 的进程。 在 ao 的情况下,如果一个单位行为不当,其他单位可能会投票削减它。 削减意味着他们将失去他们的质押,我们稍后将进一步讨论质押的话题。
创建一个名为 `dao` 的新目录,并将其复制到代币指南中创建的 `token.lua` 中。
```s... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: dao.md Path: ../ao-cookbook/src/zh/tutorials/begin/dao.md | 指南中的 `token.lua` 一起加载到 aos 中。 运行一个名为 `dao` 的新 aos 进程,同时加载 `dao.lua` 和 `token.lua`
```sh
aos dao --load token.lua --load dao.lua
```
从另一个终端运行另一个名为 voter 的 aos 进程
```sh
aos voter
```
现在从 dao aos shell 向投票者发送一些代币
```lua
aos> Send({ Target = ao.id, Tags = { Action = "Transfer", Recipient = 'process id of the voter ao... |
This is a Markdown documentation from the AO documentation repository. Filename: cron.md Path: ../ao-cookbook/src/zh/references/cron.md | # 定时消息(Cron Messages)
ao 具有在指定时间间隔生成消息的能力,这个时间间隔可以是秒、分钟、小时或区块。有一个监控进程会自动解释和运行(eval)这些消息,然后通知 Process 根据时间处理(eval)这些消息。此时会产生一个实时进程,它可以与完整的 ao 网络或外部网络中的预言机进行通信。
## 在进程中设置定时消息(Cron Messages)
创建这些定时消息(Cron Messages)的最简单方法,是在 aos 控制台中生成一个新进程并定义时间间隔。
```sh
aos [myProcess] --cron 5-minutes
```
在生成新进程时,你可以在命令行中传递一个 cron 参... |
This is a Markdown documentation from the AO documentation repository. Filename: token.md Path: ../ao-cookbook/src/zh/references/token.md
Note: This content continues in the next part. | # ao Token 和子账本规范
**状态:** DRAFT-1
**目标网络:** ao.TN.1
该规范描述了标准 ao Token 进程所必须的消息 handler 和函数。该标准提供用户控制和转移资产的能力,资产的稀缺性由进程维护。
每个符合标准的进程会实现一个余额账本,用来对进程代表的资产所有权进行编码。标准中提供了一系列函数进行账本修改,这些函数包含安全保护代码,保护 Token 所有权的稀缺性。
此外,该规范描述了一种名为 '子账本' 的进程类型。实现子账本后,可以将一定数量的 Token 从父进程转移到相同 Token 接口规范的子进程中。如果子账本进程的 `From-Module` 得到参与者的信任,这些... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: token.md Path: ../ao-cookbook/src/zh/references/token.md |
ao.send({
Target = "[Recipient Address]",
Tags = {
{ name = "Action", value = "Credit-Notice" },
{ name = "Quantity", value = "100"},
{ name = "Source-Token", value = "[ADDRESS]" },
{ name = "Parent-Token", value = "[ADDRESS]" }
}
})
```
### Withdraw(Target?, Quantity)
所有子... |
This is a Markdown documentation from the AO documentation repository. Filename: wasm.md Path: ../ao-cookbook/src/zh/references/wasm.md | # 认识 Web Assembly
WebAssembly(通常简称为 Wasm)是一种现代的二进制指令格式,为高级语言(如C、C++和Rust)提供了一个可迁移的编译目标。它可以支持在网络上部署客户端和服务器应用,并提供高水平的性能和效率。WebAssembly 是为了保持网络浏览器的安全性和沙盒功能而设计的,成为网络应用程序的选择之一。它是网络开发人员的关键技术,使他们能够用多种语言编写代码,并将代码编译为在浏览器中以接近原生速度运行的字节码。
WebAssembly 的重要性在于它能够弥合网络应用程序和本地应用程序之间的差距。它使得之前局限于桌面环境的复杂应用程序和游戏,能够在浏览器中以相当的性能运行。这为网络开发带来了新... |
This is a Markdown documentation from the AO documentation repository. Filename: community.md Path: ../ao-cookbook/src/zh/references/community.md | ---
prev:
text: "ao 编辑器设置"
link: "/zh/references/editor-setup.md"
---
# 社区
[Autonomous Finance](https://www.autonomous.finance/)
- Autonomous Finance 是一个专注于 ao 网络内金融基础设施复杂性的研究和技术实体。
[BetterIdea](https://betteridea.dev/)
- 使用 BetterIDEa 构建更快、更智能、更高效的 AO 开发终极本地 Web IDE。
[Orbit](https://www.0rbit.co/)
- 0rbit 通... |
This is a Markdown documentation from the AO documentation repository. Filename: lua.md Path: ../ao-cookbook/src/zh/references/lua.md | # 认识 Lua
### 理解 Lua
- **背景**: Lua 是一种轻量、高级、多范式的编程语言,主要用于嵌入式系统和客户端。它因效率、简洁和灵活性而闻名。
- **核心特性**: Lua 提供了强大的数据描述构造、动态类型、高效的内存管理以及对面向对象编程的良好支持。
### 上手指南
1. **安装**: 访问 [Lua 的官方网站](http://www.lua.org/download.html) ,下载并安装 Lua。
2. **环境**: 你可以使用简单的文本编辑器和命令行,或者像 ZeroBrane Studio ,或带有 Lua 插件的 Eclipse 这样的集成开发环境(IDE)。
### 基础语法... |
This is a Markdown documentation from the AO documentation repository. Filename: ao.md Path: ../ao-cookbook/src/zh/references/ao.md | # ao 模块
版本: 0.0.3
`ao` 进程通信通过消息进行处理,每个进程用 ANS-104 DataItems 的格式接收消息,并且需要能够执行以下常见操作。
- isTrusted(msg) - 检查消息是否可信
- send(msg) - 将消息发给另一个进程
- spawn(module, msg) - 创建一个进程
这个 library 为 `ao` 开发者工具包提供了这些核心功能。开发者可以按需使用这个 library,但它是默认集成在开发者工具包里的。
## 属性
| 名称 | 描述 | 类型 |
| ----------- |... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/references/index.md | ---
prev:
text: "aos 接口"
link: "/zh/concepts/tour"
next:
text: "Lua"
link: "./lua"
---
# 参考
## 目录
- [Lua](lua)
- [Web Assembly](wasm)
- [ao 模块](ao)
- [Handlers](handlers)
- [代币](token)
- [加载 Arweave 数据](data)
- [定时消息](cron)
- [编辑器设置](editor-setup)
|
This is a Markdown documentation from the AO documentation repository. Filename: handlers.md Path: ../ao-cookbook/src/zh/references/handlers.md | # Handlers (版本 0.0.3)
## 概览
Handlers library 提供了一种灵活的方式来管理和执行一系列基于模式的 handler。每个 handler 由一个匹配函数、一个处理函数和一个名称组成。这个 library 适用于需要根据不同的输入条件采取不同行动的场景。
## 模块结构
- `Handlers._version`: 代表 Handlers library 版本的字符串。
- `Handlers.list`: 存储注册的 handler 列表的表。
## 方法
### `Handlers.add(name, pattern, handler)`
添加一个新的 handler 或者根据... |
This is a Markdown documentation from the AO documentation repository. Filename: editor-setup.md Path: ../ao-cookbook/src/zh/references/editor-setup.md | # 编辑器设置
内置的 ao 函数和实用工具不太好用。为了提升你的开发体验,建议你在你常用的文本编辑器中安装 [Lua Language Server](https://luals.github.io) 扩展插件,并添加 [ao插件](https://github.com/martonlederer/ao-definitions)。它们支持所有内置的 aos [模块](../guides/aos/index.md) 和 [全局变量](../guides/aos/intro#globals)。
## VS Code
安装 [sumneko.lua](https://marketplace.visualstudio.com/ite... |
This is a Markdown documentation from the AO documentation repository. Filename: data.md Path: ../ao-cookbook/src/zh/references/data.md | # 使用 ao 访问 Arweave 上的数据
在你的 ao 开发工作流程中,可能有时候你想要访问 arweave 上的数据。你的进程可以使用 ao 发送一条消息,然后 ao 网络会通过一个 Message 对象将数据提供给你的 Process 对象。
为了从 arweave 请求数据,你只需包含一个名为 `Load` 的 `Tag`,在该标签中,你可以使用数据的 TXID 来检索。
```lua
Send({
Target = ao.id,
Tags = {
Load = "WFM_Mi2FUNGCeP7r99XyeE3ySurt07LHxEGfW-wuIdY",
Action = "Data"
... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/welcome/index.md | ---
next:
text: "入门"
link: "/zh/welcome/getting-started"
---
# 欢迎来到 ao

ao 是一个由无数进程组成的世界计算机。这些进程处在一个连贯的计算环境中,进程之间通过原生的消息进行无缝衔接,相互作用。
ao 是一个正在演化的去中心化程序生态系统,类比互联网,这里每个进程就像是一个个独立的网站。它们独立运行,但是又错综复杂的交织为一个统一的”联合体“。
## ao + aos: 火箭和火箭燃料
初次接触 ao,你可以使用操作系统 `aos` 与 ao 进行交互。
aos 是一个运行在进程中的... |
This is a Markdown documentation from the AO documentation repository. Filename: getting-started.md Path: ../ao-cookbook/src/zh/welcome/getting-started.md | # 5分钟入门
我们将在 5 分钟内带你进行首次探险(第一次窥视兔子洞)。 🕳️🐇
## 系统要求
aos 的本地客户端安装超级简单. 你需要有:
- [NodeJS](https://nodejs.org) 版本 20+. (查看 [此网页](https://nodejs.org/en/download/package-manager) 找到安装说明)。
- 一个称手的代码编辑器。
## 安装 aos
完成 NodeJS 安装后,你只需安装 aos 并运行它:
```sh
npm i -g https://get_ao.g8way.io
```
安装完成后,我们运行命令即可启动一个新的 aos 进程!
```... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/welcome/testnet-info/index.md | ---
prev:
text: "入门"
link: "../getting-started"
next:
text: "CRED 和任务 FAQ"
link: "/zh/welcome/legacynet-info/cred-and-quests"
---
# 参与 ao 测试网
2024年2月27日,`ao` 测试网上线,供开发者和早期用户探索这台超并行计算机。
## 什么是 ao 测试网?
ao 测试网允许用户免费与 ao 计算机交互,共同测试和构建主网。
你可以通过 aos 控制台连接 ao 计算机。 在接下来的文档中,你会发现许多可以尝试的任务,这些任务可以帮助你赚取 CRED 代币(测试网的代币... |
This is a Markdown documentation from the AO documentation repository. Filename: cred-and-quests.md Path: ../ao-cookbook/src/zh/welcome/testnet-info/cred-and-quests.md |
# CRED 和任务 FAQ
::: info
`ao`生态系统目前还处于非常早期的阶段,充满机遇。社区任务板提供了许多参与测试和构建软件以发展生态系统的方法,同时还能赚取`ao`生态系统的原生货币:CRED。
:::
## 视频教程
<iframe width="680" height="350" src="https://www.youtube.com/embed/QA3OmkLcdRs?si=CLAZrIUhJ0aEGYxM" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; e... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/guides/index.md | ---
prev:
text: "扩建竞技场"
link: "zh/tutorials/bots-and-games/build-game"
next:
text: "aos"
link: "./aos/index"
---
# 指南
本指南旨在帮助你导览 **ao**和 **aos**,可以帮助你构建聊天室、去中心自治机器人等程序。
## 章节列表
- [aos](aos/index)
- [aoconnect](aoconnect/aoconnect)
|
This is a Markdown documentation from the AO documentation repository. Filename: troubleshooting.md Path: ../ao-cookbook/src/zh/guides/aos/troubleshooting.md | # 使用 ao.link 进行故障排除
使用去中心计算机和网络,你需要能够排除故障,而不仅仅是你自己的代码。你需要跟踪进程和消息,这就是 [https://ao.link](https://ao.link) 工具箱的必要之处。

## 分析
AOLink 4种分析指标:
- 消息总数 (Total Messages)
- 用户总数 (Total Users)
- 进程总数 (Total Processes)
- 模块总数 (Total Modules)
这些指标可以让你快速了解 ao 网络的总体运行状况。... |
This is a Markdown documentation from the AO documentation repository. Filename: installing.md Path: ../ao-cookbook/src/zh/guides/aos/installing.md | # 安装 aos
安装 aos 只需要 `NodeJS` - https://nodejs.org
> 注意: 如果你使用的是 Windows 系统,最后使用 WSL 命令行.
```sh
npm i -g https://get_ao.g8way.io
```
安装完之后你可以输入 `aos` 来运行系统
|
This is a Markdown documentation from the AO documentation repository. Filename: token.md Path: ../ao-cookbook/src/zh/guides/aos/token.md
Note: This content continues in the next part. | # 在 ao 中创建 Token
创建 token 时,我们将遵循[Token 规范](../../references/token.md)中概述的原则,并使用ao中的[Lua 语言](../../references/lua.md)铸造。
### 创建 Token 的两种方式:
**1 - 使用 token 蓝图(token blueprint):**
`.load-blueprint token`
使用蓝图将创建一个 token,其中所有 Handler 和状态都已经定义。这是创建 token 最简单的方法。加载蓝图后,你可以自定义这些 Handler 和状态。
你可以在此处了解更多有关蓝图的信息:[蓝图](../ao... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: token.md Path: ../ao-cookbook/src/zh/guides/aos/token.md | 的余额账户。
```lua
Balances[msg.From] = Balances[msg.From] - qty
Balances[msg.Tags.Recipient] = Balances[msg.Tags.Recipient] + qty
```
如果转账成功,则向原始消息的发送者发送借记通知 (Debit-Notice),并向接收者发送贷记通知 (Credit-Notice)。
```lua
-- Send Debit-Notice to the Sender
ao.send({
Target = msg.From,
Tags = { Action = 'Debit-Notice', Recipi... |
This is a Markdown documentation from the AO documentation repository. Filename: load.md Path: ../ao-cookbook/src/zh/guides/aos/load.md | # .load 命令
这个功能可以让你加载本地环境中的 lua 代码,给 aos 的开发者带来更好的开发体验。
在创建处理程序时你可能有大量代码,希望使用 vscode 等集成开发环境来管理它们。 你还可以安装 lua 扩展插件来做一些语法检查。
那么如何将本地的 lua 代码发布到你的 ao 进程中呢? 这就是“.load”命令发挥作用的地方。
hello.lua
```lua
Handlers.add(
"ping",
Handlers.utils.hasMatchingData("ping"),
Handlers.utils.reply("pong")
)
```
aos 脚本输入
```sh
.lo... |
This is a Markdown documentation from the AO documentation repository. Filename: pingpong.md Path: ../ao-cookbook/src/zh/guides/aos/pingpong.md | # 创建一个 Pingpong 进程
这个教程将指导你在 aos 中创建一个简单的“ping-pong”过程。 在此过程中,每当进程收到带有数据“ping”的消息时,它都会自动回复“pong”。 这是 aos 中消息处理和进程间交互的基本示例。
## 步骤 1: 打开 `aos` CLI
- 首先打开命令行界面并输入 `aos` 进入 aos 环境。
## 步骤 2: 打开内置编辑器
- 在 aos CLI 中输入“.editor”打开内置文本编辑器。 你将在此处编写 pingpong 处理程序代码。
## 步骤 3: 添加 Pingpong Handler
- 在编辑器中,输入以下 Lua 代码来添加 pingpon... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/guides/aos/index.md | ---
prev:
text: "指南"
link: "../"
next:
text: "概览"
link: "zh/guides/aos/intro"
---
# aos
`ao` 是一台分布式计算的并行计算机,`aos` 是该计算机上的操作系统。
使用 `aos` 你可以与进程(processes)交互,并且非常简单地编写进程代码。 你所需要的只是一个终端和一个编辑器。
`aos` 选择 [lua](../../concepts/lua.md) 作为开发语言,这是一种健壮的动态语言,使用起来非常有趣。
如果你还没有这么做,请花 15 分钟浏览我们的[教程](../../tutorials/index)... |
This is a Markdown documentation from the AO documentation repository. Filename: editor.md Path: ../ao-cookbook/src/zh/guides/aos/editor.md | # 编辑器初始化
记住所有的内建函数和工具集方法是非常困难的。为了改善你的开发体验,我们推荐将 [Lua Language Server](https://luals.github.io) 扩展添加到您的编辑器,并添加 [ao addon](https://github.com/martonlederer/ao-definitions) 插件。它支持所有的 aos [内置模块](../aos/modules/index)和[全局变量](../aos/intro#globals)。
## VS Code
安装 [sumneko.lua](https://marketplace.visualstudio.com/items?ite... |
This is a Markdown documentation from the AO documentation repository. Filename: prompt.md Path: ../ao-cookbook/src/zh/guides/aos/prompt.md | # aos 中的自定义提示符(Prompt)
## 步骤 1: 启动 aos 并打开编辑器
- 登录 aos 命令行
- 输入 `.editor` 打开内置编辑器
## 步骤 2: 编写自定义提示符函数
- 在编辑器中,定义你的用户提示符函数,例如:
```lua
function Prompt()
return "YourName@aos> "
end
```
将 `"YourName@aos> "` 定义为你喜欢的文本。
## 步骤 3: 退出并运行你的代码
- 输入 `.done` 并输入 Enter 来退出编辑器并执行代码
- 你的 aos 将显示新的自定义提示符
## 步骤 4... |
This is a Markdown documentation from the AO documentation repository. Filename: cli.md Path: ../ao-cookbook/src/zh/guides/aos/cli.md | # CLI
这里有一些命令参数来与 aos 进行交互:
- [name] - 使用你的钱包地址创建或者加载一个进程
- --load [file] - 加载一个文件,可以多次调用
- --cron [interval] - 只在创建进程的时候使用
- --wallet [walletfile] - 使用一个指定的钱包
## 使用 aos 管理多进程
```sh
aos
```
使用默认`default`名称创建或者连接到进程
```sh
aos chatroom
```
使用 `chatroom` 创建或者连接进程
```sh
aos treasureRoom
```
使用 `treasureRoom` 创建或者连... |
This is a Markdown documentation from the AO documentation repository. Filename: intro.md Path: ../ao-cookbook/src/zh/guides/aos/intro.md | # 概览
aos 使用了与众不同的方式构建进程与合约,ao 计算机是一个去中心的计算机网络,可以在任何地方进行计算,aos 是一个统一的交互终端。 你可以使用 aos 作为你的个人操作系统、构建 ao 进程的开发环境、以及创建您的机器人军团。
让我们来回顾一些基本指令。
## 变量
如果你想通过控制台显示变量的内容,可以直接输入变量的名称
```lua
Name
```
## 收件箱 (Inbox)
`收件箱 (Inbox)` 是你进程收到的消息集合。
```lua
Inbox[1]
```
如果您想查看消息个数,在 `Inbox` 前面加入 `#` 符号
```lua
#Inbox
```
查看收件箱的消息个... |
This is a Markdown documentation from the AO documentation repository. Filename: inbox-and-handlers.md Path: ../ao-cookbook/src/zh/guides/aos/inbox-and-handlers.md | # 理解收件箱(Inbox)
在 aos 中,进程通过 handlers 获取消息并且执行。未处理的消息将进入进程的收件箱(Inbox)
## 什么是 Handlers?
Handler 是一个函数,接收并且处理进程消息。它处理这些消息是通过将消息作为参数来进行的。
```lua
function main(Message, ao)
...dostuff
return {
Output = ...,
Messages = {},
Spawns = {}
}
end
```
`main` 函数返回一个 lua Table,包含 `Output, Message, Spawns` 或者 `... |
This is a Markdown documentation from the AO documentation repository. Filename: faq.md Path: ../ao-cookbook/src/zh/guides/aos/faq.md | # FAQ
## 所有权 (Ownership)
<details>
<summary><strong>进程的所有权</strong></summary>
使用 aos 控制台创建一个新的进程,你的钱包地址就是进程的所有者。**aos** 使用 **Owner** 全局变量来标记进程的所有者。如果你想转移进程的所有权,或者将它变成无人可以控制的进程,你可以重定义 **Owner** 变量将它给其他钱包地址,或者设置为 **nil**。
</details>
## JSON
<details>
<summary><strong>将数据编码为 json 格式</strong></summary>
当你向其他进程或者... |
This is a Markdown documentation from the AO documentation repository. Filename: chatroom.md Path: ../ao-cookbook/src/zh/guides/aos/blueprints/chatroom.md | # 聊天室蓝图 (Chatroom Blueprint)
聊天室蓝图是预先设计好的模板,可帮助你在 ao 中快速构建聊天室。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。
## 解析聊天室蓝图
- **Members**: `Members`数组用于存储已注册聊天室的用户。
- **Register Handler**: `register` handler 用于进程加入聊天室。当进程发送带有标签 `Action = "Register"` 的消息时,handler会将进程添加到 `Members` 数组中,并向进程发送一条消息确认注册。
- **Broadcast Handler**: `broadcast` ha... |
This is a Markdown documentation from the AO documentation repository. Filename: token.md Path: ../ao-cookbook/src/zh/guides/aos/blueprints/token.md | # Token 蓝图
token 蓝图是预先设计好的模板,可帮助你在 ao 中快速创建一个 token。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。
## 解析 token 蓝图
- **Balances**: `Balances` 数组用于存储参与者的 token 余额。
- **Info Handler**: `info` handler 可以检索 token 参数,例如名称、代码、Logo 和面值。
- **Balance Handler**: `balance` handler 检索单个用户的 token 余额。
- **Balances Handler**: `balances` handler 检索所... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/guides/aos/blueprints/index.md | ---
prev:
text: "创建代币"
link: "../token"
next:
text: "聊天室蓝图"
link: "./chatroom"
---
# 蓝图 Blueprints
蓝图是预先设计好的模板,可帮助你在 ao 中快速构建。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。
## 可用的蓝图
- [聊天室蓝图](chatroom)
- [CRED 蓝图](cred-utils)
- [质押蓝图](staking)
- [Token 蓝图](token)
- [投票蓝图](voting)
|
This is a Markdown documentation from the AO documentation repository. Filename: cred-utils.md Path: ../ao-cookbook/src/zh/guides/aos/blueprints/cred-utils.md | # CRED Utils 蓝图
CRED Utils 蓝图是一个预先设计的模板,可帮助你快速的在`ao`测试网中查看你的 CRED 余额。
## 解密 CRED 工具蓝图
### `CRED` 信息表
- **CRED.balance**: 运行 `CRED.balance` 会显示您进程已知的最新 CRED 余额。如果您之前从未查询过余额,它将自动获取。如果你认为你的CRED最近发生变动,建议先运行`CRED.update`更新余额。
- **CRED.process**: 运行此命令会打印发行CRED代币的进程ID。
- **CRED.send**: 就像调用函数一样使用 `CRED.send(targetProce... |
This is a Markdown documentation from the AO documentation repository. Filename: voting.md Path: ../ao-cookbook/src/zh/guides/aos/blueprints/voting.md | # 投票蓝图 (Voting Blueprint)
投票蓝图是预先设计好的模板,可帮助你在 ao 中快速构建投票系统。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。
## 前提条件
投票蓝图要求先加载 [Token 蓝图](./token.md)
## 解析投票蓝图
- **Balances**: The `Balances` 数组用于存储参与者的代币余额。
- **Votes**: `Votes` 数组用于存储投票参与者地址。
- **Vote Action Handler**: `vote` handler 用户进程进行投票。当进程发送带有标记 `Action = "Vote"` 的消息时,handler 会... |
This is a Markdown documentation from the AO documentation repository. Filename: staking.md Path: ../ao-cookbook/src/zh/guides/aos/blueprints/staking.md | # 质押蓝图 (Staking Blueprint)
质押蓝图是预先设计好的模板,可帮助你在 ao 中快速构建质押系统。蓝图是入门的绝佳方式,并且可以根据你的需求进行定制。
## 前提条件
质押蓝图要求先加载 [token 蓝图](./token.md)。
## 解析 staking 蓝图
- **Stakers**: `Stakers` 数组用于存储质押者。
- **Unstaking**:`Unstaking` 数组用于存储参与者的解除质押请求。
- **Stake Action Handler**: `stake`handler 用于进程质押代币。当进程发送带有标签`Action = "Stake"`的消息时,处... |
This is a Markdown documentation from the AO documentation repository. Filename: json.md Path: ../ao-cookbook/src/zh/guides/aos/modules/json.md | # JSON
JSON 模块支持你使用 JavaScript 对象表示法对对象进行编码和解码。
### 示例用法
```lua
local json = require("json")
json.encode({
a_string = "This is a string",
nums = { 1, 2, 3 }
})
```
## 模块函数
### `encode()`
将 Lua 对象转换为 JSON 字符串。
- **参数:**
- `val`: `{any}` 需要格式化的对象
- **返回值:** 对象的 JSON 格式字符串
#### 示例
```lua
--[[
prints:
"... |
This is a Markdown documentation from the AO documentation repository. Filename: utils.md Path: ../ao-cookbook/src/zh/guides/aos/modules/utils.md
Note: This content continues in the next part. | # Utils 工具库
该工具库提供了通用的表格操作和验证功能。它同时支持链式调用 (curry-style) 和传统编程方式。
> **注意**: 务必确保提供给以下函数的输入与期望的类型相匹配。
### 使用示例
```lua
local utils = require(".utils")
local totalSupply = utils.reduce(
function (acc, v) return acc + v end,
0,
{ 2, 4, 9 }
)
print(totalSupply) -- prints 15
```
## 模块函数
### `concat()`
此函数将数组 `b... |
This is a Markdown documentation from the AO documentation repository. This is a continuation from the previous part. Filename: utils.md Path: ../ao-cookbook/src/zh/guides/aos/modules/utils.md | ,如果未找到,则返回 `nil`。
#### 示例
```lua
local user = { name = "Maria", age = 33 }
-- returns "Maria"
utils.prop("name", user)
```
```lua
local user = { name = "John", age = 50 }
-- returns 50
utils.prop("age")(user)
```
### `compose()`
此函数支持你将多个数组操作链接在一起,然后以逆序的方式对提供的数组执行这些操作。
- **Parameters:**
- `...`: `{function[]}... |
This is a Markdown documentation from the AO documentation repository. Filename: ao.md Path: ../ao-cookbook/src/zh/guides/aos/modules/ao.md | # ao
内置全局库,用于发送消息、创建进程等。
### 示例
全局对象 `ao` 在你的进程中的任何地方都可以访问:
```lua
-- sends a message to another process ("Transfer" action)
ao.send({
Target = "usjm4PCxUd5mtaon7zc97-dt-3qf67yPyqgzLnLqk5A",
Action = "Transfer",
Recipient = "XjvCPN31XCLPkBo9bUeB7vAK0VC6-eY52-CS-6Iho8F",
Quantity = tostring(1045)
})
```
## ... |
This is a Markdown documentation from the AO documentation repository. Filename: index.md Path: ../ao-cookbook/src/zh/guides/aos/modules/index.md | ---
prev:
text: "质押蓝图"
link: "../blueprints/staking"
next:
text: "JSON"
link: "./json"
---
# 模块
aos 内置模块文档。
- [JSON](./json)
- [ao](./ao)
- [Base64](./base64)
- [Pretty](./pretty)
- [Utils](./utils)
|
This is a Markdown documentation from the AO documentation repository. Filename: pretty.md Path: ../ao-cookbook/src/zh/guides/aos/modules/pretty.md | # Pretty 模块
这个模块的作用是将输出格式化、易于理解和阅读
## 模块函数
### `tprint()`
将 table 结构转换为格式化的字符串
- **Parameters:**
- `tbl`: `{table}` 需要格式化 table 结构
- `indent`: `{number}` 可选参数,表格每一层的缩进量
- **Returns:** 转为字符串格式的表格结构
#### 示例
```lua
local pretty = require(".pretty")
local formatted = pretty.tprint({
name = "John Doe",
age =... |
This is a Markdown documentation from the AO documentation repository. Filename: base64.md Path: ../ao-cookbook/src/zh/guides/aos/modules/base64.md | # Base64 编码模块
一个小型 `base64` 模块,可以用于编码和解码 Base64 格式的文本。
> **注意:** 为了优化处理大段文本的性能,建议开启缓存功能,最高可以将效率提升一倍。
### 使用示例
```lua
local base64 = require(".base64")
local str = "This will be encoded"
-- is: "VGhpcyB3aWxsIGJlIGVuY29kZWQ="
local encoded = base64.encode(str)
-- is: "This will be encoded"
local decoded = base64.d... |
This is a Markdown documentation from the AO documentation repository. Filename: spawning-processes.md Path: ../ao-cookbook/src/zh/guides/aoconnect/spawning-processes.md | # 创建一个进程
可以在[ao Processes](../../concepts/processes.md) 概念中找到关于进程的深入介绍。本指南聚焦于使用 ao connect 创建一个进程。
为了创建一个进程,你必须拥有已经上传到 Arweave 的一个 ao 模块的 TXID。模块是进程的源代码。进程本身是那个源码的实例化。
你还必须拥有一个调度单元(Scheduler Unit, SU)的钱包地址。指定的 SU 将作为此进程的调度器。这意味着系统中的所有节点都可以知道它们需要为此进程读写到这个 SU。你可以使用下面的地址。
## 调度器的钱包地址
```sh
_GQ33BkPtZrqxA84vM8Zk-N2aO0... |
This is a Markdown documentation from the AO documentation repository. Filename: monitoring-cron.md Path: ../ao-cookbook/src/zh/guides/aoconnect/monitoring-cron.md | # 监控 Cron
当使用 cron 消息时,ao 用户需要一种方式开始接收这些消息,通过使用这个监控方法,ao 用户可以启动 cron 消息的订阅服务。设置 cron 标签意味着你的进程将开始在其发件箱中生成 cron 结果,但如果你希望这些结果中的消息通过网络被推送,则需要监控这些结果。
```js
import { readFileSync } from "node:fs";
import { createDataItemSigner, monitor } from "@permaweb/aoconnect";
const wallet = JSON.parse(
readFileSync("/path/to/arw... |
This is a Markdown documentation from the AO documentation repository. Filename: calling-dryrun.md Path: ../ao-cookbook/src/zh/guides/aoconnect/calling-dryrun.md | # 调用 DryRun
DryRun 是将消息对象发送到特定进程并获取返回的结果对象的过程,但内存不会被保存,这非常适合创建一个读取消息以返回内存的当前值。例如,一个代币的余额,或者一个转账的结果等。你可以使用 DryRun 来获取输出,而无需发送实际消息
```js
import { createDataItemSigner, dryrun } from "@permaweb/aoconnect";
const result = await dryrun({
process: 'PROCESSID',
data: '',
tags: [{name: 'Action', value: 'Balance'},
a... |
This is a Markdown documentation from the AO documentation repository. Filename: installing-connect.md Path: ../ao-cookbook/src/zh/guides/aoconnect/installing-connect.md | # 安装 ao connect
## 先决条件
---
为了在你的应用程序中安装 **ao connect**,你必须安装 NodeJS/NPM 18 或更高版本。
<br>
## 安装方法
### 使用 npm 安装
```sh
npm install --save @permaweb/aoconnect
```
### 使用 yarn 安装
```sh
yarn add @permaweb/aoconnect -D
```
<br>
安装完成后,你可以在 NodeJS 或 浏览器中使用 **aoconnect**。根据你的项目类型(模块系统),可以按照下面的方式引入 **aoconnect**
#### E... |
This is a Markdown documentation from the AO documentation repository. Filename: reading-results.md Path: ../ao-cookbook/src/zh/guides/aoconnect/reading-results.md | # 从 ao 进程读取结果
在 ao 中,消息产生的结果通过计算单元(CU)提供。结果是包含以下字段的 JSON 对象:messages, spawns, output 和 error。
结果包含ao系统用来发送消息和生成进程的返回值。一个进程可以发送消息,就像你作为开发者可以通过在结果中返回消息和返回值一样。
你可能想要访问一个结果,以显示由你的消息生成的输出。或者,你可能想要看看生成了哪些消息等。你不需要自己取出结果中的消息和返回值并发送它们。它们由消息单元(MU)自动处理。对结果的调用还可以为你提供多个结果的分页列表。
## 获取单个结果
```js
import { result } from "@permaweb... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.