Questions tagged [gas-estimate]
The gas-estimate tag has no usage guidance.
356 questions
3
votes
2
answers
225
views
Is there an estimate of average (e.g. monthly) gas usage per user?
With the whole discussion around "network value", I'm wondering how much gas the average account uses on a periodical basis.
Let's say that the relevant account pool consists of any account that has ...
3
votes
1
answer
377
views
Unreal big gas consumption for contract deploying
I have a big contract (more then 1000 strings of code). I deploy it without any problems. When i estimate the gas consumption
let gas_need = Web3Helpers.web3.eth.estimateGas({data: code});
console....
3
votes
2
answers
310
views
Does execution of same function in a contract uses different amount of gas each time it's executed
1-Does execution of same function in a contract uses different amount of gas each time it's executed?
2-Also if same function (for eg, transfer() function) is written in two different contracts, ...
3
votes
2
answers
5k
views
Ethers js estimateGas() without needing ETH in account
I am trying to estimate the gas used for a uniswap transaction. I am able to perform this on the Kovan testnet however when I try and run the same script on the mainnet it raises an error, "Error:...
3
votes
2
answers
9k
views
ethers.js - estimating gas limit
Using the ethers.js library, how can I determine the gas limit when sending a transaction to a contract or deploying a new contract?
3
votes
2
answers
3k
views
Gas estimation failed in Remix
Can't really use the transfer function as it is written. It assumes the owner uses it. So made a new function for the "minting" function for the faucet to use. Not sure why the compiler message is so ...
3
votes
0
answers
40
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 ...
3
votes
0
answers
47
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 ...
3
votes
0
answers
228
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 ...
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 ...
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 ...
3
votes
1
answer
440
views
Oraclize __callback function with unbounded gas usage
I am making a lottery contract and using Oraclize to select a winning number.
Here is what I have now:
The owner calls a finalize() function, which disallows new entries, and makes a call to ...
3
votes
2
answers
4k
views
Estimate Gas Cost before SendTransaction [duplicate]
How meta estimating gas cost before broadcasting.
How can I calculate gas cost for myfunc() in web3js?
function myfunc(){
require(msg.sender == owner)
...
}
await contractInstance.myfunc....
2
votes
2
answers
1k
views
How does metamask come up its suggested gas fees?
How does metamask come up its suggested gas fees? How does it come up with a certain amount?
What is it optimised for? Should you just use it or should you set your own?
2
votes
2
answers
8k
views
Why are gas fees taken for failed smart contract interactions?
When claiming an NFT (smart contract interaction), the gas fees would have been $50-$80, so I went to Advanced options in MetaMask, and turned down my willingness to pay for gas to around 25,000 units ...
2
votes
1
answer
202
views
Do all EVM chains use the same minimum transaction gas of 21000?
Do all EVM chain use 21,000 gas as a minimum transaction gas for simple ETH payments?
Optimism seems to do so. How about the other EVM chains?
2
votes
2
answers
1k
views
I set a 3 gwei for gas price. Now my transaction has been pending for 48+ hours now. But blocks aren't even full!
I tried to set a gas price of 3 gwei for interacting with a smart contract. Now the transaction is pending for 48+ hours.
If the blocks aren't full, why dont the miners pick it up?
I can bump the fee ...
2
votes
6
answers
24k
views
Gas estimation failed - remix
I am trying to figure out what is wrong with the following code as it does deploy successfully on remix.
pragma solidity ^0.5.11;
contract MyContract {
// Storage
address contractOwner;
...
2
votes
2
answers
2k
views
How to optimize the gasPrice and gas options in a contract send() function? [duplicate]
There are many questions and answers about estimating the amount of gas consumed. This question is about what to do with this estimate.
What values should we actually provide to gas and gasPrice in ...
2
votes
1
answer
958
views
Gas consumed by function invoking event?
I have a function to emit event. When I check Ganache, I find that gas used is 23078. Doesn't the event consume less gas than function with contract state change operations?
function log() {
...
2
votes
1
answer
2k
views
Estimating transfer gas for ERC20 tokens using ethers js without needing the token
I am trying to be able to accurately estimate the gas it will take to send an ERC20 token using Ethers js without first needing that token. Currently, I am able to get an estimate though it does not ...
2
votes
1
answer
59
views
Do I pay any fee to the miner if I call a non-constant function, when no state variable is changed?
Suppose I have a non-constant function which changes a state variable under some condition.
In other words, the function may sometimes change this variable and sometimes leave it as is.
Will I pay ...
2
votes
1
answer
372
views
Sending a transaction - can I assume that when the 'data' field is missing, the 'gas' field should always be 21000?
I have implemented a function for transferring ETH from my account to another account:
async function transfer(to, value) {
let options = {
from : PUBLIC_ADDRESS,
to : to,
...
2
votes
1
answer
1k
views
How can the cost of changing 2 state variables and emitting 1 event reach 50K gas units?
I have this contract:
pragma solidity ^0.4.23;
contract Test {
event Event(address indexed wallet);
mapping (address => bool) public authorizedWallets;
uint256 public ...
2
votes
1
answer
3k
views
How to properly estimate gas costs of function calls with go-ethereum and golang?
I'm attempting to build out a program in golang to model ethereum gas costs of function calls for the smart contracts I write. I've successfully been able to estimate them using ethclient.EstimateGas ...
2
votes
2
answers
4k
views
How to estimate gas for my function using web3 js only?
Hi this is my solidity function
function closeBid(string _product) public{
}
I want to estimate gas for this function so in web3 js I called this like
var gas = MyContract.closeBid()....
2
votes
2
answers
340
views
TokenTimelock gives out of gas errors when deployed within Truffle 4.0.1
I'm trying to deploy a contract using Truffle v4.0.1, within Truffle's own console but I keep getting out of gas errors.
The constructor looks like:
function MyAwesomeCrowdsale(
uint64 ...
2
votes
1
answer
429
views
Why `address.call` function "saves" unnecessary gas for after the internal execution?
I deployed a contract of a multisig wallet to ropsten and try to test its abilities:
https://ropsten.etherscan.io/address/0x8bf20c41ee6a9fd84e81d6f6df872d9628cd08b2
Things that worked fine:
Withdraw ...
2
votes
1
answer
94
views
Why don't gas calculations take into account array size anymore?
I clearly remember that a couple of months ago when I tried to push some items into a storage array each consecutive 'array-pushing-transaction' took more gas to execute. In other words, it was ...
2
votes
1
answer
32
views
What is the gas cost of this function?
I have this contract
contract Contract {
function a() external {
assembly {
return(0, 1000000)
}
}
}
I am calculating the gas cost for a call to a.
Following https:...
2
votes
1
answer
1k
views
How to get gas estimate and gas price on Polygon Mumbai Chain using web3.py?
I have deployed a contract on Goerli test net and used the following to get the estimated gas and current gas price.
contract = web3.eth.contract(address=contract_address, abi=contract_abi)
...
2
votes
2
answers
1k
views
How do node providers (e.g. Infura, Alchemy) determine gas pricing on contract writes?
When writing to a smart contract, we can specify the priority and fee per gas.
await contract.connect(owner).foo({
maxFeePerGas: "<YOUR FEE>"
maxPriorityFeePerGas: "<YOUR ...
2
votes
1
answer
8k
views
Estimate gas fees for smart contract function call with Ethers.js
Let's say you have a function in your smart contract, like:
function saveUser(address newUser) public {
// Saving user
}
How can we estimate, with Ethers.js, what the gas price will be for ...
2
votes
1
answer
400
views
About calculating gas' cost
I was reading an old post: How to get the actual Gas price?
If the gas price currently is, for instance, 14 gwei and I have a transaction cost of 80000, does it mean the price of my transaction is 14*...
2
votes
1
answer
798
views
how to use eth_estimateGas for erc20 tokens?
i wanna calculate estimate gas for BNB, PAX, LINK
i have used geth 1.8 and web3.php
my contract data that used (i found them from etherscan):
<?php
/**
* @var array
*/
public ...
2
votes
1
answer
937
views
Can miner himself add a transaction with a zero gas price?
In general it doesn't make any sense to send a transaction with zero gas price. Probably it will be pending forever. But what about miner - can he:
Send some transaction with zero gas price (so the ...
2
votes
1
answer
2k
views
How to caculate/estimate Gas Limit and Gas Price based on current state of the ether network?
Ethgasstation and similar websites estimate proper Gas Price based on current state of Ethereum network. Is there any way of using working with Geth/web3 to estimate proper Gas Price? and similar to ...
2
votes
1
answer
3k
views
Getting 'base fee exceeds gas limit' on a transaction which requires a small amount of gas
I have the following contract:
pragma solidity ^0.4.24;
contract MyContract {
address public owner;
bool public unlocked;
constructor() public {
owner = msg.sender;
...
2
votes
1
answer
76
views
How does ether transfer processed [duplicate]
I want to understand deeply how ether transfer processed and how 21000 of gas determined. Is this a simple constant fee of the transfer transaction or ether transfer transaction is the some predefined ...
2
votes
2
answers
646
views
Price of gas from https://ethgasstation.info/
The website https://ethgasstation.info/ contains a lot of information regarding the price of gas and this is confusing. My question is: what piece of information from the website should I use to ...
2
votes
1
answer
307
views
How to make this function more gas efficient?
I have this function:
function foo(uint256 _a, uint256 _b, uint256 _c) {
require(map[msg.sender].a == 1);
require(map[msg.sender].b < 1);
require(map[msg.sender].c > 1);
...
2
votes
1
answer
433
views
How do I combine integers, to save gas on transaction data and storage?
For example, I have two integers: one is uint128, another is uint64. I want to store those two integers by converting them to bytes24. And when I use them, parse the bytes24 to uint128 and uint64.
...
2
votes
1
answer
449
views
Why estimateGas return 21001 instead 21000?
For example
web3.eth.estimateGas({from: eth.coinbase, to: eth.accounts[1], amount: web3.toWei(1, "ether")})
return 21001, but not 21000, so why?
2
votes
1
answer
127
views
Is it possible to estimate used gas based on algorithm's Big O?
[Example Algorithm 1]: I have an array of structs(PaymentReceipt[] paymentReceiptList;) and imagine there are around 1000 pushed items and array's size keep increases. Each item has a time_start and ...
2
votes
1
answer
102
views
How do I figure out how much USD it will cost to deploy or execute methods on a contract?
Is there a simple tool for this or do I have to calculate it myself?
2
votes
2
answers
1k
views
How can I check how much gas I'll need to deploy a contract with eth-brownie?
I kind of accidentally deployed an ERC20 token contract on the mainnet and brownie didn't even ask me to confirm so I ended up spending $700+ worth of ETH to practice. I didn't think it would cost ...
2
votes
1
answer
176
views
How does estimation gas work when using an unpredictable condition on a loop?
I'm new to solidity but a question comes to my mind. Say I have this example dummy contract.
contract TestLoop {
uint8 public blockNumber;
uint8 public counter= 0;
event LoopCalled(...
2
votes
2
answers
2k
views
web3 estimateGas() from fallback function
When I sign and send raw transactions with web3 in javascipt , to call a method from Smart Contract, I always pass the transaction gas variable after getting it with estimateGas function, from Smart ...
2
votes
1
answer
14k
views
How to fix "gas required exceeds allowance (9998602) or always failing transaction" web3js error on mainnet?
I'm getting gas required exceeds allowance (9998602) or always failing transaction error on transaction.estimateGas() on mainnet, but it's working ok on kovan.
What is the reason of this error? Is ...
2
votes
1
answer
3k
views
Error: Returned error: The execution failed due to an exception. @ web3.eth.estimateGas
I am having problem using bignumber.js with web3:
const sender = '0xss';
const recipient = '0xxx';
const amount = 1000; // have to use Bignumber for more than 1000
const decimals = 18;
const ...