|
| 1 | +--- |
| 2 | +title: AIP-115 - Stateless Accounts |
| 3 | +--- |
| 4 | + |
| 5 | +# AIP-115: Stateless Accounts |
| 6 | + |
| 7 | +[AIP-115](https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-115.md) covers |
| 8 | +stateless accounts. |
| 9 | + |
| 10 | +## General FAQ |
| 11 | +### What is a Stateless Account? |
| 12 | + |
| 13 | +A Stateless Account is a new behavior for Aptos accounts that allows them to |
| 14 | +operate without requiring an explicitly created `0x1::account::Account` resource. |
| 15 | +Instead, these accounts use default behaviors until an action necessitates the |
| 16 | +creation of the resource. This change simplifies account management and reduces |
| 17 | +unnecessary resource creation, making it easier for developers and users to |
| 18 | +interact with the Aptos blockchain. |
| 19 | + |
| 20 | +### How is it different from a regular account? |
| 21 | + |
| 22 | +Technically, there is no separate account type. All accounts are the same under |
| 23 | +the hood. The difference is that accounts without a resource behave in a |
| 24 | +"stateless" manner using default values. The account resource is only created |
| 25 | +on-demand when needed. |
| 26 | + |
| 27 | +### How does it work? |
| 28 | + |
| 29 | +When an account signs its first transaction sequence number transaction, it |
| 30 | +will not have the `0x1::account::Account` resource created. Instead, it will |
| 31 | +create the `0x1::account::Account` resource only when an action that requires to |
| 32 | +increment the sequence number. |
| 33 | + |
| 34 | +For an orderless transaction, the account resource is not needed at all, and the |
| 35 | +account resource will not be created. |
| 36 | + |
| 37 | +## Technical Details FAQ |
| 38 | + |
| 39 | +### What is the default auth_key for Stateless Accounts? |
| 40 | + |
| 41 | +If the `0x1::account::Account` resource does not exist, the auth_key defaults to |
| 42 | +the account address itself. This allows the account to sign and submit |
| 43 | +transactions without needing a resource. |
| 44 | + |
| 45 | +### What is the sequence number of a Stateless Account? |
| 46 | + |
| 47 | +It defaults to `0` if the account resource does not exist. In the future, with |
| 48 | +Orderless Transactions, the sequence number may be eliminated entirely. |
| 49 | + |
| 50 | +### When is the account resource automatically created? |
| 51 | + |
| 52 | +The resource is created when an action that requires on-chain state, such as: |
| 53 | +- Rotating the authentication key |
| 54 | +- Using capabilities or features that rely on the account resource such as sequence number |
| 55 | +- Explicitly calling functions that access fields in the account resource |
| 56 | + |
| 57 | +### Does creating the account resource incur extra gas cost? |
| 58 | + |
| 59 | +Yes. The creation of the resource is deferred, and the corresponding gas and |
| 60 | +storage fees are only charged at the moment of actual creation, not beforehand. |
| 61 | + |
| 62 | +### Any behavior change to account module at the Move level? |
| 63 | + |
| 64 | +`0x1::account::exists_at` always returns true, as all on-chain account addresses |
| 65 | +are considered valid and treated as existing by default. There is no move |
| 66 | +function in the module to check whether the underlying account resource really |
| 67 | +exists since the goal is to make it transparent to users. As a result, any logic |
| 68 | +that first checks whether an account exists before attempting to create it is |
| 69 | +now obsolete. |
| 70 | + |
| 71 | +### Can users force-create the account resource upfront? |
| 72 | + |
| 73 | +Yes. Users can explicitly call functions like |
| 74 | +`0x1::account::create_account_if_does_not_exist` to create the resource |
| 75 | +manually, if desired. |
| 76 | + |
| 77 | +### Any behavior change to API? |
| 78 | + |
| 79 | +If you rely on the following API behavior, please adjust correspondingly. |
| 80 | +`GET /accounts/{address}` will never return “404 not found” but the default |
| 81 | +authentication key and sequence number mentioned above for stateless accounts. |
| 82 | +Therefore, if it is desired to check whether the account resource exists or not, |
| 83 | +try `GET /accounts/{address}/resource/0x1::account::Account` |
| 84 | + |
| 85 | +### Do existing accounts get affected? |
| 86 | + |
| 87 | +No. Existing accounts with resources already created will continue to work |
| 88 | +exactly as they do now. Stateless Account behavior only applies to accounts that |
| 89 | +have not yet created a resource. |
| 90 | + |
| 91 | + |
| 92 | +### Do dApps / CEX need to change anything? |
| 93 | + |
| 94 | +Maybe. Previously, checking whether an account existed often relied on calling |
| 95 | +APIs that return a 404 error if the account resource was not found. Applications |
| 96 | +would then use this as a signal to warn users (e.g., "This account does not |
| 97 | +exist"). Under the new model, all addresses are considered valid, and such |
| 98 | +404-based existence checks are no longer reliable or meaningful. However, we are |
| 99 | +not banning this pattern—developers may still choose to warn users that an |
| 100 | +account may not have performed any on-chain activity and thus might not have a |
| 101 | +resource created yet. |
| 102 | + |
| 103 | +If you still want to detect whether an account has an associated resource, you |
| 104 | +can refer to the method described in Q9 or check whether the sequence_number is |
| 105 | +0. But be aware that with the introduction of orderless transactions, some |
| 106 | +accounts may only submit transactions that never create a resource, which could |
| 107 | +result in false negatives. |
| 108 | + |
| 109 | +We recommend designing your application to be robust regardless of whether the |
| 110 | +account resource exists, and to avoid assuming resource presence as a proxy for |
| 111 | +account existence. |
| 112 | + |
| 113 | +Examples: |
| 114 | +- A wallet might check for an account to see if it’s a new account, and provide |
| 115 | +a user a warning. With this change, instead a mitigation like Q9 will be needed. |
| 116 | +- A custodial wallet may send funds to initialize an account with gas. With |
| 117 | +this change, it will need to check the account’s balance instead of just the |
| 118 | +account existing. |
| 119 | + |
| 120 | +### Is this compatible with Orderless Transactions? |
| 121 | + |
| 122 | +Yes. Orderless Transactions and Stateless Accounts are complementary. Once |
| 123 | +Orderless Transactions are enabled, sequence numbers will no longer be needed, |
| 124 | +enabling truly stateless usage. |
| 125 | + |
| 126 | +## Will all accounts become Stateless in the future? |
| 127 | + |
| 128 | +No. Stateless Accounts are not a new account type. It simply allows accounts to |
| 129 | +behave with default logic until the account resource is needed. This lazy |
| 130 | +resource creation, does not transform existing account state. All accounts can |
| 131 | +behave in a stateless way by default, but they will still create the standard |
| 132 | +resource if and when advanced features are used. |
| 133 | + |
| 134 | + |
| 135 | + |
| 136 | + |
0 commit comments