getConnectedWallet()

Returns the wallet that the current signer was generated by. If there is no wallet connected the isConnected flag will be false and the address and balance properties will be undefined

Response

{
    "isConnected": "boolean",
    "address": "string | undefined",
    "balance": {
        "value": "BigNumber",
        "formatted": "string"
    } | "undefined"
}

The "value" field uses ethers.js BigNumber format due to the nature of how long balances can be. To get the actual value, reference the "formatted" property and this will return the string value in ETH/wETH/Sol.
You may also call the "toString()" method on the value and this will return the value in Wei, which is generally a very large number (see example below). If you are unsure how to handle Wei, then please use the "formatted" property.

Example Usage

const connectedWallet = await contract.getConnectedWallet();

console.log(connectedWallet.address);

const balanceValue = connectedWallet.balance.value.toString();

📘

Balances on Polygon
The SDK will return the user's balance of wETH on Polygon (not MATIC!)

You can then use an app like UniSwap to swap MATIC for wETH on Polygon:
https://app.uniswap.org/#/swap

Or you can use the Polygon Bridge to send wETH from Ethereum to Polygon:
https://wallet.polygon.technology/bridge

Logging

There are no logs emitted from this method.

Possible Errors

This function will never error. If there are any issues getting the currently connected wallet it will return the disconnected state e.g.

{    
    "isConnected": false,
    "address": undefined,
    "balance": undefined
} 

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.