Questions tagged [gas-estimate]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
28 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
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, ...
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
40 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-...
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 (...
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
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
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....
0
votes
1answer
422 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 { ...
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
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 ...
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
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", ...
1
vote
2answers
217 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
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 ...
4
votes
2answers
299 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(...
1
vote
0answers
90 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
367 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 ...
0
votes
1answer
954 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> ...
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 "...
4
votes
0answers
151 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 ...
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
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 ...
2
votes
1answer
81 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, ...
4
votes
2answers
250 views

Do intermediate memory variables cost gas?

Example without an intermediate variable: uint startTime = 9; uint allowedTime = 7; require(now > startTime + allowedTime); Example with an intermediate variable: uint startTime = 9; uint ...
2
votes
1answer
20 views

Gas used for the same deterministic operation is different

standard ICO function which exchanges Ether to ERC20 token balance. Call 1, used 49431: https://ropsten.etherscan.io/tx/0x6671c8fd39d195b09868d914d80f0e884e42259c7346b69afb483f2e18fae263 Call 2, ...
7
votes
3answers
223 views

Composition Over Inheritance - Gas Efficiency

In OOP languages, composition over inheritance is a well-known best practice. Solidity is an OOP language too but there is also the gas efficiency issue. Question is, in Solidity, how do composition ...
0
votes
1answer
67 views

Smart contract's function work on testnet but don't work on private network

I have been created a smart contract (ERC20 implantation). The contract run great om testrpc, ropsten and rinkeby but i want to use it in a private network. When the contract deployed in the private ...
1
vote
0answers
37 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 ...
1
vote
1answer
26 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 ...
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 ...
1
vote
0answers
30 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 ...
1
vote
2answers
438 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 ...
1
vote
1answer
203 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
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
490 views

How to estimate gas cost for contract method using geth

I want to estimate a contract method gas cost using geth. I understand there is no direct way using geth as in the web3 libs. But I don't understand what is the second argument needed and how I can ...
1
vote
1answer
404 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; ...
1
vote
0answers
41 views

What's the point in the 'gas' parameter passed to function 'signTransaction'? [duplicate]

I am using web3.js v1 in order to sign and send transactions: async function signAndSend(transaction) { let options = { to : transaction._parent._address, data: transaction....
1
vote
2answers
307 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
1answer
306 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, ...
0
votes
1answer
549 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, ...
0
votes
1answer
112 views

Question about Gas and Gas Price

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