Ethereum (Metamask)
Integrate with MetaMask wallet
To connect to MetaMask Wallet, import connectToMetaMask
import { connectToMetaMask } from "api/wallet";
Call it whenever you want to trigger a MetaMask connection.
const doConnectToMetaMask = async () => {
await connectToMetaMask()
.then(async (res) => {
const address = res?.ethAddress;
// your address is ready inside resEthAddress
})
.catch((err) => {
// An error occurred while connecting to metamask
});
};
Connect the function to a button.
<button onClick={doConnectToMetaMask}>Connect to Finnie</button>
And that's it. Your connection is ready and you have the address.