This guide is available on four different programming languages: Typescript, Kotlin, Flutter (Dart) and Swift. You can change the shown version on each page via the buttons above.
Get Anchor Information
Let’s start with creating a sep6 object, which we’ll use for all SEP-6 interactions:- TypeScript
- Flutter
- Swift
- TypeScript
- Flutter
- Swift
Start a deposit
Before getting started, make sure you have connected to the anchor and received an authentication token, as described in the Stellar Authentication wallet guide. We will useauthToken in the examples below as the SEP-10 authentication token, obtained earlier.
To initiate an operation, we need to know an asset. You can hardcode this. Ensure it is one that is included in the info response above.
Before starting with the deposit flow, make sure that the user account has established a trustline for the asset you are working with.
account to represent our account’s public key.
- TypeScript
- Flutter
- Swift
1. Success response
If the response is successful (HTTP 200), then the anchor is processing the deposit. If it needs additional information, it will communicate it when providing the transaction info.2. Still processing, or denied
If an HTTP 403 with data:customer_info_status is returned, it means the action is still processing, or not accepted. In this case the more_info_url field should have a link describing next steps.
An example response:
3. Needs more KYC info
Another common response is an HTTP 403, with the response:non_interactive_customer_info_needed. In this case the anchor needs more KYC information via SEP-12.
An example response:
- TypeScript
- Flutter
- Swift
- TypeScript
- Flutter
- Swift
Providing KYC info
An anchor may respond to a deposit or withdrawal request saying they need additional KYC info. To faciliate this, SEP-6 supports adding a customer’s KYC info via SEP-12. The user can send in the required info using the sep12 object like below. Let’s add some KYC info for our account using sample data. Binary data (eg. image data), needs to be sent in a separate field. The fields allowed to send to the anchor are described in SEP-9.- TypeScript
- Flutter
- Swift
Start a withdrawal
Starting a withdrawal is similar to deposit, and has the same response types as described earlier.- TypeScript
- Flutter
- Swift
Get exchange info
If the anchor supports SEP-38 quotes, it can support deposits that make a bridge between non-equivalent assets. For example, an anchor recieves BRL via bank transfer and in return sends USDC (of equivalent value minus fees) to the user on Stellar. The sep6 exchange functions allow a user to start an exchange deposit or withdrawal with the anchor, and the anchor can communicate back next steps to the user. First, let’s start a deposit exchange with sample data. Assets are described using the SEP-38 scheme.- TypeScript
- Flutter
- Swift
type field.
- TypeScript
- Flutter
- Swift
Getting Transaction Info
On the typical flow, the wallet would get transaction data to notify users about status updates. This is done via the SEP-6GET /transaction and GET /transactions endpoint.
Tracking Transaction
Let’s look into how to use the sdk to track transaction status changes. We will use theWatcher class for this purpose. First, let’s initialize it and start tracking a transaction.
- TypeScript
- Flutter
- Swift
- TypeScript
- Flutter
- Swift
Fetching Transaction
WhileWatcher class offers powerful tracking capabilities, sometimes it’s required to just fetch a transaction (or transactions) once. The Anchor class allows you to fetch a transaction by ID, Stellar transaction ID, or external transaction ID:
- TypeScript
- Flutter
- Swift
- TypeScript
- Flutter
- Swift