Unity SDK

Thirdweb Manager

The ThirdwebManager is a prefab that provides a convenient way to instantiate the ThirdwebClient, and contains helper functions to create contracts and wallets. Add the prefab to your scene and the client will persist throughout your game's lifecycle, keeping track of your connected wallets.

It is entirely optional, and you can opt to use the .NET SDK directly if you prefer to do so.

If you are wrapping the SDK, we recommend making your own Manager inspired by ThirdwebManager.cs that extends ThirdwebManagerBase.cs, specifically for ThirdwebClient initialization. Every method and property is virtual and can be overridden.

Configuration

Configure ThirdwebManager through the Unity Inspector window.

Below is a list of all the settings you can adjust.

Client

This section configures the ThirdwebClient instance that the manager creates at runtime:

  • Client ID: Required thirdweb API Key. Without it, ThirdwebManager refuses to initialize and logs an error.
  • Bundle ID: Optional identifier used for native redirect URIs. If left blank, the manager falls back to Application.identifier (or com.<Company>.<Product> when no identifier is set).
  • Create API Key: Opens the dashboard so you can generate a fresh API key.

Preferences

Use these toggles to shape how the manager boots and reports information:

  • Initialize On Awake: Automatically calls Initialize() during Awake. Disable it if you need to delay initialization or swap credentials at runtime.
  • Show Debug Logs: Mirrors ThirdwebDebug.IsEnabled, enabling verbose diagnostics during development.
  • Auto-Connect Last Wallet: Persists the most recent WalletOptions to PlayerPrefs and reconnects on startup (including smart-wallet upgrades). Errors in this flow are swallowed and logged.

Miscellaneous

Fine-tune the runtime behaviour of authentication and networking here:

  • RPC Overrides: Per-chain RPC endpoints stored as ChainIdURL pairs. When populated, these replace the default thirdweb RPCs for the matching chains.
  • OAuth Redirect Page HTML Override: Multiline HTML snippet used by the in-app and ecosystem OAuth flows (including external browser handoffs). Provide custom markup only if you know the full redirect requirements.

Debug

Quick utilities exposed by the custom inspector:

  • Log Active Wallet Info: Available in Play Mode; prints the current ActiveWallet type and address to the Unity Console.
  • Open Documentation: Launches the hosted Unity SDK documentation in your default browser.

Interacting with the ThirdwebManager

Once your ThirdwebManager is set up, you can interact with it using the following methods:

Initialize (If not set to Initialize On Awake)

ThirdwebManager.Instance.Initialize();

Initializes the SDK with the settings specified in the Unity Inspector.

ConnectWallet

var walletOptions = new WalletOptions(
provider: WalletProvider.EcosystemWallet,
chainId: 1,
inAppWalletOptions: new InAppWalletOptions(authprovider: AuthProvider.Guest)
);
var wallet = await ThirdwebManager.Instance.ConnectWallet(walletOptions);
var address = await wallet.GetAddress();
ThirdwebDebug.Log($"Connected wallet address: {address}");

Connects a wallet based on the specified WalletOptions and returns an IThirdwebWallet instance that can be used to interact with the blockchain.

UpgradeToSmartWallet

var smartWallet = await ThirdwebManager.Instance.UpgradeToSmartWallet(wallet, chainId, smartWalletOptions);

Upgrades the specified wallet to a SmartWallet, returning a SmartWallet instance.

ActiveWallet

var activeWallet = ThirdwebManager.Instance.ActiveWallet;
var address = await activeWallet.GetAddress();

Returns the last connected wallet as an IThirdwebWallet instance, or null if no wallet is connected.

GetContract

var contract = await ThirdwebManager.Instance.GetContract("contract-address", chainId, "optional-contract-abi");
var result = await contract.Read<string>("name");

Returns a ThirdwebContract instance that can be used to interact with a smart contract.

LinkAccount

var linkedAccounts = await ThirdwebManager.Instance.LinkAccount(mainWallet, walletToLink, otp, chainId, jwtOrPayload);

Links another InAppWallet or EcosystemWallet account to the main wallet and returns a list of linked accounts, allowing you to login with either authentication method later.

Child Prefabs

DefaultOTPModal

The helper modal that is displayed when using the ThirdwebManager's ConnectWallet function with an auth method that requires an OTP, such as Email or Phone login.

It can be replaced with a custom modal that extends AbstractOTPVerifyModal to customize the OTP verification process.

What Now?

Explore the .NET SDK to learn more about interacting with smart contracts, wallets, storage, RPC, account abstraction, and more.