Skip to main content
SEP-24 provides a standard way for wallets and anchors to interact by having the user open a webview hosted by an anchor to collect and handle KYC information. In this integration, a user’s KYC information is gathered and handled entirely by the anchor. For the most part, after the anchor’s webview has opened, BasicPay will have little knowledge about what’s going on.
Remember, SEP-24 depends on SEP-10 authentication. Everything below assumes the user has successfully authenticated with the anchor server, and BasicPay has access to an unexpired authentication token to send with its requests.

Find the anchor’s TRANSFER_SERVER_SEP0024

Before we can ask anything about how to make a SEP-24 transfer, we have to figure out where to discover that information. Fortunately, the SEP-1 protocol describes standardized fields to find out what we need.
/src/lib/stellar/sep1.js
Source: https://github.com/stellar/basic-payment-app/blob/main/src/lib/stellar/sep1.js

Get /info

Our application will request the /info endpoint from the anchor’s transfer server to understand the supported transfer methods (deposit, withdraw) and available endpoints, as well as additional features that may be available during transfers. SEP-24 Transfers
/src/lib/stellar/sep24.js
Source: https://github.com/stellar/basic-payment-app/blob/main/src/lib/stellar/sep24.js

The user clicks “deposit” or “withdraw”

Now that we have all the SEP-24 information the anchor has made available to us, it’s up to the user to actually begin the initiation process. In BasicPay, they do that by simply clicking a button that will then trigger the launchTransferWindowSep24 function.
This file was pretty heavily covered in the SEP-6 section. We’ll be presenting here the additions we make to this file, though we won’t repeat things we’ve already covered. Remember to check the source files for the full picture.
/src/routes/dashboard/transfers/+page.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/transfers/+page.svelte

Retrieve the interactive URL

BasicPay then initiates a transfer method by sending a POST request to either the “SEP-24 Deposit” or “SEP-24 Withdraw” endpoint. The anchor then sends an interactive URL that BasicPay will open as a popup for the user to complete and confirm the transfer.
/src/lib/stellar/sep24.js
Source: https://github.com/stellar/basic-payment-app/blob/main/src/lib/stellar/sep24.js

Launch the popup window and listen for a callback

BasicPay doesn’t really need (or want) to know everything that’s happening between the user and the anchor during a SEP-24 transfer. However, we do want to know when the interaction is over, since we may need to take some action at that point. So, we add a callback to the interactive URL and open the popup window.
Since BasicPay is an entirely client-side application, we can’t provide a callback as a URL. So, we are using a postMessage callback. For more information on the details of these callback options, check out this section of the SEP-24 specification.
/src/routes/dashboard/transfers/+page.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/transfers/+page.svelte

Complete transfer

Once the user is finished with the interactive window from the anchor, they’ll be brought back to BasicPay. We store the details of the transfer in the transfersStore store (remember, this is just so we can track which anchors to query for transfers later on).
/src/routes/dashboard/transfers/+page.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/transfers/+page.svelte

(Sometimes) Send a Stellar payment

In a withdrawal transaction, BasicPay will also build and present to the user a Stellar transaction for them to sign with their pincode.
/src/routes/dashboard/transfers/+page.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/transfers/+page.svelte