Questions tagged [gas-estimate]

The tag has no usage guidance.

134 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
6 votes
0 answers
101 views

Deploy gas issue for require reason string

I found a strange case and didn't find out why. ... modifier onlyMaster() { require(msg.sender == master || msg.sender == developer, "caller is not the master"); _; } ... ...
webelf000's user avatar
  • 126
5 votes
1 answer
811 views

Can't debug transactions that fail during the Web3.js estimateGas() call? No Tx Hash

NOTE: I am doing my work with the Ganache v1.2.2 GUI client on a Linux Ubuntu 18.04 station. There are many revert errors that happen during the estimateGas() call that precedes the actual Web3.js ...
Robert Oschler's user avatar
4 votes
0 answers
194 views

Does 'estimateGas' behave the same on Ganache and on mainnet?

I noticed that estimateGas behavior in Ganache has changed: In version 6.4.1, it throws an exception if exceeding the gas-limit. In version 6.5.1, it returns the estimation even if exceeding the gas-...
goodvibration's user avatar
4 votes
1 answer
193 views

Testrpc transactions are failing. How do I perform a transaction when Mist cannot estimate gas?

I am attempting to perform transactions and create contracts using EthereumJS Testrpc. I set it up by running the following: Terminal 1: testrpc Terminal 2: mist --rpc localhost:8545 Running both ...
user avatar
3 votes
0 answers
43 views

Elegant way to purposefully charge more gas in a smart contract

I am trying to run tests to see how much a smart contract will cost, but since I am in my research period, I have to make some assumptions on how my smart contract will be developed. I would like to ...
Barney Chambers's user avatar
3 votes
0 answers
216 views

Does brownie have functionality to analyze gas costs for all function calls?

Does brownie have any sort of functionality that gives a breakdown of the cost to deploy all contracts and execute all function calls within a brownie project with min, max and average gas cost ...
MShakeG's user avatar
  • 1,054
3 votes
1 answer
1k views

Ethers and Web3-React: Cannot estimate gas when trying to connect with contracts deployed on testnet and using Alchemy as node provider

I'm trying to connect with contracts deployed on the Rinkeby testnet using a node provider. When I was testing using hardhat as a local node, the contracts are called with no problem, but when I ...
Dan's user avatar
  • 31
3 votes
2 answers
3k views

Constantly getting "Gas estimation failed" error when attempting to deploy ERC20 Token contract on Rinkeby testnet

I have included the code for the contract below. The error I get when attempting to deploy in remix via metamask is: Gas estimation errored with the following message (see below). The transaction ...
John Murphy's user avatar
2 votes
0 answers
24 views

Understanding the Inner Workings of eth_estimateGas in Smart Contracts

I'm seeking clarification on how the eth_estimateGas function operates under the hood. Does it run the smart contract in a manner similar to a dry run? When I make a call to eth_estimateGas, and I've ...
undefined's user avatar
  • 121
2 votes
0 answers
23 views

What values for the global state variables does geth use for estimateGas?

What values for the global state variables does geth use for estimateGas? For example, block.timestamp.
out.eth's user avatar
  • 21
2 votes
0 answers
390 views

Is gasleft() the best way to manage big loops in solidity?

I'm developing an Smart Contract that has to iterate through an undetermined size list of ERC20 tokens, and make a swap for each token. I'm aware that you cannot loop an undetermined size list, ...
Alexander Herranz's user avatar
2 votes
1 answer
2k views

Automated gas cost calculation in Hardhat?

Context I've learned from this question that it is not (always) possible to compute the gas-costs of an arbitrary solidity contract a.sol because the amount of computation that it takes may depend on ...
a.t.'s user avatar
  • 65
2 votes
1 answer
179 views

How estimateGas works internally?

I am building a sniper bot which continually estimating the gas for buying one token. Once the gas is successfully estimated, a transaction to buy the token is sent. But for many times it estimated ...
Jettie's user avatar
  • 41
2 votes
1 answer
782 views

gas fee on OpenSea

First, I'm brand new to the Ethereum platform, so I do apologise if any of the following is considered stupid questions. Now, I will ask my question anyway I am setting up the first sale of one of my ...
Mohamed Dabbous's user avatar
2 votes
0 answers
121 views

how to estimate the gas cost of a contract function that will fail

I am trying to estimate the gas cost of a contract function that will fail. when i do that using standard web3.py's contract.function(args).estimateGas(txArgs) it ends up failing and raising an ...
Kaki Master Of Time's user avatar
2 votes
0 answers
155 views

What Web3JS method do I call to know what value to use for the gas price with sendSignedTransaction?

I am using Web3JS 1.0+ to send transactions to my smart contract. I've been using the following constant for the gas price in my code that I got a long time ago from a tutorial. What is the "...
Robert Oschler's user avatar
2 votes
1 answer
68 views

Why use different gas?

I have this contract with this functions, why each use different gas amount? pragma solidity 0.4.24; contract Foo { //transaction cost: 21471 gas //execution cost: 199 gas //total cost: 21670 ...
Alfredo Egaf's user avatar
2 votes
0 answers
245 views

Gas cost of adding an item to a class-level (storage) array

I would like to make sure that the gas cost of adding an item to a (storage) array is constant, i.e., not dependent on the length of the array. To my understanding, the relevant EVM operation is ...
goodvibration's user avatar
2 votes
1 answer
498 views

Alternative solution for loops in subscription smart contract design

I am a new developer, working on a smart contract mostly for my own learning. I am developing a Smart Contract to handle subscriptions. The contract has the below features. Subscribers can subscribe ...
Colm Seale's user avatar
2 votes
1 answer
224 views

Can the behaviour of the Ropsten Test net be compared to that of the main net?

can be assumed, that a contract behaves in the same way on the Ropsten Test test as well as on the main net, in terms of gas consumption for example? (I think, that the gas price might be different?) ...
cryptovale.eth's user avatar
2 votes
0 answers
302 views

Calculating Gas Remaining at Specific Point in Execution of Contract

This is a doozy :~) I'm trying to figure out the amount of gas remaining in some contract at some specific step. For example: function hash(uint num) returns (bytes32) { return sha3(num, msg....
Nate Rush's user avatar
  • 770
2 votes
0 answers
629 views

Why is there a difference between eth.estimateGas and the real cost in testRPC?

When I want to deploy a smart contract, I use the eth.estimateGas before deploying my smart contract. This gave me 688180 Gas. let bytecode = compiledContract.contracts['Document'].bytecode; let ...
FrenchieiSverige's user avatar
2 votes
0 answers
147 views

Populus cannot deploy contract related to estimated gas is not enough error

I am using populus. Platform darwin -- Python 2.7.12, pytest-3.0.2, py-1.4.31, pluggy-0.3.1 Plugins: populus-1.1.0 OS: Mac OS X I do face with following error: for the following line on my test.py ...
alper's user avatar
  • 8,298
1 vote
2 answers
51 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
  • 195
1 vote
1 answer
625 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
41 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
31 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
  • 33
1 vote
0 answers
25 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
225 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
28 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
16 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
379 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
189 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
213 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
80 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
682 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
  • 113
1 vote
0 answers
485 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
173 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
18 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
420 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
198 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
87 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
0 answers
405 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
166 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
235 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
490 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
0 answers
295 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
46 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
65 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