Skip to main content
One central feature of BasicPay is a list of contacts containing a user’s name and associated Stellar addresses.

User experience

There are a few ways for a user to interact with the contact list. One way is that they can add a user and address on the /dashboard/contacts page (which also checks for a valid public key!). contact list See it in action here: https://basicpay.pages.dev/dashboard/contacts

Code implementation

We will create a Svelte store to keep track of a user’s contact list.

Creating the contacts store

As with the rest of our user-data, the contacts list will live in the browser’s localStorage. We are using the svelt-local-storage-store package to facilitate this. We create a Svelte store to hold the data, and add a few custom functions to manage the list: empty, remove, add, favorite, and lookup.
This tutorial code is simplified for display here. The code is fully typed, documented, and commented in the source code repository.
/src/lib/stores/contactsStore.js
Source: https://github.com/stellar/basic-payment-app/blob/main/src/lib/stores/contactsStore.js

Using the contacts store

On the /dashboard/contacts page

We also have a page dedicated to managing contacts. The /dashboard/contacts page will allow the user to collect and manage a list of contact entries that stores the contact’s name and Stellar address. The contact can also be flagged or unflagged as a “favorite” contact to be displayed on the main /dashboard page.
/src/routes/dashboard/contacts/+page.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/contacts/+page.svelte

On the /dashboard page

The contacts store is now exported from this file and can be accessed and used inside a Svelte page or component. Here is how we’ve implemented a “favorite contacts” component for display on the main BasicPay dashboard.
/src/routes/dashboard/components/FavoriteContacts.svelte
Source: https://github.com/stellar/basic-payment-app/blob/main/src/routes/dashboard/components/FavoriteContacts.svelte