Setup for Anchored Assets
An anchor is a Stellar-specific term for the on and off-ramps that connect the Stellar network to traditional financial rails, such as financial institutions or fintech companies. When a user deposits with an anchor, that anchor will credit their Stellar account with the equivalent amount of digital tokens. The user can then hold, transfer, or trade those tokens just like any other Stellar asset. When a user withdraws those tokens, the anchor redeems them for cash in hand or money in the bank. Read more about anchors in this anchor section.
When a customer downloads a wallet application that is connected to an anchor service, their Stellar account can either be created by the wallet application or the anchor service. In this example, the account has been created by the wallet application, BasicPay. Account creation strategies are described more in-depth here.
In this example, we’ll use an anchor on Stellar’s Testnet to simulate a bank transfer into and out of the user’s wallet using SEP-6: Deposit and Withdrawal API and/or SEP-24: Hosted Deposit and Withdrawal.
SEPs define community-decided standards for interoperability on Stellar. Read more in our SEPs section.
Our integrations will also use the following SEPs:
- SEP-1: Stellar TOML - a file that provides a place for the Internet to find information about an organization’s Stellar integration
- SEP-9: Standard KYC Fields - defines a list of standard KYC fields for use in Stellar ecosystem protocols
- SEP-10: Stellar Web Authentication - defines the standard way for clients to create authenticated web sessions on behalf of a user who holds a Stellar account
- SEP-12: KYC API - defines a standard way for Stellar clients to upload KYC information to anchors
Finding anchored assets​
BasicPay takes care of all the anchor transfer details on the /dashboard/transfers
page. See it in action here: https://basicpay.pages.dev/dashboard/transfers
We need our application to know how it can communicate with anchors to get asset and infrastructure information. The first thing we'll do is determine whether the user holds trustlines to any assets that have a home_domain
field set on the Stellar network. The presence of that field on an issuer's account tells us the asset may be plugged into the existing Stellar rails allowing for transfers of the asset. If it's present, we'll display some interactive elements to the user for that asset/domain.
import { fetchAssetsWithHomeDomains } from "$lib/stellar/horizonQueries";
/** @type {import('./$types').PageLoad} */
export async function load({ parent }) {
const { balances } = await parent();
return {
/** @type {import('$lib/stellar/horizonQueries').HomeDomainBalanceLine[]} */
homeDomainBalances: await fetchAssetsWithHomeDomains(balances),
};
}
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/transfers/+page.js
Now we know if there are any assets the user holds that may have the necessary infrastructure for authenticated transfers and we can query the domain in question for the relevant details.