Fund the Account and make the First Deposit
In this section, we will go over the new user account creation flow between non-custodial wallets and anchors with SEP-24 and/or SEP-6 implementations. Before we dive into the flow, it’s important to understand how Stellar accounts are created in the first place.
The first step in creating a Stellar account is to generate a keypair. This keypair includes public and private keys. However, an account does not exist and does not warrant space on the ledger until it’s funded with the minimum balance of 1XLM by a Create Account operation. This requirement was created to minimize unused accounts from bloating the ledger. For a more in-depth look at this topic, check out this page.
When a new customer downloads the wallet application and goes through the deposit flow for the first time, their Stellar account can be created by either the user’s wallet application or the anchor facilitating the first deposit. This section describes the possible strategies and flows for you to consider.
For this option, the wallet needs to allow users to initiate their first deposit without having to add an asset/establish a trustline. The wallet then prompts the user to add the trustline once funds are received by the anchor. The flow looks like this:
- The wallet registers a new user and issues a keypair.
- The wallet initiates the first deposit on behalf of the user without requiring the user to add the asset/create the trustline.
- The anchor provides deposit instructions to the customer.
- The user transfers money from a bank account to the anchor’s bank account.
- Once the anchor receives the transfer, the anchor creates and funds the Stellar account for the customer.
- The wallet detects that the account has been created and a trustline must be established.
- The wallet prompts the user to add the asset/create the trustline.
- Finally, the anchor sends the deposit funds to the user’s Stellar account.
Note: An anchor should always maintain a healthy amount of XLM in its distribution account to support new account creations. If doing so becomes unsustainable, it’s recommended that the anchor collaborates with wallets to determine a strategy based on the number of account creation requests. The recommended amount is 2XLM per user account creation (1XLM to meet the minimum balance requirement, and 1XLM for establishing trustlines and covering transaction fees).
With the flow described above, the wallet and the anchor have to facilitate listening for and responding to the trustline status, which can create user experience frictions when waiting for the trustline to be established. To address this issue, Protocol 15 introduced Claimable Balances, which enhance the flow by allowing users to start using the wallet without having to secure XLM wait to create the trustline after they made their first deposit. Both the wallet and the anchor have to implement Claimable Balance support in order to make this flow work.
The flow with Claimable Balances looks like this:
- The wallet registers a new user, and generates a keypair.
- The wallet initiates a deposit on behalf of a user.
- The anchor provides deposit instructions to the wallet.
- The user transfers money from a bank account to the anchor’s account.
- The anchor creates and funds the user’s Stellar account plus the amount required for trustlines and transaction fees. Again, we suggest 2 XLM to start.
- The anchor creates a Claimable Balance.
- The wallet detects the Claimable Balance for the account, claims the funds, and posts it in the wallet.
For this option, the wallet creates and funds the Stellar account upon every new user sign-up with the minimum requirement of 1XLM, plus the .5XLM reserve for establishing the first trustline, plus a bit more to cover transaction fees. For more information on minimum balances, check out the glossary entry.
The flow looks like this:
- Upon a new user signup, the wallet issues a keypair, then creates and funds the user’s Stellar account with 2XLM.
- Then the wallet creates a trustline, and initiates the first deposit.
- Once the deposit request is sent to the anchor, the anchor provides instructions for the deposit.
- The customer transfer funds from a personal bank account to the anchor’s account.
- The anchor receives the funds, then sends them to the user’s Stellar account.
- The wallet detects that funds were sent and notifies the user.
Note: In the examples above, we suggest having the anchor or wallet cover minimum balance and trustline XLM requirements by depositing funds directly into a user’s account. We made that suggestion for the sake of simplicity, but in all cases, the anchor or wallet could instead use Sponsored Reserves to ensure that when a user closes a trustline or merges their account, the reserve reverts to the sponsoring account rather than to the user’s account.
Last updated Jul. 27, 2021