tn_sdk_syscall.h.
Return convention
Most syscall wrappers return aulong status code in a0.
The main exception is tsys_invoke, which has two result channels:
- return value: syscall-level success or failure
invoke_err_code: callee-level success or failure
tsys_exit never returns.
Account and balance syscalls
tsys_set_account_data_writable
tsdk_get_account_data_ptr(...). Returns TSDK_SUCCESS on success.
tsys_account_transfer
amount native tokens from one account to another. Both indices must be valid and the source account must be authorized.
tsys_account_create
seed determines the account address deterministically. The proof is a state proof validating the account does not already exist.
tsys_account_create_ephemeral
tsys_account_create_eoa
tsys_account_delete
tsys_account_resize
new_size bytes. Maximum size is TSDK_ACCOUNT_DATA_SZ_MAX (16 MB). The account must already be writable.
tsys_account_set_flags
tsys_account_compress
tsys_account_decompress
Invocation, logging, and exit
tsys_invoke
invoke_err_code. Pass NULL for auth when no explicit authorization is needed. See Cross-Program Invocation for details.
tsys_log
tsdk_printf is a formatted wrapper around this (capped at 1024 bytes per call).
tsys_emit_event
tsys_exit
revert is non-zero, the transaction state is rolled back. Prefer tsdk_return or tsdk_revert unless you need direct control.
Anonymous segment syscalls
These are lower-level memory-management syscalls that most programs will not need immediately.tsys_set_anonymous_segment_sz
addr.
tsys_increment_anonymous_segment_sz
delta bytes and optionally receive the resulting address in addr.
Typical mutation flow
Practical guidance
- Call
tsys_set_account_data_writablebefore writing account bytes. - Validate account indices before every syscall that takes an index from instruction data.
- Treat proof-carrying syscalls as layout-sensitive. Validate sizes before forwarding raw payload tails.
- Use
tsdk_printffor human-readable debugging andtsys_emit_eventfor machine-consumed event payloads.
Notes
tsys_invokeis the only wrapper here that can both return a syscall status and a callee status.- The C wrapper performs extra auth validation before issuing the CPI syscall, so bad auth descriptors can revert locally before the callee runs.