Module sys

Source
Expand description

This module defines the low-level syscall API.

§Wasm Syscall ABI

Here we specify how the syscalls specified in this module map to Wasm. For more information on the FVM syscall ABI, read the syscall ABI spec.

By return type, there are three “kinds” of syscalls:

  1. Syscalls that do not return (return !).
  2. Syscalls that do not return a value (return Result<()>).
  3. Syscalls that return a value (return Result<T>).

Syscalls may also “return” values by writing them to out-pointers passed into the syscall by the caller, but this is documented on a syscall-by-syscall basis.

§Kind 1: Divergent

Syscalls that return ! (e.g. [vm::abort]) have the signature:

(func $name (param ...) ... (result i32))

result is unused because the syscall never returns.

§Kind 2: Empty Return

Syscalls that return Result<()> (nothing) have the signature:

(func $name (param ...) ... (result i32))

Here, result is an ErrorNumber or 0 on success.

§Kind 3: Non-Empty Return

Syscalls that return Result<T> where T is a non-empty sized value have the signature:

(func $name (param $ret_ptr) (param ...) ... (result i32))

Here:

  • result is an ErrorNumber or 0 on success.
  • ret_ptr is the offset (specified by the caller) where the FVM will write the return value if, and only if the result is 0 (success).

Modules§

actor
Syscalls for creating and resolving actors.
crypto
Syscalls for cryptographic operations.
debug
Syscalls for debugging.
event
Syscalls related to eventing.
gas
Syscalls for working with gas.
ipld
Syscalls for manipulating IPLD state.
network
Syscalls for network metadata.
rand
Syscalls for getting randomness.
send
Syscalls for sending messages to other actors.
sself
Syscalls for querying and modifying the current actor.
vm
Syscalls for interacting with the VM.

Macros§

fvm_syscalls
Generate a set of FVM syscall shims.

Structs§

TokenAmount
The token amount type used in syscalls. It can represent any token amount (in atto-FIL) from 0 to 2^128-1 attoFIL. Or 0 to about 340 exaFIL.

Enums§

ErrorNumber
When a syscall fails, it returns an ErrorNumber to indicate why. The syscalls themselves include documentation on which syscall errors they can be expected to return, and what they mean in the context of the syscall.