I am entirely unsure what the root cause is, but every time I use web3.eth.estimateGas with my call's parameters, it results in the last blocks gas limit as the result (~8 million). I have even tested with a normal transaction which should result in 21,000 gas, but gives around 8 million. Not sure if a limitation of using infura nodes or a implementation issue.
// Get the gas estimate for the current transaction
window.web3.eth.estimateGas({
from: transactionData.params[0].from,
to: transactionData.params[0].to,
data: transactionData.params[0].data,
value: transactionData.params[0].value,
nonce: transactionData.params[0].nonce
}, function(error, result) {
console.log(result)l
}
Here is more specifically the way I am calling the API. Any suggestions?
UPDATE: I have a workaround, instead of using web3, I directly call Infura's eth_estiamteGas with a https POST. https://infura.io/docs/ethereum/json-rpc/eth_estimateGas