Questions tagged [gas-estimate]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
26
votes
3answers
12k views

What are the limitations to estimateGas and when would its estimate be considerably wrong?

web3.eth.estimateGas and JSON-RPC estimateGas can be used to see how much gas should be specified for a transaction, before crafting the transaction. Since it is an estimate, are there any ...
18
votes
2answers
15k views

How to estimate gas at contract creation/deployment to private ethereum blockchain

What I have done a) When I use web3.eth.estimateGas to estimate the cost of a contract creation constructor with no parameters, the estimate is correct. b) If the contract is already deployed then ...
9
votes
2answers
12k views

how to estimate gas cost?

I have a function that iterate through an array, which could cost a lot of gas. But I still want to test out the estimate gas cost, then decide if I should maintain the design or not. function ...
13
votes
1answer
3k views

What happens if transaction runs out of gas before transaction completes?

As gas cost can only be estimated until the transaction is executed against the actual contract state at the time of execution on the blockchain, what happens if transaction runs out of gas before the ...
1
vote
2answers
813 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; ...
4
votes
2answers
3k views

How can I estimate price of data storage? [duplicate]

I'd like to make estimations of the cost of an application, and one of the things I need is the price to store n kB of data on a contract. In ether and in USD. Where could I find rates or prices of ...
7
votes
2answers
1k views

Infinite gas estimation from solc for simple function

Here is a simple Solidity contract: pragma solidity ^0.4.16; contract Test { uint[] array; function testGasEstimation() public { array.length = 1; } } Here is the output of ...
0
votes
2answers
132 views

Will same contract consume different gas in different network?

I have a contract deployed both in test and main network and if i execute same method with same parameters, will gas used differ?
2
votes
1answer
78 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, ...
9
votes
1answer
3k views

How to whitelist up to 50k addresses in a single contract?

What is the best practice in whitelisting a large amount of addresses in a contract. For example, if I wanted to include 50k addresses into a mapping that will reflect true for only the 50k addresses, ...
8
votes
2answers
3k views

How to estimate the cost to call a Smart Contract method?

After succesfully deployed this Smart Contract on Ethereum testnet https://testnet.etherscan.io/address/0x27c042342C9ba937214117e11A4970A6145034cB is it possible to calculate how much gas is going ...
7
votes
2answers
3k views

Mist Testnet error “it seems this transaction will fail”

I am very new to Ethereum, and just working through some early tutorials using the testnet. My version is up to date; the blockchain is also up to date; and I have only one account in the keystore, ...
5
votes
1answer
1k views

Is it possible to calculate the gas costs of a transaction exactly upfront?

In the Ethereum wallet there are the estimated gas costs. Why is it only an estimate? Is is possible to calculate the gas costs precisely upfront?
6
votes
1answer
524 views

Gas estimation for mapping updating with web3js

The gas estimation for contract deploying with web3js will look like: var res = web3.eth.estimateGas({ from: web3.eth.defaultAccount, data: contractByteCode }); For example, I have the ...
5
votes
2answers
3k views

Getting infinite gas estimates for simple functions

I am testing out solidity in remix ide using simple contracts. This is the contract that I wrote: contract mortal { address owner; function mortal() { owner = msg.sender; } function kill(){ ...
4
votes
1answer
1k views

How to minimize gas consumption during contract creation

I have trouble deploying a contract to the main network and I believe this is due to high gas consumption. An earlier version of the contract worked on the main network. The current version works in ...
3
votes
2answers
3k views

Correct syntax for estimating gas cost of a function in Web3?

Suppose I have the following function: function SetMessage (bytes32 _message) returns (bool success) { message = _message; return true; } Which might be called in Web3 as follows, for ...
2
votes
2answers
203 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, ...
1
vote
2answers
2k views

how to estimate gas limit when using web3.eth.sendSignedTransaction

I am using web3 to transfer tokens by using web3.eth.sendSignedTransaction. When I am setting the parameter rawTx like var rawTx = { "from" : walletbase, "nonce" : ...
1
vote
1answer
173 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 ...
1
vote
1answer
369 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; ...
0
votes
1answer
418 views

How do you estimate the gas cost of any arbitrary function in Remix IDE?

I've found plenty of information on how to do this using Truffle and Web3, but nothing regarding how to achieve this in the Remix IDE. Examples would be very much appreciated.
0
votes
1answer
105 views

Question about Gas and Gas Price

In my transaction: gasPrice: 210000 blockHash: "0x69bd71736f2a5d2c83919a0de81a7de0b6b690bb6bdda3acff254d5c68f634bc", blockNumber: 3178, from: "0xc8caa71c16299b40b8579742a27ee53162886040", gas: ...