🔬
Singularity Developer Documentation
  • 👋Hi! Welcome to Singularity
  • Overview
    • 💡What we do
    • ✨Our Products
  • TECHNICAL PAPERS
    • ✨White papers
  • Integration First Steps
    • 🛠️Account Setup
  • Wallet Integration Guide
    • SDK setup and initialization
    • User Sign-in and registration
    • Wallet APIs and Callbacks
  • Payments Integration Guide
    • SDK setup and initialization
    • User Sign-in and registration
    • Buy Tokens
    • NFT Checkout
  • Legal
    • Terms of Service
    • Privacy Policy
Powered by GitBook
On this page
  1. Payments Integration Guide

User Sign-in and registration

PreviousSDK setup and initializationNextBuy Tokens

Last updated 1 year ago

First, follow steps from the 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 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

See sample code at:

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).

wc:552fdc5d755cfde1bf5c93b91c92a306bedfbe658688ff4d427990fd0cb075eb@2?relay-protocol=irn&symKey=5a7e72255b94e3403efe1b2a76bd50ac220ad4a4c8e03e39c4bcac9393d0743f

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);
});
SDK setup and initialization section
Singularity Wallet User Sign-in and Registration
https://github.com/coinbrix/external_wallet_demo
https://main.d1l2w6o5kaplk.amplifyapp.com/
https://github.com/coinbrix/walletconnect-uri-connection-demo