MultiversX Unity Tools
  • Overview
  • Demo App
  • Setup Guide
  • Quick Start
  • Video Tutorials
  • Complete API
    • CallSCMethod
    • CheckTransactionStatus
    • Connect
    • DeepLinkLogin
    • Disconnect
    • GetApiProvider
    • GetConnectedAccount
    • GetNetworkConfig
    • GetRequest
    • IsWalletConnected
    • LoadAllTokens
    • LoadImage
    • LoadNetworkConfig
    • LoadWalletNFTs
    • MakeSCQuery
    • PostRequest
    • SendEGLDTransaction
    • SendESDTTransaction
    • SendMultipleTrasactions
    • SendNFT
    • SignMessage
    • SignMultipleTrasactions
    • RefreshAccount
  • Releases
Powered by GitBook
On this page
  • Description
  • Declaration
  • Parameters
  • Example
  1. Complete API

Connect

Description

This is required before making any blockchain transaction. It is used to initialize the WalletConnect socket used for xPortal connection.

Declaration

public static void Connect(UnityAction<CompleteCallback<Account>> OnWalletConnected, UnityAction OnWalletDisconnected, Image qrImage)

public static void Connect(UnityAction<CompleteCallback<Account>> OnWalletConnected, UnityAction OnWalletDisconnected, UnityAction<string> OnSessionConnected, Image qrImage)

Parameters

Name
Description

OnWalletConnected

Callback triggered when user wallet connected

OnWalletDisconnected

Callback triggered when user wallet disconnected

OnSessionConnected

hen trigger the connection is established. qr code can be displayed

qrImage

The image component that will display the QR for xPortal login

Example

public class Test : MonoBehaviour
{
    [SerializeField] Image qrCode;

    void Start()
    {
        MultiversX.UnityTools.API.Connect(OnConnected, OnDisconnected, OnSessionConnected, qrCode);
    }

    private void OnConnected(CompleteCallback<Account> result)
    {
        if (result.status == OperationStatus.Success)
        {
            //do what you want after the connection is established
            //result.data is the connected account
            LoadScreen(Screens.Connected);
        }
        else
        {
            Debug.LogError(result.errorMessage);
        }
    }

    private void OnDisconnected()
    {
        //do what you want when disconnected
        LoadScreen(Screens.Home);
    }

    private void OnSessionConnected(string arg0)
    {
        // use this method to enable the QRCode or the login button
    }
}
PreviousCheckTransactionStatusNextDeepLinkLogin

Last updated 1 year ago