Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [gas-estimate]

The tag has no usage guidance.

0
votes
0answers
18 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
16 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 ...
3
votes
1answer
35 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
39 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
54 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
17 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
85 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
24 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
0answers
42 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
53 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
votes
0answers
51 views

How to get the estimate Gas before sending transaction?

I got "undefined",so I wanna know how to get the estimate Gas before send transaction.Thanks for helping me.
2
votes
1answer
33 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 ...
-1
votes
0answers
16 views

Using the byte code for a contract to estimate cost of deploying the contract

I'm using ethers.js in node and I have used solc to compile my contract code, so I have the byte code for the contract. From this I Think I should be able to estimate the cost in gas of deploying it ...
2
votes
1answer
22 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
46 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
72 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
15 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
176 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
54 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
21 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 ...
2
votes
1answer
40 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
22 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 ...
0
votes
2answers
183 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
66 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
21 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
241 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
124 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
31 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
133 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
208 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
452 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
76 views

Question about Gas and Gas Price

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

Why does address.transfer(amount) cost the same when sent to a new or used address?

In the Ethereum yellow-paper, it's specified that creating a new account costs 25000 gas (Appendix G, entry for Gnewaccount). We can see this if, for example, we call a function that makes a transfer:...
1
vote
1answer
49 views

Gas cost tests: Sending a transaction to a new address is more expensive?

A friend and I were thinking about transaction costs, is there any attached cost to send a transfer to a new address that has not been stored on chain before? So we started digging. First off we ...
1
vote
1answer
61 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 ...
0
votes
1answer
43 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
0answers
67 views

Remix gas estimation error

I have created a contract on remix.ethereum.org as the Rinkeby blockchain. On the Remix I have configured Remix to work with the Rinkeby through injected web3 provider. It's a simple register user: /...
1
vote
1answer
74 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 ...
0
votes
1answer
280 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
49 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 ...
0
votes
1answer
151 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
98 views

How to keep up with the gas price in a backend service

I have a small nodesjs app that is writing to a contract every now and then. It works, but i had to manually check the current gas price and deploy afterwards. What can I do to automate that? I dont ...
0
votes
0answers
85 views

Trouble estimating gas cost of function in Remix console

I'm trying to follow a tutorial for estimating the gas cost of a function. https://cristian.io/post/estimate-gas/ Thus after deploying my contract I type in this code in the Remix console to get the ...
1
vote
0answers
22 views

Gas estimation failed when trying to input a list of bytes32[5]

I am trying to create a struct as shown in the code below. The function setData is intended to create an object of the struct, take the inputs (a string and a list of type bytes32[5]) and set their ...
2
votes
2answers
563 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 ...
1
vote
2answers
277 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 ...
1
vote
2answers
1k 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" : ...
0
votes
0answers
48 views

GasPrice strategy - is automatic safe?

Is it okay to not set gasPrice in web3.eth.accounts.signTransaction or is it potentially dangerous if the automatic price is unreasonable? The Transaction is a basic ether transfer - no smart ...