2

I am creating an instance of singer by passing the pvkey and provider, but after creating the instance of the contract i am not able to interact with it.

const signer =  new ethers.Wallet(pvKey,apiKey);
const erc20_rw = new ethers.Contract(address, abi, signer);

// getting the name of contract
let name = await erc20_rw.name()

console.log("name of contract ", name);

enter image description here

1 Answer 1

1

What is apiKey? Based on the name, I'm guessing it's just a string of your api key for whatever node provider you have (e.g. an Infura or Alchemy key). However it should be an instance of Provider, which you can get by passing in a url and/or an api key to the function ethers.getDefaultProvider

1
  • 1
    thanks for help, i already solved it. as you said we have to pass provider instance in wallet instance
    – DereK
    Mar 7 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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