Skip to main content

Connect User Wallets

Ask users to connect their wallets to your game. This allows you to ask them to sign transactions.

To write transactions to the blockchain, you must have a connected wallet first.

// Ask the user to connect their wallet and read their wallet address.
string address = await sdk.wallet.Connect();

Connect to a particular Wallet provider

You can pick and choose how you want your users to connect to your application. The SDK supports:

  • MetaMask
  • Coinbase Wallet
  • WalletConnect
  • any injected browser extension like TrustWallet and others.

You can also specify which chain you want your users to connect to, here's an example:

// Connect to the user's wallet via CoinbaseWallet
string address = await sdk.wallet.Connect(new WalletConnection()
provider = WalletProvider.CoinbaseWallet,
chainId = 5 // Switch the wallet Goerli on connection

Read Wallet Information

Once connected, you can access information about the user's Wallet.

// For example, we can now read the user's native token balance.
var balance = await sdk.wallet.GetBalance();