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

IsConnected

Returns true if a wallet is currently connected.

HandshakeData

An object with a field named PairingData with the data that applications need to connect to the wallet.

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 WalletConnected or WalletConnectionFailed 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 WalletDisconnected event.

GetWalletAddress()

void GetWalletAddress()

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

RequestSignPayload()

public void RequestSignPayload(
SignPayloadType signingType,
string payload)

Sends a request to the connected wallet to sign a payload string.

Parameters:

  • signingType: The type of payload, such as raw, operation or micheline.
  • payload: The payload to send to the wallet to sign.

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. For example, this code prompts the user to sign the message "This message came from my account."

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

TezosManager.Instance.EventManager.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 specified contract.

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.

OriginateContract()

void OriginateContract(
string script,
string delegateAddress);

Deploys (originates) the specified contract.

To use this method, you must compile a contract to Michelson in a JSON file. For an example, see the code of the built-in contract in Resources/Contracts.

The optional delegateAddress parameter is the address of the account to delegate the contract's tez to. For more information, see Delegation.

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 origination operation succeeded or failed.