# User Sign-in and registration

First, follow steps from the [SDK setup and initialization section](https://docs.s9y.xyz/payments-integration-guide/sdk-setup-and-initialization) 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](https://docs.s9y.xyz/wallet-integration-guide/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:

<details>

<summary>Custom Provider Connection</summary>

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.

<pre class="language-javascript" data-overflow="wrap"><code class="lang-javascript"><strong>await window.SingularityEvent.loginWithProvider(ethereum) // here etherum is the provider instance
</strong></code></pre>

See sample code at: <https://github.com/coinbrix/external_wallet_demo>

</details>

**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:

<details>

<summary>Establish Wallet Connect Connection</summary>

You can request a wallet connect connection\_uri from Singularity and pass that uri to your own wallet by using the following call.&#x20;

{% code overflow="wrap" %}

```javascript
const {name, metaData} = await window.SingularityEvent.getWalletConnectConnectionUri()
```

{% endcode %}

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

{% code overflow="wrap" %}

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

{% endcode %}

See sample implementation of logging user into Singularity using Wallet Connect uri: <https://main.d1l2w6o5kaplk.amplifyapp.com/> . Code @ <https://github.com/coinbrix/walletconnect-uri-connection-demo>

</details>

You can now subscribe to the following callback events to know when the user has been signed-in to Singularity:

{% code overflow="wrap" %}

```javascript
//Event when a user is signed-in to singularity
window.SingularityEvent.subscribe('SingularityEvent-login', loginInData => {
    console.log('login data --->', loginInData);
});
```

{% endcode %}
