Links

User Account Verification

Learn more about account verification with the Enjin Platform
ith Enjin Platform's integration similar to WalletConnect, you have the ability to request a user account and validate its ownership. In this guide, we will demonstrate how this can be accomplished using GraphiQL and JavaScript code.
The following paragraphs provide a brief explanation of the account verification process.
As evident from the previous information, there is a callback mechanism between Enjin Wallet and the platform, necessitating the platform to be externally accessible for proper functioning. If your platform doesn't have a public URL, you can refer to a straightforward tutorial below on how to set up a public URL using ngrok.
Feel free to skip this section if your platform already has a public URL in place.
Making the platform externally accesible for testing

Creating a public URL using ngrok

Step 1: Download ngrok from the official website: https://ngrok.com/download
Step 2: Unzip to Install
On Linux, or macOS you can unzip ngrok from a terminal with the following command. On Windows, just click on ngrok.zip to extract it.
$unzip /path/to/ngrok.zip
Step 3: Connect your account
Running this command will add your auth token to the default ngrok.yml configuration file. This will grant you access to more features and longer session time.
$ngrok config add-authtoken ONE_AUTH_TOKEN_HERE
Step 4: Running ngrok
Read the documentation here, Try it out by running it from the command line:
$ ngrok help
To start an HTTP tunnel forwarding to your local port 8000, run this next:
$ ngrok http 8000
Once you have run the command from above, the example should appear as the following, where the URL shown is the URL of your project.
In case you want to access the GraphQL playground, you would just need to add /graphiql at the end of your HTTP

Testing Account Verification with GraphiQL Playground

Step 1: Start an Account Verification Request

Visit the playground at https://6026-177-220-186-18.ngrok-free.app/graphiql and send the following query:
query RequestAddress {
RequestAccount(callback: "https://6026-177-220-186-18.ngrok-free.app") {
qrCode
verificationId
}
}
Please note the callback MUST be the public URL of your platform which Enjin Wallet will send the signing message.
This query will start the account verification process and output something similar to this:
{
"data": {
"RequestAccount": {
"qrCode": "https://chart.googleapis.com/chart?chs=512x512&cht=qr&chl=https://deeplink.wallet.enjin.io/proof/0xc8b982e38d9524e500eab06b66e5de8c93686487668c4e0447154f1c3b8488bd:A101XH61:aHR0cHM6Ly82MDI2LTE3Ny0yMjAtMTg2LTE4Lm5ncm9rLWZyZWUuYXBw",
"verificationId": "0xc8b982e38d9524e500eab06b66e5de8c93686487668c4e0447154f1c3b8488bd"
}
}
}
Now, with the QR code in hand, you should show it on your front end for the user to scan.

Step 2: Scan the QR code with Enjin Wallet

This step will be done by your end-user who will need to scan the QR code with Enjin Wallet in order to verify the ownership of the account.
  1. 1.
    Open Enjin Wallet, tap the scan button on the top-right section of the screen, scan the QR code, and accept the signing request.
  2. 2.
    Choose the address you want to verify the ownership and wait for the successful response.

Step 3. Retrieve the user account

After the user finished the flow above you can retrieve his account using one of the following methods.
Using GetWallet and passing the verificationId from step 1, you will be able to get any information related to his wallet if the verification process succeeded.
query GetWallet {
GetWallet(verificationId: "0xc8b982e38d9524e500eab06b66e5de8c93686487668c4e0447154f1c3b8488bd") {
account {
address
}
}
}
{
"data": {
"GetWallet": {
"account": {
"address": "efRcQ7zYzqUcmnKvzg7AXBXdj2tpY9kxMLiafshyMkSEXyY1Y"
}
}
}
}
Or by sending the verification ID in the GetAccountVerified query as shown below.
query GetAccountVerified {
GetAccountVerified(verificationId: "0xc8b982e38d9524e500eab06b66e5de8c93686487668c4e0447154f1c3b8488bd") {
verified
account {
address
}
}
}
The possible outputs of the GetAccountVerified are:
{
"data": {
"GetAccountVerified": {
"verified": true,
"account": {
"address": "efRcQ7zYzqUcmnKvzg7AXBXdj2tpY9kxMLiafshyMkSEXyY1Y"
}
}
}
}
Or:
{
"data": {
"GetAccountVerified": {
"verified": false,
"address": null
}
}
}
This query can be used to fetch the status of the verification, while you are showing the QR code to the player, for example, when the query returns verified = true you could hide the QR code and proceed with the next workflow of the game/site by having the user address.
© 2023 Enjin Pte. Ltd.