javascriptsolidityethers.jsether

ether.js accessing public views


I have 2 public views in my smart contract but when I try to access them with ether.js if I try with callStatic like that:

NVAContract.callStatic.calculateTotal(address)

it throws an error: callStatic undefined

If I try like that:

NVAContract.calculateTotal(address)

it asks for gas fees. (the contract and the abi are right, double checked the abi and the same contract object works when using write functions)


Solution

  • Fixed. I just realized I was using ethers.js 3, switching to version 4 fixed the problem.