Overview
Theaccount_create_ephemeral syscall creates a temporary account that exists only for the duration of the current transaction. Ephemeral accounts do not require state proofs and are automatically cleaned up at transaction end.
Syscall Code
Code:0x05 (TN_SYSCALL_CODE_ACCOUNT_CREATE_EPHEMERAL)
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.
Return Value
Returns a syscall result code:TN_VM_SYSCALL_SUCCESS(0) - Ephemeral 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_ADDRESS(-21) - Invalid virtual address for seedTN_VM_ERR_SYSCALL_BAD_ACCOUNT_ADDRESS(-15) - Computed address doesn’t match expected
Resource Consumption
Compute Units
- Base cost:
TN_VM_SYSCALL_BASE_COST(512 units) - Seed cost: Additional units equal to seed length in bytes
- Metadata cost: Additional units equal to
sizeof(tn_account_meta_t) - Total formula:
base_cost + seed_sz + sizeof(tn_account_meta_t) - Note: No proof cost since ephemeral accounts don’t require state proofs
Memory Pages
- Page usage: No direct page allocation (account data starts at size 0)
- Metadata pages: Allocates pages for account metadata structure
- Cleanup: All allocated pages are automatically freed at transaction end
Side Effects
- Account creation: Creates a new account with EPHEMERAL flag set
- Ownership: Sets the current program as the account owner
- Automatic cleanup: Account will be deleted at transaction end
Address Derivation
The ephemeral account address is computed as:Usage Notes
- No state proof required (faster creation)
- Account exists only during transaction execution
- Cannot be used in balance transfers (ephemeral accounts rejected)
- Automatically deleted when transaction completes
- Perfect for temporary storage and intermediate computations
- The computed address must match the transaction’s expected address
Differences from Permanent Accounts
| Feature | Permanent Account | Ephemeral Account |
|---|---|---|
| State proof | Required | Not required |
| Lifetime | Persists after transaction | Transaction only |
| Balance transfers | Allowed | Forbidden |
| Creation cost | Higher (includes proof) | Lower (no proof) |
| Address derivation | is_ephemeral = 0 | is_ephemeral = 1 |