1 year ago

#314304

test-img

Jazflyer

Error: Provider does not have a request or send method to use

I am using Metamask and I am trying to interact with a contract on the AVAX blockchain. I am using web3.js and when I try to interact with the contract, I get the error,

Error: Provider does not have a request or send method to use.

Does metamask not allow for this type of contract interaction? If so, is there a workaround?

This is how I am detecting and then attempting to interact with the contract.

async function printAccts() {
  const provider = await detectEthereumProvider();

  if (provider) {
    // From now on, this should always be true:
    // provider === window.ethereum
    console.log(await provider.request({method: 'eth_requestAccounts'}));
    await provider.request({method: 'eth_sendTransaction'});
  } else {
    console.log('Please install MetaMask!');
  }
}


export const buy = async (amount: number) => {
  const contract = new Contract(abi, '0x82194f7d4Ded53A546ec4e3A7a57f81C5a54E194');
  console.log("transaction sent");
  await contract.methods.transfer("0x0000000", amount).send({from: "0x000000"});
  console.log("transaction sent really");
}

I have my address where the 0x0000's are, just not shown in the example

blockchain

web3js

metamask

avalanche

0 Answers

Your Answer

Accepted video resources