Skip to main content
A payment operation sends an amount in a specific asset (XLM or non-XLM) to a destination account. With a basic payment operation, the asset sent is the same as the asset received. BasicPay also allows for path payments (where the asset sent is different than the asset received), which we’ll talk about in the next section.

User experience

In our BasicPay application, the user will navigate to the Payments page where can either select a user from their contacts or input the public key of a destination address with a specified asset they’d like to send along with the amount of the asset. payment The user clicks the “Confirm Transaction” button. If the destination account exists and is properly funded with XLM, this will trigger a Transaction Preview where they can view the transaction details. All Stellar transactions require a small fee to make it to the ledger. Read more in our Fees section. In BasicPay, we’ve set it up so that the user always pays a static fee of 100,000 stroops (one stroop equals 0.0000001 XLM) per operation. Alternatively, you can add a feature to your application that allows the user to set their own fee. payment The user then inputs their pincode and clicks the “Confirm” button, which signs and submits the transaction to the ledger.

Code implementation

The /dashboard/send page

The /dashboard/send page allows the user to send payments to other Stellar addresses. They can select from a dropdown containing their contact list names, or they can enter their own “Other…” public key. The following additional features have been implemented:
  • If the destination address is not a funded account, the user is informed they will be using a createAccount operation, and must send at least 1 XLM to fund the account.
  • The user can select to send/receive different assets and paths are queried from Horizon depending on the four below points:
    1. If they want to strict send or strict receive,
    2. The source/destination assets they have selected,
    3. The source/destination accounts, and
    4. The amount entered for the send/receive value.
  • An optional memo field is available for text-only memos.
For now, we’ll focus on regular payments, and we’ll dig into the path payments in a later section.
/src/routes/dashboard/send/+page.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/send/+page.svelte

The transaction functions

In the above section, we used the createPaymentTransaction function. This function can be used to send a payment of any asset from one Stellar address to another. We also used the createCreateAccountTransaction function. This is used when the destination account is not currently funded and active on the Stellar network. The only asset possible in this scenario is native XLM.
/src/lib/stellar/transactions.js