Calling a view function using Truffle console error code: -32000,

I am trying to interact with a smart contract i deployed half a year ago (before EIP1559)
my truffle config is setup as follows for the main eth network:

main: {
      provider: () => new HDWalletProvider(pkArrayMain, mainSpeedyNode, 0, 6),
      network_id: 1, // Main's id
      gas: 6700000, 
      gasPrice: 20000000000,
      confirmations: 2,
      timeoutBlocks: 50,
      skipDryRun: true, 
    },

then go into the truffle console using

truffle console --network main

then when im in the truffle console I run

const instance = await MyContract.deployed();
await instance.cap();

then i get hit with the following error

Uncaught:
{
  code: -32000,
  message: 'err: insufficient funds for gas * price + value: address ###i have delete my address for privacy### have 0 want 10000000000000000000 (supplied gas 50000000)'
}

why is it asking for eth when im simplying trying to call a view function?

I followed the exact same steps on the contract i deployed on Rinkeby and it worked how it expected it.
has there been some change since eip1559 that call functions now require gas???
its an old project which i havent updated the packages so im running @truffle/hdwallet-provider": “^1.6.0”.

any help would be really appreciated as its taking me ages to sort out a problem that shouldnt even be there.
If more info is required please let me know.
Thanks in advance.

do you need truffle to interact with that smart contract (assuming that it is already deployed on mainnet)?

yes and no.
I am comfortable using truffle as this is how I was taught following the IvanOnTech academy courses. however if there is a new and improved way im happy to learn.

I mean you can use Moralis.executeFunction for example, but you will have to know the ABI for your smart contract.
https://docs.moralis.io/moralis-server/web3/web3#executefunction

or runContractFunction: https://docs.moralis.io/moralis-server/web3-sdk/native#runcontractfunction

1 Like

yes i have the abi, ill give it a go thanks.