Questions tagged [gas-estimate]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
4
votes
1answer
152 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 ...
3
votes
2answers
72 views

Is there a Gas Cost profiler

I am trying to figure out what part of a complicated smart contract transaction is responsible for the cost. I was wondering if there is already a tool for that. Ideally it would spit out you are ...
0
votes
1answer
29 views

Does using a very high gas limit somehow get your transactions executed slower?

I'm executing transactions on mainnet with a NodeJS script: async function send(web3, transaction, destAddr, gasPrice, privateKey) { const options = { data : transaction.encodeABI(), ...
1
vote
1answer
222 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 ...
0
votes
1answer
149 views

Infinite gas estimate for almost all the functions. Is it normal?

When I deploy contract test net, it shows an error that gas limit exceeds: 3000000 What's the solution? Github Link to the smart contract. And is it normal to have the infinite gas estimate of ...
0
votes
1answer
435 views

Gas estimation failed: gas required exceeds allowance or always failing transaction

I have two contracts one for defining token and other for crowdsale. I am using remix ide. pragma solidity >=0.4.22 <0.6.0; contract owned { address public owner; constructor () public { ...
4
votes
1answer
170 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 ...
4
votes
2answers
303 views

web3.eth.getGasPrice() always return 1GWei

For estimate transaction cost, I use web3.eth.getGasPrice() function. The return callback value always 1Gwei(1,000,000,000) in ROPSTEN. web3.eth.getGasPrice(function(error, result){ console.log(...
2
votes
1answer
323 views

Contract is sent and gets an address, but eth.getCode returns 0x

I'm trying to deploy a contract on a private blockchain network. My solidity code has a lot of variables used in it. The deployment does give me a contract address, however, when trying to retrieve ...
0
votes
1answer
374 views

Error: `Invalid JSON RPC response` when running estimateGas on Infura

Why am I getting an error when doing a gas estimation on infura. I am using web3 v1.0 and here is my code: let Web3 = require('web3'); var web3 = new Web3(new Web3.providers.HttpProvider('http://...
2
votes
1answer
31 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 ...
0
votes
1answer
550 views

Error in Ethereum Wallet:“Couldn't estimate gas, resorting to default parameters. Transaction is likely cheaper than the estimate”

I am using ethereum wallet for deploying contracts in my private blockchain. But whenever I try to send a transaction in my ethereum wallet it shows an error that says, "Couldn't estimate gas, ...
1
vote
1answer
35 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 ...
0
votes
1answer
14 views

Get gas limit beforehand with Web3

I know that web3 exposes a function to estimate gas limit, but is it accurate when sending to a contract? AFAIK the amount of gas I'm gonna need if sending to a contract depends on the contract code, ...
2
votes
2answers
700 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 ...
0
votes
1answer
38 views

Calling a function to zero out struct data in a mapping costing more gas than other calls, causing out of gas error

I am working with the following function and state vars: struct TimeRestriction { uint256 fromTime; uint256 toTime; } mapping (address => TimeRestriction) public whitelist; function ...
0
votes
0answers
11 views

Can web3js accurately estimate a transaction that includes an external call?

Can web3js accurately estimate a transaction that includes an external call? For example, will it be accurate in estimating: (bool _success, bytes memory _response) = _to.call.value(_value)(_data); ...
3
votes
0answers
41 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-...
1
vote
1answer
25 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/...
0
votes
1answer
69 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 ...
0
votes
1answer
23 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 (...
2
votes
1answer
783 views

Remix error “gas required exceeds allowance or always failing transaction” on private blockchain

I'm trying to test contract interaction using Remix with two basic contract: contract Callee contract Caller Callee function/variable: uint[] public values; function storeValue(uint value) { ...
0
votes
1answer
74 views

estimateGas doesnt match with actual one

I have deployed erc20 contact in Robsten network : https://ropsten.etherscan.io/token/0xa93d83709a1b35f67b30e7400b200690aa51859a?a=0x2c5253b9055cfd3ac7a2d352934fb5c45f667367 Code can be found here (...
0
votes
1answer
112 views

Question about Gas and Gas Price

In my transaction: gasPrice: 210000 blockHash: "0x69bd71736f2a5d2c83919a0de81a7de0b6b690bb6bdda3acff254d5c68f634bc", blockNumber: 3178, from: "0xc8caa71c16299b40b8579742a27ee53162886040", gas: ...
1
vote
1answer
22 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 ...
0
votes
1answer
23 views

How expensive is it to manipulate the gas price?

Imagine that an evil billionaire decided to make Ethereum hard to use by making the gas very high. I'm wondering how expensive this would be to do for various timescales. For example, manipulating ...
0
votes
1answer
37 views

Calculated Gas Costs of Contract execution

I have a smart contract that maps a string to a string value and stores it on the Blockchain. I want to analyse the Gas Used by Transaction. One time the execution consumes 92,843 Gas (https://rinkeby....
1
vote
1answer
210 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 ...
0
votes
0answers
31 views

How to handle estimate gas cost error?

I am programming a button for a transaction which shall only appear if the transaction is possible. Therefore, I am using the following code contract.methods.function(parameters) .estimateGas({...},...
5
votes
1answer
100 views

Why does gas cost explode with more than 7 variables in a struct

I'm assuming this has to do with Ethereum's 7 variable stack limit but in the following code test struct TestStruct5 { uint8 m_nOther1; uint8 m_nOther2; uint8 m_nOther3; uint8 ...
1
vote
1answer
21 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, ...
0
votes
0answers
32 views

Find exact gas limit requirements for executing fallback function logic

I have a certain function logic coded for fallback function. This logic also contains some delete operations of storage variables (delete storeVarX;) due to which there might be some gas being ...
0
votes
0answers
32 views

Why does my private network transaction use a different amount of gas than my mainnet transaction performed immediately after?

I am forking the mainnet from my own geth node with ganache-cli --fork option. Immediately after the fork, I simulate a transaction to a contract on the forked, private network. I then immediately ...
0
votes
1answer
315 views

JSON-RPC estimate gas error

I am calling method with params: { "jsonrpc":"2.0", "method":"eth_estimateGas", "params": [ { "to": "0x8f0921f30555624143d427b340b1156914882c10", "data":"...
0
votes
0answers
36 views

JSON RPC get this error “Request have return error: gas required exceeds allowance or always failing transaction”

i'm trying to do a simple transaction for a token but i keep getting following error for estimate gas limit : "Request have return error: gas required exceeds allowance or always failing transaction" ...
0
votes
1answer
71 views

Multi token transfer issue [closed]

In exchange contract,With multi token when I call approve function from exchange contract, nor my address and spender get approved. Instead only the exchange address and spender gets approved. Its ...
0
votes
1answer
38 views

Gas Estimation questions

I am little confuse in the concept of Gas Estimation and price. When i add new user i get popup through metamask for the transaction amount and gas used which is totally fine. I checked my code in ...
1
vote
1answer
92 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 ...
0
votes
1answer
961 views

Error: gas required exceeds allowance or always failing transaction when trying to estimate gas

I am trying to run estimateGas function on mainnet like the following to send erc721 cryptokitties from one account to another: data.from = <my address> data.to = <destination address> ...
1
vote
2answers
220 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 ...
0
votes
0answers
112 views

Transactions always fails on POA sokol testnet blockchain

POA Sokol is a ethereum like testnet blockchain. I am using ether.js to make a contract call . The eth_estimateGas method in testnet gives this response but works in mainet: { "jsonrpc": "2.0", ...
0
votes
1answer
287 views

Simple function triggering infinite gas warning?

When I compile this in Remix (0.4.21+commit.dfe3193c.Emscripten.clang): uint256 public rewardAmount = 40; function adjustReward (uint256 reward) onlyOwner public { rewardAmount = reward; }...
1
vote
0answers
91 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 ...
1
vote
1answer
369 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
0answers
24 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 ...
9
votes
1answer
535 views

In web3.js, how do I accurately find total gas cost to deploy a new contract (including constructor)?

I am using a public node as my web3 privider, so I must sign all transactions manually. This includes transactions that create contracts. Currently, I use the following method to deploy contracts. ...
2
votes
0answers
27 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 "...
1
vote
1answer
84 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< ...
2
votes
1answer
36 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
0answers
172 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?) ...