Comment on page

User Sign-in and registration

First, follow steps from the SDK setup and initialization section to setup your Singularity account and initialize the Singularity SDK inside your app.
Now, before calling any of the Payments APIs, you must first 'register' the user with Singularity SDK, using either of the following methods, depending on which wallet the user is using:
Option A: If using Singularity Wallet, sign-in the user using one the methods listed in the Singularity Wallet User Sign-in and Registration section.
Option B: If you are using an external wallet (e.g. Metamask or any external wallet via Wallet Connect), then you must pass the wallet provider connection to the Singularity drawer before initiating any payments calls. See below for details:
Custom Provider Connection
Use the following code snippet to pass the user's existing wallet connection to Singularity, by passing the provider. This is required so that the user does not have to reconnect their wallet to Singularity while proceeding with payment.
await window.SingularityEvent.loginWithProvider(ethereum) // here etherum is the provider instance
Option C: If you are a wallet app on your own, then you must establish a Wallet Connect connection with Singularity in order to proceed with Payment APIs. More details below:
Establish Wallet Connect Connection
You can request a wallet connect connection_uri from Singularity and pass that uri to your own wallet by using the following call.
const {name, metaData} = await window.SingularityEvent.getWalletConnectConnectionUri()
The metaData will contain the connection uri. The uri looks like below given example. Use this uri to establish a Wallet Connect connection with Singularity app (please refer to Wallet Connect documentation for more details on how to establish connection).
See sample implementation of logging user into Singularity using Wallet Connect uri: . Code @​
You can now subscribe to the following callback events to know when the user has been signed-in to Singularity:
//Event when a user is signed-in to singularity
window.SingularityEvent.subscribe('SingularityEvent-login', loginInData => {
console.log('login data --->', loginInData);