Overview
Theaccount_set_flags syscall modifies specific flags on an account, such as marking it as a program account or setting privileged status. Only certain flags can be modified.
Syscall Code
Code:0x0E (TN_SYSCALL_CODE_ACCOUNT_SET_FLAGS)
C SDK Function
Arguments
Index of the account to modify. Must be writable by the current program.
New flags value. Only modifiable flags will be changed.
Return Value
Returns a syscall result code:TN_VM_SYSCALL_SUCCESS(0) - Flags updated successfully
TN_VM_ERR_SYSCALL_INVALID_ACCOUNT_INDEX(-7) - Account index out of boundsTN_VM_ERR_SYSCALL_ACCOUNT_DOES_NOT_EXIST(-8) - Account does not existTN_VM_ERR_SYSCALL_ACCOUNT_NOT_WRITABLE(-26) - Account not writable by current programTN_VM_ERR_SYSCALL_INVALID_FLAGS(-40) - Attempted to modify non-modifiable flagsTN_VM_ERR_SYSCALL_ACCOUNT_IS_NOT_PROGRAM(-16) - Account data is not valid program bytecode (when setting PROGRAM flag)
Resource Consumption
Compute Units
- Base cost:
TN_VM_SYSCALL_BASE_COST(512 units) - Additional cost: None
- Total cost: Fixed at 512 units regardless of flag changes
Memory Pages
- Page usage: No direct page allocation
- Metadata impact: May trigger metadata page allocation if not already writable
- Program validation: Temporary memory usage when validating program bytecode
Side Effects
- Account flags: Updates the account’s flag bits
- Account metadata: Makes account metadata writable if not already
- Program validation: Validates bytecode when setting PROGRAM flag
- Write permissions: May remove account writability when marking as program
Modifiable Flags
Only certain flags can be modified:Marks the account as containing executable program bytecode. When setting this flag, the account data is validated as valid program bytecode.
Marks the account as privileged (currently unimplemented).
Flag Setting Behavior
- PROGRAM Flag
- PRIVILEGED Flag
Setting the flag:
- Account data is validated as valid program bytecode
- Account is automatically made non-writable (security measure)
- Validation failure causes the syscall to fail
- No special validation required
- Account becomes a regular data account
Usage Notes
- Only the account owner (program) can modify flags
- Attempts to modify non-modifiable flags result in an error
- If no flags actually change, the syscall succeeds immediately
- Program validation is performed when setting the PROGRAM flag
- Account must exist and be writable by the current program
Security Considerations
- Setting the PROGRAM flag automatically removes account writability
- This prevents modification of executable code after deployment
- Privileged flag modifications are restricted (future implementation)