Alias directory onboarding tutorial
Date | Responsible | Changes |
---|---|---|
December 23, 2022 | @Tomislav Herman | Initial version |
January 19, 2023 | @Tomislav Herman | Updated JSON payloads and wallet addresses according to new addressing schema. |
January 20, 2023 | @Tomislav Herman | Added steps to create a bridge record for alias directory service. Updated code examples to match lates ledger-sdk. |
January 27, 2023 | @Tomislav Herman | Changed title from ‘Onboard alias directory users’ to ‘Alias directory onboarding tutorial’ |
February 10, 2023 | @Omar Monterrey | SDK Options refactoring (url to server and key to signer ) |
February 27, 2023 | @Omar Monterrey | Refactored signer.schema -> signer.format |
March 13, 2023 | @Tomislav Herman | Renamed ledger → sdk in code examples. Added real example of credit received on phone alias service when onboarding prone number. |
April 17, 2023 | @Omar Monterrey | Removed config.signer property from bridge |
May 22, 2023 | @Omar Monterrey | Removed bridge.schema property from bridge |
Example of mobile phone wallet data configured to forward balance sent to phone number to different bank accounts for different currencies:
For example, this wallet will forward all balance movements of usd
which initially targets the phone number 15261234578
to the wallet representing the account 343454345
in the bank pbz
.
We will now show the process how this wallet is configured by different actors in the process. Examples are written in NodeJS by using @minka/ledger-sdk
.
Creating phone alias bridge wallet
First we will create a bridge record which will represent the phone alias directory service. This code is executed only once during setup of a clearinghouse. It can be executed through CLI by admin, or from a server side code by using SDK. Example below shows execution from the phone alias directory service hosted on clearinghouse side.
Created bridge record data:
Then we will create a bridge type wallet described here: About Wallets, which will serve as a catch-all for all balance movements which target any phone number and pass them for processing to the bridge created above.
Created wallet record data:
Created bridge type wallet has handle tel
equal to schema so it will automatically catch all balance movements sent to tel:*
. If there is already an alias wallet tel:*
created for some specific phone number then this wallet with catch the balance movement, but all others will go to the bridge wallet.
Bridge of the wallet is set to tel
which represents the phone alias directory service created above. It handles phone number resolution and onboarding of new phone numbers into system. This bridge will process any intent which targets the phone alias wallet (if wallet still is not created).
Creating a wallet representing a phone number
When user starts to use the service for the first time there is still no wallet representing his phone number in the ledger so we need to create it. In our clearinghouse model, the phone alias directory service will be called to prepare the credit entry for intent which targets a phone number which is still not onboarded in ledger. Service needs to create specific wallet for this phone number.
We created a wallet with handle tel:15261234578
which represents hierarchical wallet name described here: About Wallets. Prefix tel
represents the schema and we already have authoritative bridge type wallet with the same name which will handle all balance movements to addresses in format tel:*
. Number 15261234578
represents the phone number which is a handle under tel
schema. Created phone wallet now looks like:
In this moment the balance will still not be forwarded to the target user bank account since the wallet doesn’t have any routes. So the service will send an SMS to user notifying him that he has a pending transfer on his phone number and that he needs to select the bank account to receive the balance.
Selecting bank account to receive the balance
When user gets onboarding SMS he will be instructed that he has pending balance and needs to open the bank application (or one of the bank applications) where he will be able to select the bank account where he wants to receive the balance. He will see a pending transfer and when he opens it he will be able to accept the payment. This will add new route to his phone number wallet which will point to his bank account he just have accessed through mobile app. The code which adds a route will be executed on the bank backend service which serves the banking mobile app for pbz
bank.
Phone number wallet tel:15261234578
now has a route for usd
:
Which means that all usd
balance received to this phone number will be forwarded to the user bank account 343454345
in bank pbz
. More info about routing can be found here: About Wallets.
Our initial intent which was pending until this moment can now continue the execution since it can now be continued by the phone alias directory service adding a signature to intent with prepared status. More details about the processing of intent sent to alias and also continuation of pending intent by phone alias directory service can be found here: Making cross-ledger payments.
Setting the default bank account to receive currency
In any moment user can decide to change the bank account he uses as a default to receive the balance for some currency through the mobile app of any bank. Mobile app will also call bank backend service which will add additional route for new currency or modify existing one. Backend code is basically the same, we will show the example for zaba
bank setting default account for eur
currency:
Phone number wallet tel:15261234578
now has additional route route for eur
:
Now the user is ready to receive the balance by phone number in usd
and eur
into 2 different banks.