Connect()

For EVM

Asks the user to select what wallet they want to connect to from the currently supported wallets list. Calling this function triggers a wallet selector when there is no wallet selected. When there is a wallet already connected, the disconnect function should be called first to re-trigger the wallet selector.

Currently Supported Wallets

  • MetaMask
  • Coinbase Wallet
  • All wallets with access to WalletConnect

Example Usage

await contract.connect();

After calling connect, the SDK will attempt to communicate with the user's wallet. This will cause the wallet extension to issue a modal to the user to interact with, or it will cause a notification icon to display on the wallet extension icon. For EVM, if the users wallet is currently set to a different network to the one the current contract is configured to use, the user will be prompted to switch networks inside the wallet UI.

Logging

The SDK will prefix all logs from connect() with HM (connect) -

Success

When a user successfully connects their wallet a "Connected" message will be displayed in the console

Possible Errors

  • Failed selecting wallet
    • The user did not select a valid wallet
  • Failed to select network
    • The wallet was unable to add the configured chain. This is if the wallet doesn't support this chain or the SDK does not support the configured chain.
  • No accounts found
    • The user has no accounts setup in the selected wallet

Feedback

Something not quite right, unclear or can't find what you are looking for? Please let us know at support.moonpay.com and we will get back to you as soon as we can.