I cannot work with Smart Contract using Node.js

Advertisements

I’ve been trying to link a smart contract with ethers.js in my project.

const Provider= new ethers.providers.JsonRpcProvider(
  `https://goerli.infura.io/v3/`
);

const TokenContract = new ethers.Contract(
TokenAddress,
abiSource.token.abi,
Provider
);`

I tried to run this but couldn’t get the balance of the token contract.
Extracted RPC link from the Metamask.
Who can help me with this problem?
Thanks in advance.

>Solution :

It seems like you didn’t use Infura georli api key.

const Provider= new ethers.providers.JsonRpcProvider(
  `https://goerli.infura.io/v3/ca11249dabe247c1a6e0877c24376dda`
);

Please try the above.
However, you must bring your own Infura API Key.

Leave a ReplyCancel reply