Skip to main content

Connect Wallet Button

The ConnectWallet prefab allows users to connect their wallet to your game. It is intended for use in WebGL based games, where a browser environment is available; thus enabling the use of browser extensions such as MetaMask.

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.

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

Connect Wallet Button

Configuration

From the Inspector window, you can configure the options for the ConnectWallet prefab.

Supported Wallets

The list of wallets you want to support. Each wallet you provide appears as a button in the dropdown.

Supports Injected (window.ethereum), MetaMask, Coinbase Wallet, Wallet Connect, Magic Auth.

Support Switching Networks

The list of networks you want to support.

Once connected, users can switch between networks, each network you provide appears as an option.

Supports any of the default chains.

View default chains
  • Ethereum: "ethereum"
  • Goerli: "goerli"
  • Polygon: "polygon"
  • Mumbai: "mumbai"
  • Arbitrum One: "arbitrum"
  • Arbitrum Goerli: "arbitrum-goerli"
  • Optimism: "optimism"
  • Optimism Goerli Testnet: "optimism-goerli"
  • Binance SmartChain: "binance"
  • Binance SmartChain Testnet: "binance-testnet"
  • Fantom Opera: "fantom"
  • Fantom Testnet: "fantom-testnet"
  • Avalanche C Chain: "avalanche-fuji"
  • Avalanche Fuji Testnet: "avalanche-fuji-testnet"
  • Localhost: "localhost"

Custom Callbacks

Custom logic to run whenever an event occurs on the button, including:

  • OnConnected: Triggered when the user connects their wallet successfully.
  • OnDisconnected: Triggered when the user disconnects their wallet successfully.
  • OnSwitchNetwork: Triggered when the user switches networks successfully.
  • OnFailedConnect: Triggered when the user fails to connect their wallet.
  • OnFailedDisconnect: Triggered when an error occurs after attempting to disconnect a wallet.
  • OnFailedSwitchNetwork: Triggered when an error occurs after attempting to switch networks.