0

I'm building a Dapp and when i im click the mint button i get this error

Error: Provided address undefined is invalid, the capitalization checksum test failed, or it's an indirect IBAN address which can't be converted.

and this is how my code looks like

export const publicSale = async (mintAmount) => {
if(window.ethereum.selectedWallet) {
    return {
        success : false,
        status : 'To be able to mint, you need to connect your wallet'
    }
}

const nonce = await web3.eth.getTransactionCount(window.ethereum.selectedWallet, 'latest');
const tx = {
    to : config.contractAddress,
    from : window.ethereum.selectedWallet,
    value : parseInt(web3.util.toWei(String(config.price * mintAmount), 'ether')).toString(16),
    gas : String(30000 * mintAmount),
    data : NFTContract.methods.publicSaleMint(mintAmount).encodeABI(),
    nonce : nonce.toString(16)
}

try {
    const txHash = await window.ethereum.request({
        method : 'eth_sendTransaction',
        params : [tx]
    });

    return {
        success : true,
        status : 'You have successfully minted your NFT'
    }
} catch (error) {
    return {
        success : false,
        status : 'Somthing went wrong ' + error.message
    }
}

}

this is where the error goes

102 | const nonce = await web3.eth.getTransactionCount(window.ethereum.selectedWallet, 'latest');

1 Answer 1

0

If this is all the code, it looks like you don't have a function to connect the users wallet. Also it should be: window.ethereum.selectedAddress not window.ethereum.selectedWallet

you have to use window.ethereum.request here is one way of doing this :

if(window.ethereum){
   try {
      const accounts = await window.ethereum.request({
         method: "eth_requestAccounts",
      });
      console.log(accounts)           
   } catch (error) {
      console.log(error)
   }
}

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.