Syscall Listing
Account Management
tsys_set_account_data_writable
tsys_set_account_data_writable
Code 0x02 - Marks account data writable by program
tsys_account_transfer
tsys_account_transfer
Code 0x03 - Transfers balance between accounts
tsys_account_create
tsys_account_create
Code 0x04 - Creates permanent account with proof
tsys_account_create_ephemeral
tsys_account_create_ephemeral
Code 0x05 - Creates temporary account
tsys_account_delete
tsys_account_delete
Code 0x06 - Marks account as deleted
tsys_account_resize
tsys_account_resize
Code 0x07 - Changes account data size
tsys_account_set_flags
tsys_account_set_flags
Code 0x0E - Modifies account flags
Calling Convention
ThruVM syscalls follow a standardized calling convention using RISC-V registers:- Syscall number: Placed in register
a7 - Arguments: Passed in registers
a0througha6(up to 7 arguments) - Return value: Placed in register
a0 - Invocation: Use the
ecallinstruction to trigger the syscall
C SDK Interface
The C SDK provides convenient wrapper functions for all syscalls. Includetn_sdk_syscall.h to access these functions:
Raw Assembly Template
For direct assembly usage:Compute Units
All syscalls consume compute units:- Base cost:
TN_VM_SYSCALL_BASE_COST(512 units) - Additional costs: Vary by syscall complexity and data size
- Total consumption: Base cost + operation-specific costs
Error Handling
Syscalls return standardized error codes:TN_VM_SYSCALL_SUCCESS(0) - Operation successful- Negative values indicate specific error conditions
- Programs should always check return values
Usage Patterns
Memory Management
Use memory syscalls to allocate and manage anonymous data segments for program scratch space and dynamic data structures.Account Operations
Account syscalls enable creating, modifying, and managing accounts within transactions. Always verify account ownership and permissions.Cross-Program Calls
Usetsys_invoke and tsys_exit syscalls to build modular programs that can call each other while maintaining security boundaries.