Develop and troubleshoot AO processes locally by loading a wasm module and interacting with it via a simple JS API.
- Node 20+ (ESM only)
- Always run with
--experimental-wasm-memory64(or setNODE_OPTIONS)
npm i @permaweb/loco
# or
yarn add @permaweb/locoimport { aoslocal, SQLITE } from '@permaweb/loco'
async function main() {
const aos = await aoslocal(SQLITE) // or omit for latest default
await aos.src('./test/example.lua') // bundles local Lua requires automatically
const evalRes = await aos.eval('Count = 1 + 1')
const { Output } = await aos.send({ Action: 'Eval', Data: 'Count' })
console.log(Output.data)
}
main()Run with the memory flag (or export once):
NODE_OPTIONS="--experimental-wasm-memory64" node index.jsaoslocal(aosmodule = LATEST, env?)→ Promiseaosmodule: useSQLITE,LLAMA,LATESTor an Arweave TX idenv:{ Process, Module }defaults are provided for local dev
aos.src(srcFile, env?)→ loads Lua source; packsrequire()graph into oneaos.eval(expr, env?)→ AOS_Result for an Eval actionaos.send(message, env?)→ AOS_Result; any extra fields become Tagsaos.load(processId)→ loads latest checkpoint for a processaos.fromCheckpoint(txId)→ loads a specific checkpointaos.fromState(txId)→ downloads VM memory fromhttps://cu.ao-testnet.xyz/state/${txId}and loads itaos.asOwner(processId)→ derives default env from a live processaos.fromOwner(txOrPid)→ resolves Process from a state TX (if given), sets env
Types
// AOS_Message
Record<string, string>
// AOS_Result
{
Output: { data: string },
Messages: Record<string, any>[],
Spawns: Record<string, any>[],
Assignments: Record<string, any>[]
}- Checkpoints are fetched from Arweave and cached as
<txId>.binin CWD fromStatefetches from the AO testnet state endpoint and also caches as<txId>.bin- Large files are streamed to disk; subsequent runs reuse the cache
- Network is required for first load of module binary and checkpoints/state
- All tests:
npm test - Single file:
npm test -- test/index.test.js - Name pattern:
npm test -- --test-name-pattern="basic"
License: MIT