0

Unexpected error calling ethereum contract using web3.js

MyContract.methods.actual_balance("0xE8D.........").call({})
.then(r=>{
    console.log(r)
}).catch(err=>{
    console.log(err)
})

I'm getting error:

{ Error: Returned error: err: max fee per gas less than block base fee: address 0x4..., maxFeePerGas: 3000000000 baseFee: 42784084648 (supplied gas 4700000)...

That is nonsense, I'm not sending transaction (send) but just querying state from local ledger. How is this posible? Moreover, it was working an suddenly broke

5
  • Maybe try to remove the {} inside the call? Sep 23 at 23:28
  • Thanks, but it initially was without {}. I added it trying to fix the problem
    – Igoos
    Sep 24 at 6:17
  • Can you share more details about the network and provider used? Ethereum mainnet, testnet, or some other l2 network. Web3 version used, and if it was working previously.
    – Ismael
    Sep 25 at 22:18
  • 1
    Try changing the {} to {gasPrice:undefined}. The reason it happens is because the current baseFee (eip-1559 value) is higher than whatever is getting set - usually explicitly setting it as undefined, in my experience, allows it to succeed
    – natewelch_
    Sep 27 at 14:13
  • Thanks everyone. The issues was that web3 contract instance has gasPrice set too low, as natewelch_ wrote.
    – Igoos
    Sep 28 at 15:36
1

web3 contract instance had gasPrice set very low. You can use https://ethgasstation.info/ to get actual price. I didn't knew that it does meters when you .call() not .send()

0

If this function is just a view function then no gas should be required. Maybe your ABI was altered and when you make the instance of the contract locally, the web3 library thinks that this requires some gas cause it is changing the state

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.