Questions tagged [gas-estimate]
The gas-estimate tag has no usage guidance.
356 questions
2
votes
2
answers
177
views
Why miners do not simulate their list of transactions to detect a gas exceed and discard those Txs that exceed gas?
Base on this answer related to How Ethereum estimate the gas for running a contract?:
Which brings the second point. geth gets its estimate by simulating
the transaction itself, based on the ...
2
votes
2
answers
238
views
Contract transaction: Gas estimated doesn't fit gas used
After finding out how to estimate contract tx fees thx to How to estimate the cost to call a Smart Contract method? and Syntax for calling contract state changing methods I tried to use all that ...
2
votes
0
answers
35
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.
2
votes
0
answers
523
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, ...
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 ...
2
votes
1
answer
220
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 ...
2
votes
1
answer
794
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 ...
2
votes
0
answers
123
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 ...
2
votes
0
answers
156
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 "...
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 ...
2
votes
0
answers
268
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 ...
2
votes
1
answer
571
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 ...
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?)
...
2
votes
0
answers
313
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....
2
votes
0
answers
688
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 ...
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 ...
1
vote
1
answer
1k
views
Why ether transfer sometimes use more that 21000 gas?
I noticed that some ether transfers use more that 21000 gas. Here is an example which transferring ether from an UOA to a contract used 21033 gas:
unusual transaction
While another transfer with same ...
1
vote
1
answer
4k
views
What's the difference between "Transaction fee" and "Gas used by Txn"?
On this etherscan doc page (https://info.etherscan.com/what-is-a-transaction-hash-txhash/), it says:
Transaction Fee
The actual cost of the transaction (Gas Used by Txn multiplied by Gas Price). ...
1
vote
1
answer
13k
views
Gas Estimation Execution Reverted (ERC20: transfer amount exceeds allowance)
I want to estimate gas cost for a smart contract function. It's a kind of deposit function which takes USDT tokens from user wallet to the pool. So I should call the approve() function first to ...
1
vote
1
answer
290
views
Does a virtual function increase gas usage?
Suppose we replace every expression balances[user] with a call myBalance(user) where
mapping(address => uint256) balances;
function myBalance(address user) returns (uint256) virtual internal {
...
1
vote
1
answer
78
views
Different between gas and gasLimit keys when executing transactions
Below is the code that I'm running. When I entered "gas" and "gasLimit" as the keys, both worked. Why is that? What does "gas" represent? And what is the optimum amount of gasLimit should I use (...
1
vote
1
answer
408
views
How to calculate the costs of storing data in a contract? [duplicate]
Lets say, I want to create a smart contract that can receive a record of data per hours, e.g. hourly rates of ETH/EUR. These data would be stored in an array.
What would each transaction cost me and ...
1
vote
1
answer
354
views
Different gas cost for same operation?
I'm running a smart contract locally on TestRPC and using MetaMask to interact with it. Repeatedly calling the same function with the same parameters seems to accumulate different gas consumption (...
1
vote
1
answer
620
views
What is max amount of ETH that can be spent during a single transaction (theoretically)
I know users can set up a gas limit as not to spend too much.
I am also aware of the "gas block limit" (how much gas can be consumed in a single ETH block). However, the user can set the gas ...
1
vote
1
answer
868
views
gas usage for a large loop
How expensive are loops in solidity? (in terms of gas usage).
I need to loop through ~1000 wallet address, and send each of them some tokens.
my code:
struct User {
uint32 frozenAt ;
uint ...
1
vote
1
answer
141
views
How can I reduce the gas price for the fallback function?
Below is my fallback function for ethereum. It currently require 91000 gaslimit which is way more than 21000. Metamask always starts the transaction with 21000 gas stipend due to which transaction ...
1
vote
2
answers
2k
views
How to estimate ERC721 mint transaction?
My contract;
contract My721 is ERC721Full, ERC721Mintable, Ownable {
constructor() ERC721Full("My721", "MY721") public {}
function mintUniqueTokenTo (address _to, uint256 _tokenId, string ...
1
vote
1
answer
4k
views
Estimate Gas For Smart Contract Always Fails
I have deployed a very simple contract to the Ethereum blockchain to be able to split a payment across two different outputs.
pragma solidity ^0.5.0;
contract MoonTrade
{
function multiSendETH( ...
1
vote
1
answer
42
views
Why aren't costs "advertised" or at least knowable so funds aren't lost?
I'm admittedly new to all of this, but as I learn about the transaction model, it seems to be a confusing business model at the very least. I can understand that the price of gas fluctuates or can be ...
1
vote
1
answer
654
views
Infinite gas estimate caused by Internal function type
When I flag a simple function with the type internal, remix throws an infinite gas estimate warning. Without this type, everything is fine. Please, do you know why?
function half(uint a) {
...
1
vote
1
answer
198
views
How does actual gas unit use differ for the similar transaction?
I transferred ETH 3 times to a smart contract which needs 48734 actual gas units to execute.
It took 68932 units for 1st tx and 48734 for remaining 2. Why it took more gas for the first tx than ...
1
vote
1
answer
2k
views
How can I estimate gas on a transaction with custom data?
How can I estimate the gas I need for a string which may be quite long?
I've found an example here, but in this estimate, it doesn't include any custom data.
In my app I would like to save a string ...
1
vote
2
answers
1k
views
eth_estimateGas rpc is very slow. I'm using geth node. It worked fine a few days ago. Is network congestion the reason?
I'm using geth 1.7.2-stable. I noticed "eth_estimateGas" is very slow. It does not show the result. I confirmed that it worked a few days ago. Someone said the number of transaction is very high from ...
1
vote
1
answer
159
views
Is next formula to calculate TX cost in euros correct?
I want to create a transaction in the main-net. Each transaction modifies 4 * 32 bytes of storage. It also creates a event with 3 indexes and 150 bytes of real log.
Note: I arbitrarily take 300 Euros/...
1
vote
1
answer
24
views
Transaction within block gas limits: Will it possibly run out of gas?
Is there any risk in running a transaction that needs quite some gas, even if always within the borders of block gas limits? Let's say 20M, with block limit being 30M.
The transaction runs complex ...
1
vote
1
answer
37
views
Would always keeping a non-zero amount of every relevant ERC-20 token lower transaction costs over time?
There is a Smart Contract call called SSTORE (See ETH Yellow Paper page 27: https://ethereum.github.io/yellowpaper/paper.pdf).
It costs 20000 gas if a zero byte is set to a non-zero byte.
It costs ...
1
vote
1
answer
56
views
Payable function won't get executed (gas estimation fails)
Hey guys I am trying to create a function that would send Ether to a contract based on how many "USD" I put into an argument. But it keeps failing to estimate the gas and thus the ...
1
vote
1
answer
358
views
Incorrect Gaslimit estimation for transaction
So, I have been testing a transaction with hardhat and etherjs, that internally makes two staticcalls and a low-level call. However, by default, the transaction fails at the low-level call, as it is ...
1
vote
1
answer
568
views
estimateGas gets called too early and doesn't return correct value
I am using a alchemy node to calculate the gas limit of a smart contract once the state of the contract has changed to what I am looking for. I monitor this change by calling a read method on the ...
1
vote
1
answer
382
views
Does the EVM calculate the gas used for a transaction in real time?
Does the EVM calculate the gas used to execute a transaction on the fly as opcodes are being executed? So if there's a branch in code whose conditional is satisfied then additional gas is used to ...
1
vote
1
answer
393
views
Computing gas fees to store a plaintext blob
I'm doing some math to figure out how much it would cost to store a multiple KB text blob in a single transaction, but the number I'm getting is too low to make sense.
Let's say I want to store 20KB ...
1
vote
1
answer
2k
views
How to estimate gas without balance?
So, I'm making a private network and deploying some contracts. The contract has a payable method which means I have to put value when calling the method. I want to get the estimated cost to call the ...
1
vote
1
answer
4k
views
Default gas limit set by web3 is unreasonably high?
I am trying to learn and understand solidity/defi by creating some copies of current popular protocols; I've created a small copy of the Curve Dai strategy from harvest finance, but I'm getting really ...
1
vote
3
answers
863
views
Solidity 0.6.1 Receive Fallback Forwarder reverts due to insufficient gas
I am playing around with Solidity 0.6.1 and trying to build a simple funds forwarder. So ETH is sent to the contract and it sends the funds to another address.
I deployed it to Ropsten. But every ...
1
vote
1
answer
56
views
Explanation for small variation in gasUsed while recursively deploying same contract
https://github.com/christianlundkvist/simple-multisig/blob/master/contracts/SimpleMultiSig.sol
I'm deploying the above contract recursively and I find that the gasUsed varies by specifically 12 gas. ...
1
vote
1
answer
67
views
Block Gas Limit Doubt
Suppose i have a loop.
Here user is a struct of which player is an address.
address[] memory addrs = new address[](n);
for(uint i=0;i<n;i++){
addrs[i] = user.player;
}
return addrs;
This is a ...
1
vote
1
answer
695
views
ERC721 - How is gas worked out with TokenID?
ERC721 - I have minted a tokenid (tokenid=444) and my account owns it. When I try and transfer it, I get this message stating the gas cost is the normally calculated one and the total cost has the ...
1
vote
1
answer
365
views
What should be optimal gas limit and gas price for 80 addresses airdrop?
This is my airdrop function:
mapping (address => bool) public airdrops;
function airdropTokens(address[] _recipient, uint256[] _tokens) public onlyOwner{
uint airdropped;
for(uint256 i = 0; i< ...
1
vote
2
answers
1k
views
Measuring the efficiency/performance of a smart contract presented as an algorithm
I am trying to theoretically analyze the expected performance of a smart contract presented in the form of an algorithm which consists of multiple functions.
What is the best way to measure the ...
1
vote
1
answer
2k
views
"Gas estimation failed" on Ropsten using MetaMask!
I'm testing a smart contract using Remix, MetaMask, Ropsten.
Yesterday I developed my contract on Ropsten network and everything goes in the right way.
Today I was developing the SAME contract code, ...