Overview
Theaccount_create syscall creates a new permanent account using a program-defined address derived from a seed. The account creation requires a state proof to verify the address doesn’t already exist in the global state.
Syscall Code
Code:0x04 (TN_SYSCALL_CODE_ACCOUNT_CREATE)
C SDK Function
Arguments
Index of the account slot to create. Must be writable in the transaction and currently non-existent.
Pointer to the seed data used for address derivation.
Length of the seed data in bytes. Must not exceed
TN_VM_SYSCALL_MAX_SEED_LEN (4096).Pointer to the state proof data.
Size of the state proof data in bytes.
Return Value
Returns a syscall result code:TN_VM_SYSCALL_SUCCESS(0) - Account created successfully
TN_VM_ERR_SYSCALL_INVALID_ACCOUNT_INDEX(-7) - Account index out of boundsTN_VM_ERR_SYSCALL_ACCOUNT_NOT_WRITABLE(-26) - Account not writable in transactionTN_VM_ERR_SYSCALL_ACCOUNT_ALREADY_EXISTS(-14) - Account already existsTN_VM_ERR_SYSCALL_INVALID_SEED_LENGTH(-35) - Seed length exceeds maximumTN_VM_ERR_SYSCALL_INVALID_ADDRESS(-21) - Invalid virtual address for seed or proofTN_VM_ERR_SYSCALL_BAD_ACCOUNT_ADDRESS(-15) - Computed address doesn’t match expectedTN_VM_ERR_SYSCALL_INVALID_PROOF_LEN(-31) - Proof size mismatchTN_VM_ERR_SYSCALL_INVALID_PROOF_SLOT(-32) - Proof references invalid block slotTN_VM_ERR_SYSCALL_INVALID_STATE_PROOF(-22) - State proof verification failedTN_VM_ERR_SYSCALL_EPHEMERAL_ACCOUNT_CANNOT_CREATE_PERSISTENT(-42) - Ephemeral account cannot create persistent account
Resource Consumption
Compute Units
- Base cost:
TN_VM_SYSCALL_BASE_COST(512 units) - Seed cost: Additional units equal to seed length in bytes
- Proof cost: Additional units equal to proof size in bytes
- Metadata cost: Additional units equal to
sizeof(tn_account_meta_t) - Total formula:
base_cost + seed_sz + proof_sz + sizeof(tn_account_meta_t)
Memory Pages
- Page usage: No direct page allocation (account data starts at size 0)
- Metadata pages: Allocates pages for account metadata structure
- State proof validation: Temporary memory usage for proof verification
Side Effects
- Account creation: Creates a new account with NEW flag set
- Ownership: Sets the current program as the account owner
- Account metadata: Initializes writable metadata structure
Address Derivation
The account address is computed as:State Proof Requirements
- New accounts: Requires a creation-type state proof showing the address doesn’t exist
- Deleted accounts: Can recreate without proof (removes DELETED flag)
- Proof verification: Must reference a valid block slot and verify against state root
Usage Notes
- The computed account address must match the transaction’s expected address
- Seed can be any data up to 4096 bytes
- State proof ensures global uniqueness of the address
- Created accounts are owned by the calling program
- Account is implicitly marked as writable by the creating program