Skip to main content

Usage with Unity SDK

1. Using the ThirdwebManager prefab

Adding the ThirdwebManager to your scene will handle the initialization of the SDK and maintain the connection to the wallet.

using Thirdweb;

public async void ConnectWallet()
{
// Reference to your Thirdweb SDK
var sdk = ThirdwebManager.Instance.SDK;

// Configure the connection
var connection = new WalletConnection(
provider: WalletProvider.Metamask, // The wallet provider you want to connect to (Required)
chainId: 1 // The chain you want to connect to (Required)
);

// Connect the wallet
string address = await sdk.wallet.Connect(connection);
}

2. Using the ConnectWallet prefab

The ConnectWallet prefab allows users to connect their wallet to your game.

It uses the ThirdwebManager to determine which networks to display as well as the secondary UI related to certain providers such as WalletConnect.

You can set up which wallets you want to support from the Prefab_ConnectWallet Inspector directly.

When a user clicks the button, a dropdown of supported wallets will appear. The user can then select their preferred wallet to connect to the game; once connected, the button will show the users balance and an option to switch networks if multiple networks are set up through the ThirdwebManager.

The prefab is located at: Assets/Thirdweb/Examples/Prefabs/Prefab_ConnectWallet.prefab.