Skip to main content

Module env

Module env 

Source
Expand description

Low-level WASM host environment bindings.

This module provides direct access to the TruthLinked runtime host functions via WASM imports. These are the raw building blocks used by higher-level SDK APIs.

Most contract developers should use the higher-level APIs in other modules rather than calling these functions directly.

Modules§

oracle_rc
Oracle error codes returned by http_call.

Constants§

MAX_CALLDATA_SIZE
Maximum size of calldata in bytes (256 KB).
MAX_LOG_DATA_SIZE
Maximum size of log data in bytes (64 KB).
MAX_LOG_TOPICS
Maximum number of topics per log event.
MAX_RETURN_DATA_SIZE
Maximum size of return data in bytes (256 KB).
STORAGE_KEY_BYTES
Size of storage keys in bytes (32 bytes / 256 bits).
STORAGE_VALUE_BYTES
Size of storage values in bytes (32 bytes / 256 bits).

Functions§

call_contract_legacy
Calls another contract (legacy version without value transfer).
call_contract_v2_with_value
Calls another contract with value transfer (v2 API).
emit_log_bytes
Emits a log event with topics and data.
get_caller_32
Retrieves the caller’s address (32 bytes).
get_contract_id_32
Retrieves the current contract’s ID (32 bytes).
get_height_u64
Retrieves the current block height.
get_owner_32
Retrieves the contract owner’s address (32 bytes).
get_timestamp_u64
Retrieves the current block timestamp (Unix seconds).
get_value_u128
Retrieves the value sent with the current call (in smallest units).
http_call_bytes
Makes an HTTP oracle call.
read_calldata
Reads the calldata into the provided buffer.
set_return_data_bytes
Sets the return data for the current contract call.
storage_read_32
Reads a 32-byte value from storage at the given 32-byte key.
storage_write_32
Writes a 32-byte value to storage at the given 32-byte key.