Overview
Theset_account_data_writable syscall marks an account’s data as writable by the current executing program. This grants the program permission to modify the account’s data and metadata.
Syscall Code
Code:0x02 (TN_SYSCALL_CODE_SET_ACCOUNT_DATA_WRITABLE)
C SDK Function
Arguments
Index of the account to mark as writable. Must be a valid account index within the transaction.
Return Value
Returns a syscall result code:TN_VM_SYSCALL_SUCCESS(0) - Account successfully marked as writable
TN_VM_ERR_SYSCALL_INVALID_ACCOUNT_INDEX(-7) - Account index out of boundsTN_VM_ERR_SYSCALL_ACCOUNT_NOT_WRITABLE(-26) - Account not writable in transaction or ownership check failedTN_VM_ERR_SYSCALL_ACCOUNT_DOES_NOT_EXIST(-8) - Account does not exist
Resource Consumption
Compute Units
- Base cost:
TN_VM_SYSCALL_BASE_COST(512 units) - Additional cost: None
- Total cost: Fixed at 512 units regardless of account state
Memory Pages
- Page usage: No direct page allocation or deallocation
- Metadata impact: May trigger metadata page allocation if account metadata becomes writable
Side Effects
- Account state: Marks the account as writable by the current program
- Write permissions: Grants the program ability to modify account data
Usage Notes
- The account must be marked as writable in the transaction (signer approval)
- The account must be owned by the current program
- Program accounts cannot be made writable
- If the account is already writable by the current program, the syscall succeeds immediately
- Once writable, the program can modify account data and metadata
Ownership Rules
The account can be made writable only if:- The account is not a program account
- The account is owned by the current executing program