0

I have an nftmarket site. How do I link Metamask wallet to transact on my site. Artists will sell nft through my site, so how do I connect the metamask?

1 Answer 1

0

I give you basic and simplest code for connect metamask form using ethers. For more ways to connect metamask wallet read you can prefer is metamask docs.

import {ethers} from 'ethers'

const connectWalletHandler = () => {
        if (window.ethereum && window.ethereum.isMetaMask) {
            console.log('MetaMask Here!');

            window.ethereum.request({ method: 'eth_requestAccounts'})
            .then(result => {
                accountChangedHandler(result[0]);
                setConnButtonText('Wallet Connected');
                getAccountBalance(result[0]);
            })
            .catch(error => {
                setErrorMessage(error.message);
            
            });

        } else {
            console.log('Need to install MetaMask');
            setErrorMessage('Please install MetaMask browser extension to interact');
        }
    }
3
  • thank you can you send me your e-mail I want to talk to you or can you give me your watsapp number Commented Mar 17, 2022 at 7:25
  • Sorry but I can't give you my whatsapp number. Commented Mar 17, 2022 at 7:32
  • can you email me i want help Commented Mar 17, 2022 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.