HB
HB handles interactions with a Hyperbeam node.
Instantiate
import { HB } from "wao"
const hb = await new HB({ url: "http://localhost:10000" }).init(jwk)HTTP Requests
get
Send a GET request without a signed http message. You can get the decoded data in out.
out = decode( headers, body )
const { out, headers, body } = await hb.get({ path, ...params})post
Send a POST request with a signed http message. data will be set to http body with auto-generated content-digest and inline-body-key in the header.
const { out, headers, body, hashpath } = await hb.post({ path, ...fields})g
A shortcut for get.
const out = await hb.g( path, params )p
A shortcut for post.
const out = await hb.p( path, params )Processes
spawn
Spawn a process.
const { pid } = await hb.spawn({ ...tags })schedule
Equivalent to sending a message.
const { slot } = await hb.schedule({ tags, data, pid })compute
Equivalent to getting a result.
const res = await hb.compute({ pid, slot })message
message = schedule + compute.
const { pid, slot, res } = await hb.message({ tags, data, pid })now
Compute up to the latest slot.
const res = await hb.now({ pid })messages
Get messages on a process. You can get next messages by message.next.
const msgs = await hb.messages({ pid, from, to })
for(const item of msgs.edges){
const { cursor: slot, node: { assignment, message } } = item
}
if(msgs.next) const msgs2 = await msg.next()pid: a process idfrom|to: the slot numbers. Messages are marked by integer on HB, not by txid.0is theType=Processmessage that spawed the process.tois inclusive. Both are optional.
Utilities
sign
Sign a message without sending it.
const signed_msg = await hb.sign(msg)send
Send a signed message.
const res = await hb.send(signed_msg)commit
Sign a message with commitments.
const committed_msg = await hb.commit(msg)Legacynet AOS
spawnLegacy
Spawn Legacynet AOS.
const { pid } = await hb.spawnLegacy({ tags, data })scheduleLegacy
Schedule a legacynet aos message.
const { slot } = await hb.scheduleLegacy({ tags, data, pid, action })computeLegacy
Compute legacynet AOS state.
const res = await hb.computeLegacy({ pid, slot })
const { Messages, Spawns, Assignments, Output } = resdryrun
dryrun is only for legacynet AOS. Mainnet AOS disabled this feature for a performance reason.
const res = await hb.dryrun({ tags, data, pid, action })
const { Messages, Spawns, Assignments, Output } = resHyper AOS
AOS with Lua VM (lua@5.3a) instead of Wasm.
spawnLua
The AOS module is fetched from the Arweave mainnet.
const { pid } = await hb.spanw("8DvyaxF8xpHMgPdmpMnhcb1mjY-M8qr2kGxnCpGMb60")scheduleLua
This is an alias of scheduleLegacy.
const { slot } = await hb.scheduleLua({ tags, data, pid, action })computeLua
const { outbox, output } = await hb.computeLua({ slot, pid })Mainnet AOS
Mainnet AOS processes have dedicated API.
spawnAOS
const { pid } = await hb.spawnAOS()messageAOS
messageAOS = schedule + computeAOS.
const result = await hb.messageAOS({ pid, action, tags, data })computeAOS
const result = await hb.computeAOS({ pid, slot })