Checking for a Wallet

Learn how to connect a wallet with a smart contract.

We'll cover the following...

Overview

Our application will require the user to have a wallet extension (such as MetaMask) available on their browser. The wallet is needed so that whoever deploys the contract can sign the transaction and pay the necessary gas for the operation.

We can see if the user has a wallet extension by checking if the window.ethereum object exists.

Press + to interact
export default function Home() {
// new addition
const checkIfWalletIsConnected = () => {
return Boolean(window.ethereum);
};
return (
<div>
<main>Home</main>
</div>
);
}

We want ...