Skip to main content

Questions tagged [gas-estimate]

Filter by
Sorted by
Tagged with
1 vote
1 answer
1k views

JSON-RPC estimate gas error

I am calling method with params: { "jsonrpc":"2.0", "method":"eth_estimateGas", "params": [ { "to": "0x8f0921f30555624143d427b340b1156914882c10", "data":"...
ItsMyLife's user avatar
  • 145
1 vote
1 answer
393 views

Infinite gas estimate for an empty function

I have an empty function like below: function myFunction(int[24] param1, int param2) public returns (int s) { } When I calculate the estimated gas value of this empty function, Remix is telling that ...
Önder Gürcan's user avatar
1 vote
1 answer
105 views

Where does gas comes from when I create a new Contract in a Contract [duplicate]

Let's say I am creating a contract from another contract by calling a function in a parent contract, is the gas required to create new contract included in running the function that creates new ...
Harwee's user avatar
  • 111
1 vote
2 answers
2k views

Transaction fails due to: Insufficient funds for gas * price + value

I am trying to make transactions on Polygon Mainnet, but unfortunately when I automatically try to calculate the transaction fees, the transaction gets reverted because I assume that the fees are to ...
Dakata's user avatar
  • 255
1 vote
1 answer
142 views

Simple operation causes Remix gas estimate to become infinite [duplicate]

Completely new to using Remix (first few hours of using it) but confused by this behaviour. In the simple code example below using Remix, why does an operation as simple as incrementing a uint256 (...
cryptophile's user avatar
1 vote
1 answer
490 views

EtherJS calculates gas fee too low

newbie here so please bear with me. I am using EthersJS latest v5 in order to interact with our contracts, which works great so far. However, I spotted that for a certain period of time (around 1st ...
supersize's user avatar
1 vote
1 answer
1k views

Estimate Gas from a smart contract on polygon with ethers

I deployed a smart contract on polygon mainnet and want to estiamte gas costs before calling the function. This is my smart contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.4; import &...
Dani S's user avatar
  • 21
1 vote
1 answer
70 views

Gas cost of mapping operations

Suppose, your contract has something like if (_balances[account] >= someNumber) { _balances[account] = _balances[account] - _balances[account]/10; } What is the gas cost of this operation? I ...
dnnagy's user avatar
  • 111
1 vote
2 answers
41 views

Predict future gas price

I am wondering, is there a way to "predict" future gas prices? I would like to find a gas price or at least approximation of it for the future block, so the one that is currently pending.
Kacper's user avatar
  • 43
1 vote
0 answers
45 views

Complex factory optimization

After two and a half years of developing smart contracts on a non-EVM blockchain (Tezos), I started working on a few solidity projects, and I'm trying to understand some things. I built a factory ...
Aharon Lando's user avatar
1 vote
0 answers
397 views

estimateGas with prerequisites (gas estimation requires approvals first)

I am trying to estimateGas for an Ethereum transaction with ethers signer.estimateGas(). This transaction should execute several trades on arbitrary DEXs. To execute the transaction approvals of ERC-...
Philipp Schweiger's user avatar
1 vote
0 answers
158 views

tx.gasprice gives wrong gas estimation

I am using tx.gasprice and block.basefee in my contract to calculate the used gas. The problem is that I can't estimate the gas correctly or sometimes not at all when the contract uses tx.gasprice;. ...
Marvin Daum's user avatar
1 vote
0 answers
35 views

Deterministic gas use

In ether, any pure ether transfer will always cost 21000 gas. However, due to the nature of the MPT used in the Balances tree, wouldn't some addresses have more layers of the tree to hop through and ...
Anton M's user avatar
  • 11
1 vote
0 answers
17 views

NodeJs or Python libraries for estimating the gas costs

I am looking for libraries in Python or NodeJs which can provide gas cost estimations like the one provided by Hardhat. Please share knowledge you have regarding this..
user111771's user avatar
1 vote
0 answers
481 views

Gas estimation failed error

Following error is coming: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution reverted { "...
Suraj Sahoo's user avatar
1 vote
0 answers
233 views

Low level question about how eth_estimateGas interacts with state changes

i'm new here, i have a pretty weird question. Do you guys know how eth_estimateGas works at low level? In particular, do you guys know how it interacts with state changes? Let's say for example i have ...
Davide Rossi's user avatar
1 vote
0 answers
219 views

getting error while calling getrandomnumber in my smart contract

error message: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution reverted { "originalError": {...
Raaj Vashitva's user avatar
1 vote
0 answers
88 views

Maximum gas estimate

eth_estimateGas provides estimated final gas consumed by transaction and accounts for gas refund in the end of transaction. However, is there a way to estimate maximum gas the transaction may consume ...
pokrovskyy's user avatar
1 vote
0 answers
892 views

How does web3.eth.estimateGas work?

I have tested two situations using "web3.eth.estimateGas" to estimate the gas cost of contract transaction. First one is to get contract by the address of a deployed contract and estimate ...
Yuhua Wei's user avatar
  • 123
1 vote
0 answers
573 views

Ethersjs estimateGas bypassing insufficient funds

I am using ethersjs to call my contract methods. The problem stems from trying to making the Metamask popup despite the account has insufficient funds in the first place. I am trying to do the popup ...
MongChangHsi's user avatar
1 vote
1 answer
191 views

estimate gas usage for a contract

I'm trying to estimate the gas usage for a smart contract for an NFT token - is it possible to do before the actual sale? contract is already published and all functions as well. so I want to know how ...
teggr234's user avatar
1 vote
1 answer
20 views

why did this transfer transaction fail on eth?

https://etherscan.io/tx/0x8ad822a326243e69c4d5bcd3fe07466a82c2c00edbc53cbc0a211c6efbdd7dd2 checked ethgasstation and doubled the gas but it still failed, any ideas why it would?
user89380's user avatar
1 vote
1 answer
195 views

Error when trying to estimateGas()

I'm getting the following error: { code: 13, message: 'execution simulation failed: status = 106' } When executing this code: const gasEstimate = await WJEWELContract.methods.mint(amount).estimateGas(...
Falcon Stakepool's user avatar
1 vote
1 answer
635 views

Estimated Gas in JS Doesn't Match Metamask Gas Fee

I need help with figuring out the estimated gas for an approval. I'm able to get a number but it doesn't match what's in metamask. I'm a noob to web3 and so I'm not even sure I'm passing the correct ...
Chris's user avatar
  • 131
1 vote
0 answers
1k views

Hardhat estimatedGas error on smart contract deployment

I'm getting the following error when trying to deploy to BSC testnet: Hardhat Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"name":"...
AMG's user avatar
  • 11
1 vote
1 answer
205 views

Discrepancy in gas prices in ENS

I'm a bit confused, I'm trying to buy a domain name in https://ens.domains/ and the price is extremely high for a domain name, it's about $150. Most of that price comes from gas fees. The confusing ...
nelson687's user avatar
  • 113
1 vote
1 answer
209 views

Efficiently Accessing Mappings

I'm working on keeping track of data via a struct stored in a mapping. mapping(uint256 => Session); Here is the Session struct: struct Session { // UID uint256 id; // Timestamp ...
cypher.build's user avatar
1 vote
1 answer
103 views

Are named returns more expensive?

Say I have the following Smart Contract: // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.7; contract Test { function f1(uint256 a, uint256 b) external pure returns(uint256) { ...
António Gonçalves's user avatar
1 vote
1 answer
213 views

Storing constants in Storage vs Creating a view function? (Solidity 0.5.17)

So, which would be gas efficient? Reading a storage variable in a state-changing function? OR Reading from a pure function in a state-changing function? Example: contract Test { uint256 public a = ...
remedcu's user avatar
  • 372
1 vote
0 answers
482 views

Understanding eth_estimateGas with regards to gas price, and current mempool

Does anyone have a detailed understanding of how eth_estimateGas works with regards to gasPrice and the current mempool state? I have historically seen some really odd behavior when using ...
LampShade's user avatar
  • 640
1 vote
0 answers
27 views

I don't know why my contract have a problem. Gas estimation and Gas exceeds Problem [closed]

pragma solidity >=0.4.24 <=0.5.6; contract Indian { mapping (address => uint16) myGame; address public owner; constructor() public { owner = msg.sender; } ...
InChl Song's user avatar
1 vote
0 answers
204 views

Execution erorr: Invalid opcode on estimateGas | Possible unhandled promise rejection

pragma solidity ^0.5.0; I get invalid opcode error when trying to estimate gas needed for my transaction from react-native using the following line of code: const gasAmount = await contract.methods ...
user63058's user avatar
1 vote
1 answer
248 views

gas estimate in loop

I have two contract. I call function placeBid in other contract and i have warning gas estimation. help me. thanks. Can i call function which use gas in loop through other contract? How i can get ...
modernToking's user avatar
1 vote
0 answers
493 views

Gas estimation errored with the following message (see below). The transaction execution will likely fail

When I try to excute the deposit function it shows Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution ...
chen Crush's user avatar
1 vote
1 answer
255 views

How to calculate "gas" and "gasPrice" when referring to ethgasstation.info when sending transaction via web3js?

I'm using web3js to issue token which has a name and description. I'm using ropsten testnet. Here's my tx. const tx = { from: walletAddress, to: contractAddress, gas: 4700000, ...
TThom's user avatar
  • 49
1 vote
0 answers
310 views

Is there a way to calculate gas usage of external function call?

I have an external view function which has an iteration loop. If the contract's totalSupply gets bigger, then the iteration time will grow as well. I'm testing on rinkeby right now, but when I launch ...
Jung Chun's user avatar
  • 191
1 vote
0 answers
51 views

function gas calculator and function gas padding

not sure if this is possible, but I was wondering if one function can calculate the gas cost of another function? Also can a function run a series of computations to match the gas cost of the ...
jpowell79's user avatar
1 vote
0 answers
72 views

Vyper OPCODES gas estimate at compile time

I am trying to dissect Vyper at lower levels to understand how the gas estimates are generated. I tried following the yellow paper and I searched every single line of the compiler but I can't get it ...
AlmostInsane's user avatar
1 vote
1 answer
89 views

Loop with upper bound of iterations / loop variant

Is it possible somehow to create a loop that solidity will recognize as having an upper bound of iterations for gas estimations? Something like a loop variant in Eiffel (https://www.eiffel.org/doc/...
matthias_buehlmann's user avatar
1 vote
0 answers
231 views

What's the point in the 'gas' parameter passed to function 'signTransaction'? [duplicate]

I am using web3.js v1 in order to sign and send transactions: async function signAndSend(transaction) { let options = { to : transaction._parent._address, data: transaction....
goodvibration's user avatar
1 vote
0 answers
66 views

Why does address.transfer(amount) cost the same when sent to a new or used address?

In the Ethereum yellow-paper, it's specified that creating a new account costs 25000 gas (Appendix G, entry for Gnewaccount). We can see this if, for example, we call a function that makes a transfer:...
Enrique Alcazar's user avatar
1 vote
1 answer
98 views

Calculating a minimum entry fee for a game based on typical minimum gas requirements?

I am creating a dApp that is a game where players compete for the prize pool and that pool is built from the sum of all the entry fees payed by the player at the start of the game. The player that ...
Robert Oschler's user avatar
1 vote
0 answers
33 views

Gas estimation failed when trying to input a list of bytes32[5]

I am trying to create a struct as shown in the code below. The function setData is intended to create an object of the struct, take the inputs (a string and a list of type bytes32[5]) and set their ...
blockchainenth's user avatar
1 vote
0 answers
572 views

Error: gas required exceeds allowance or always failing transaction

I am calling contract's method from javascript. It throws error as: <pre>Error: gas required exceeds allowance or always failing transaction <br> &nbsp; &nbsp;at Object....
HARESH's user avatar
  • 73
1 vote
1 answer
483 views

Gas estimation: inconcistency between Python Web3 and NodeJS Web3

Python Web3 and NodeJS Web3 are giving me completely different gas estimations (with NodeJS Web3 estimation being approximately 3 times larger than Python Web3 estimation). My Python Web3 version is ...
goodvibration's user avatar
1 vote
0 answers
404 views

Contract deploy estimateGas undefined

When ti try to estimate gas for my contract to deploy, I always get undefined result. This is my code: const toDeploy = contract.deploy({ data: '0x' + bytecode, arguments: [[web3.utils....
imfabio's user avatar
  • 11
1 vote
2 answers
1k views

Maximum gas consumption of calling a contract method

I want to evaluate the maximum gas consumption (minimum safe gas limit that will not fail) that calling a specific contract method would consume given that I have the contract source code / byte code. ...
Amit's user avatar
  • 13
1 vote
0 answers
815 views

my_contract,estimateGas() crashes and "eth_estimateGas" returns incorrect value

I'm trying to estimate Gas for a contract method (both using parity and geth - tried web3py and web3js). Contract is deployed and proven to be working. When I use: estimateGas and geth (providing: ...
JackinHouse's user avatar
1 vote
2 answers
217 views

How gas used by a miner is verified?

The more gas used, the more profit a miner earns. So miners can simply say that the transaction ran out of gas without even executing the transaction and updating the state. JITVM optimizes the byte-...
Narayan Prusty's user avatar
1 vote
2 answers
2k views

How to estimate gas for a function without any input parameter?

How to estimate gas for a contract function that doesn't take any input parameter bu changes state? For eg, function buy() returns (uint amount){ amount = msg.value / buyPrice; ...
Prashant Prabhakar Singh's user avatar

1 2 3
4
5
8