Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Host Calls (ecalli)

Declared host functions available to services. Import from "@fluffylabs/as-lan" or from a specific group ("@fluffylabs/as-lan/ecalli/general", .../refine, .../accumulate).

General (available in all contexts)

IDFunctionDescription
0gas()Returns remaining gas
1fetch(dest_ptr, offset, length, kind, param1, param2)Fetch context data
2lookup(service, hash_ptr, out_ptr, offset, length)Look up preimage by hash
3read(service, key_ptr, key_len, out_ptr, offset, length)Read from storage
4write(key_ptr, key_len, value_ptr, value_len)Write to storage
5info(service, out_ptr, offset, length)Get service account info
100log(level, target_ptr, target_len, msg_ptr, msg_len)JIP-1 debug log (prefer Logger)

Refine (available during refinement)

IDFunctionDescription
6historical_lookup(service, hash_ptr, out_ptr, offset, length)Historical preimage lookup
7export_segment(segment_ptr, segment_len)Export a data segment
8machine(code_ptr, code_len, entrypoint)Create inner PVM machine
9peek(machine_id, dest_ptr, source, length)Read inner machine memory
10poke(machine_id, source_ptr, dest, length)Write inner machine memory
11pages(machine_id, start_page, page_count, access_type)Set inner machine page access
12invoke(machine_id, io_ptr, out_r8)Run inner machine (r7=exit reason, r8 written to out_r8)
13expunge(machine_id)Destroy inner machine

Accumulate (available during accumulation)

IDFunctionDescription
14bless(manager, auth_queue_ptr, delegator, registrar, auto_accum_ptr, count)Set privileged config
15assign(core, auth_queue_ptr, assigners)Assign core
16designate(validators_ptr)Set next epoch validators
17checkpoint()Commit state, return remaining gas
18new_service(code_hash_ptr, code_len, gas, allowance, gratis_storage, id)Create service
19upgrade(code_hash_ptr, gas, allowance)Upgrade service code
20transfer(dest, amount, gas_fee, memo_ptr)Transfer funds
21eject(service, prev_code_hash_ptr)Remove service
22query(hash_ptr, length, out_r8)Query preimage status (r8 written to out_r8)
23solicit(hash_ptr, length)Request preimage availability
24forget(hash_ptr, length)Cancel preimage solicitation
25yield_result(hash_ptr)Provide accumulation result hash
26provide(service, preimage_ptr, preimage_len)Supply solicited preimage

Error Sentinels

All functions return i64. Error sentinels are defined in EcalliResult: NONE (-1), WHAT (-2), OOB (-3), WHO (-4), FULL (-5), CORE (-6), CASH (-7), LOW (-8), HUH (-9).