Skip to content

Get Started: MultiversX Apps

Estimated time to read: 4 minutes

Integrate 'MultiversX' apps with Arcana Auth SDK and onboard users via social login. Enable users to sign blockchain transactions with the in-app Arcana wallet.

MultiversX chains are pre-configured and instantly accessible to authenticated users via the Arcana wallet.

Prerequisites

  • Register the MultiversX app as instructed in the MultiversX Configuration Guide. Get a unique Client ID and use it for app integration.

  • Configure social login providers to onboard users and customize the user experience for blockchain signing via the wallet settings.

1. Install

npm install --save @arcana/auth
yarn add @arcana/auth

2. Integrate

import { AuthProvider } from '@arcana/auth'
const auth = new AuthProvider(
  "xar_test_445007f942xxxxxxxxxxxxxxxxxx484cAfd2", // App client ID
  { 
    alwaysVisible: false,     // default: true, wallet always visible
    connectOptions: {
      compact: true           // default: false, regular plug-and-play login UI
    },
    position: 'left',         // default: right
    setWindowProvider: true,  // default: false, window.ethereum not set
    theme: 'light',           // default: dark
})
try {
  await auth.init()
} catch (e) {
  // Handle exception case
}

Initialize First!

The app must use await until the init() call is complete, before invoking any of the other Arcana Auth SDK functions listed in Arcana Auth SDK Reference.

Onboard Users

await auth.connect();
Plug-and-Play Login UI
Plug-and-Play Login UI

Sign Transactions

  // For authenticated users, add code for signing message

  const personalSign = await provider.request({
    method: 'mvx_signMessage',
    params: {
      message: 'SignMessage to test MultiversX signmessage',
      address: from,
    },
  })

  // Returns signature object
  // {signature: "some-sig"}

For the MultiversX chain, the following methods are supported:

  • mvx_signMessage
  • mvx_signTransaction
  • mvx_signTransactions
  • getAccounts
  • getPublicKey

Refer to other supported Web3 wallet operations for details.

That's all!

The 'MultiversX' app is ready to onboard users and allow them to sign blockchain transactions.

3. Advanced Usage

AuthProvider Optional Parameters

Besides Client ID input parameter, you can optionally customize these settings in the AuthProvider constructor:


position: wallet position within the app context - left|right

theme: wallet theme - light|dark

connectOptions: compact mode for the built-in plug-and-play login UI - true|false

connectOptions: {
      compact: true // default - false
},

See AuthProvider constructor parameters for details.

Wallet Customization

Manage the user experience for signing blockchain transactions by configuring SDK usage. Specify thetheme, branding settings of the in-app built-in Arcana wallet UI. Use wallet visibility and decide when to display the wallet UI in the app. Configure keyspace and enable the user experience of having the same wallet address across multiple apps integrated with the Arcana Auth SDK.

You can also replace the built-in wallet UI with a custom wallet UI.

Custom Login UI

You can onboard users through a custom login UI instead of the built-in plug-and-play one. See how to onboard users via custom login UI in a 'MultiversX' app.

Arcana JWT Token

Upon successful authentication, Arcana Auth SDK returns a unique JWT token to the app called the Arcana JWT Token. App developers can access this token via getUser() method and refer to the loginToken field of the UserInfo object.

Developers can use this token to verify the user and subsequently generate another token for app use if required.

In the future, the Arcana JWT Token will be deprecated. Use userDIDToken to verify user.

Upon successful authentication, Arcana Auth SDK returns a unique DID token to the app called the Arcana DID Token. App developers can access this token via getUser() method and refer to the userDIDToken field of the UserInfo object.

Developers can use this token to verify the user and subsequently generate another token for app use.

See Also

'MultiversX' integration example: See 'sample-auth-multiversx' submodule in Auth Examples

Try Demo App!


Last update: July 16, 2024 by shaloo, shaloo