Skip to main content

Unity SDK Wallet object

The Unity SDK class TezosSDK.Tezos.Wallet.WalletProvider, which is available at runtime as TezosManager.Instance.Wallet, provides methods to connect to wallets and send transactions from the connected account.

Properties

None.

Methods

Connect()

void Connect(WalletProviderType walletProvider, bool withRedirectToWallet)

Sends a request to a user's wallet to connect to the application.

Parameters:

  • walletProvider: The type of wallet to connect to, including WalletProviderType.beacon for TZIP-10 wallets (most Tezos wallets) and WalletProviderType.kukai for Kukai wallets.
  • withRedirectToWallet: When running on a mobile platform, whether to open the connected mobile app after connecting to a wallet.

This method triggers the AccountConnected or AccountConnectionFailed events, depending on whether the connection was successful or not.

When the walletProvider parameter is set to WalletProviderType.beacon, this method automatically picks the correct way to connect to wallets:

  • In WebGL applications, it uses the TezosSDK.Beacon.BeaconConnectorWebGl class to trigger the browser to connect to a wallet app in a browser plugin.
  • In all other applications, it uses the TezosSDK.Beacon.BeaconConnectorDotNet class to generate a QR code to connect to a wallet app on a mobile device or use a "deep link" to connect to a wallet on the same mobile device that is running the application.

When the walletProvider parameter is set to WalletProviderType.kukai in a WebGL application, it triggers the web browser to open the user's Kukai wallet. This type of connection is appropriate only for WebGL applications.

Disconnect()

void Disconnect()

Disconnects from the currently connected wallet.

This method triggers the AccountDisconnected event.

GetActiveAddress()

void GetActiveAddress()

Returns the address (technically the public key hash) of the currently connected account, or NULL if no wallet is connected.

RequestSignPayload()

public void Connect(WalletProviderType walletProvider, bool withRedirectToWallet)

Sends a request to the connected wallet to sign a payload string. Signing a message proves that it came from a specific user's wallet because the wallet encrypts the message with the user's account's key. You can prompt users to sign messages for several reasons, including:

For example, this code prompts the user to sign the message "This message came from my account."

using Beacon.Sdk.Beacon.Sign;

string payload = "This message came from my account.";

TezosManager.Instance.MessageReceiver.PayloadSigned += OnPayloadSigned;
TezosManager.Instance.Wallet.RequestSignPayload(SignPayloadType.micheline, payload);

VerifySignedPayload()

bool VerifySignedPayload(SignPayloadType signingType, string payload)

Returns true if most recent response to RequestSignPayload matches the specified payload and is properly signed.

CallContract()

void CallContract(
string contractAddress,
string entryPoint,
string input,
ulong amount = 0);

Calls the specified entrypoint of the built-in FA2 contract.

You can use this method as an alternative to calling convenience methods such as TezosManager.Instance.Tezos.TokenContract.Mint() directly or as a way to call the contract methods that do not have convenience methods in the TokenContract object.

This method triggers the ContractCallInjected event if the call is successfully sent to Tezos. Then it triggers ContractCallCompleted or ContractCallFailed events, depending on whether the call succeeded or failed.