Questions tagged [gas-estimate]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
0answers
17 views

Can not swap SHIB to ETH . Gas price shown two times

When trying to for example swap SHIB --> ETH the confirmation screen in Metamask shows the same amount at GAS fee as well at the GAS FEE + Amount field. So only the GAS fee amount is calculated and ...
0
votes
1answer
8 views

Storing constants in Storage vs Creating a view function? (Solidity 0.5.17)

So, which would be gas efficient? Reading a storage variable in a state-changing function? OR Reading from a pure function in a state-changing function? Example: contract Test { uint256 public a = ...
2
votes
1answer
26 views

Understanding Gas Fees for NFTs

I am going to mint a collection of 10,000 NFTs. However, I've become very concerned over the gas costs associated with such an endeavor. I was wondering if someone could help me understand the ...
0
votes
0answers
20 views

calculate gas cost for transaction

this is the method that I call: function depositAll() public { address(0xf5eA38B6b9644224dA1aECbC1219e8543c0689b2).call(abi.encodeWithSignature("depositAll()")); } and this is ...
0
votes
0answers
41 views

Gas estimation failed AmazinBEP20 contract

Im trying to deploy the contract AmazingBEP20, i use: http://remix.ethereum.org/#optimize=true&runs=200&evmVersion=null&version=soljson-v0.8.3+commit.8d00100c.js Contract i want to deploy ...
1
vote
2answers
899 views

Why are gas fees taken for failed smart contract interactions?

When claiming an NFT (smart contract interaction), the gas fees would have been $50-$80, so I went to Advanced options in MetaMask, and turned down my willingness to pay for gas to around 25,000 units ...
0
votes
0answers
27 views

How to optimally use map of maps in solidity?

I have the code: struct A { mapping(uint256 => uint256) b; } mapping(uint256 => A) public a; and I want to have the following code as gas efficient as possible: a[key_a].b[key_b] = a[...
0
votes
1answer
32 views

Tx stuck even after using gasestimation for gas limit

I am trying to sign a manual transaction using ethereumjs-tx to interact with a smart contract. This is how I am getting my gaslimit, nounce and data for the params var GAS = await cont.methods....
2
votes
1answer
6k views

How can I calculate the gas fee of a swap on Uniswap?

According to gas tracker on Etherscan the average gas price is 212 gwei and the average Uniswap swap estimate is $70.26 which implies that the gas fee is around 201101. To my knowledge swap gas fee is ...
0
votes
0answers
109 views

EstimateGas reverts, actual transaction works

On Rinkeby I'm trying to estimate gas and send ERC-20 Weenus tokens. If I shove the necessary data into an estimateGas call to Infura Rinkeby it returns with an error of execution reverted. { &...
0
votes
0answers
41 views

Truffle test doesn't recognize estimateGas function

I'm trying to test my contracts using Truffle and Ganache, but I'm facing some problems with some functions. When I call a non view function, I'm getting the error "out of gas". Moreover, if ...
0
votes
1answer
27 views

Deciding Gas Pricing

Anyone know how curve fi and metamask fetch the average gas price for the transaction and how they provide the slow and fast option? I just want to know which third party they use to get these info.
1
vote
1answer
21 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 { ...
0
votes
1answer
27 views

Can gasLimit be infinite?

Assuming I have enough Ether, can smart contracts be executed no matter how complex they are as long as I specify a large enough gasLimit? Hope you can give me some hope, thanks!
2
votes
1answer
3k views

I'm getting “invalid opcode: opcode 0xfe not defined”, when trying to estimate the gas fees

I'm trying to estimate gas fees of a contract that I'm about to execute. My code is as follows. import Web3 from "web3"; const web3 = new Web3(); const estimateGasLimit = async ( ...
5
votes
0answers
33 views

Deploy gas issue for require reason string

I found a strange case and didn't find out why. ... modifier onlyMaster() { require(msg.sender == master || msg.sender == developer, "caller is not the master"); _; } ... ...
0
votes
0answers
28 views

amount of gas used in receive and fallback functions in truffle tests

I have a contract that is written in solidity ^0.6.4 and has a simple implementation of reverting funds when someone directly transfers some eth or calls an unhandled function. Now it appears to be ...
1
vote
0answers
98 views

Understanding eth_estimateGas with regards to gas price, and current mempool

Does anyone have a detailed understanding of how eth_estimateGas works with regards to gasPrice and the current mempool state? I have historically seen some really odd behavior when using ...
0
votes
1answer
55 views

About calculating gas' cost

I was reading an old post: How to get the actual Gas price? If the gas price currently is, for instance, 14 gwei and I have a transaction cost of 80000, does it mean the price of my transaction is 14*...
0
votes
1answer
519 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 ...
0
votes
1answer
45 views

Is it possible to get the gas fee before sending an ETH?

Is there a way or api endpoint to calculate the gas fee before sending the ETH? My client requirements is to calculate the gas fee before sending an ETH to other user. I can only get the gas price ...
0
votes
0answers
15 views

What determines how much gas is required when transferring an ECR-721 non-fungible token? [duplicate]

When transferring an ECR-721 token, what determines how much gas is required? Is it written into the contract of the ECR-721 token? Does it depend upon how it was transferred (e.g. cryptokitties.com ...
1
vote
0answers
20 views

I don't know why my contract have a problem. Gas estimation and Gas exceeds Problem [closed]

pragma solidity >=0.4.24 <=0.5.6; contract Indian { mapping (address => uint16) myGame; address public owner; constructor() public { owner = msg.sender; } ...
0
votes
0answers
9 views

For Ganache and BuidlerEVM I have different estimated gas

For Ganache and BuidlerEVM I have different (several times) estimated (by Ethers.js) gas for the same computation. Is it a bug? Isn't the Ethereum standard specifying particular gas amount for every ...
1
vote
1answer
93 views

how to use eth_estimateGas for erc20 tokens?

i wanna calculate estimate gas for BNB, PAX, LINK i have used geth 1.8 and web3.php my contract data that used (i found them from etherscan): <?php /** * @var array */ public ...
1
vote
2answers
271 views

Can miner himself add a transaction with a zero gas price?

In general it doesn't make any sense to send a transaction with zero gas price. Probably it will be pending forever. But what about miner - can he: Send some transaction with zero gas price (so the ...
0
votes
1answer
208 views

How to refund gas to the smart contract caller? (What is the number?)

I have this function: function setAccount(BaseUBI _ubi, address _user, uint256 _startTime, uint _esiaID, bool _setToZero) external { uint256 _refund = (gasleft() + 0/*FIXME*/) * tx....
1
vote
0answers
58 views

Execution erorr: Invalid opcode on estimateGas | Possible unhandled promise rejection

pragma solidity ^0.5.0; I get invalid opcode error when trying to estimate gas needed for my transaction from react-native using the following line of code: const gasAmount = await contract.methods ...
0
votes
1answer
38 views

mining transaction in private blockchain

I am new to the blockchain issue, and I have read about it, but I had these questions. When I actually implement a private Blockchain on every transaction it costs a certain gas. Who pays for this ...
0
votes
0answers
122 views

Insufficient funds for gas * price + value in Ropsten

I write API for smart contract but its shown error "Insufficient funds for gas * price + value"? My try I have increased my address balance but it's showing the same error. I have changed my ...
0
votes
1answer
427 views

How to estimate gasLimit of ERC20 contracts in web3.php project?

I am using web3.php project in my Ethereum based project. A part of this project is sending ERC20 tokens, and in this regard, I need to estimate gas limit of transaction. For this purpose, I found the ...
0
votes
1answer
935 views

How to fix “gas required exceeds allowance (9998602) or always failing transaction” web3js error on mainnet?

I'm getting gas required exceeds allowance (9998602) or always failing transaction error on transaction.estimateGas() on mainnet, but it's working ok on kovan. What is the reason of this error? Is ...
0
votes
0answers
166 views

How to correctly account for transaction costs when swapping from one ERC-20 token to another using for example the Kyber network?

If I for example have 5 KNC (an ERC-20 token) and would like to swap them for x amount of DAI (another ERC-20), this would on the Kyber network, as far as I understand, be achieved via two conversions:...
0
votes
0answers
223 views

intrinsic gas too low in Ropsten

I am trying the sendSignedTransaction in Ropsten and I assigned the value of gas limit and gas price: gasLimit: web3.utils.toHex(21000), gasPrice: web3.utils.toHex(web3.utils.toWei('10', 'gwei')) ...
1
vote
1answer
65 views

gas estimate in loop

I have two contract. I call function placeBid in other contract and i have warning gas estimation. help me. thanks. Can i call function which use gas in loop through other contract? How i can get ...
0
votes
1answer
66 views

Smart contract transaction takes different amounts of gas on different platforms

I have an ERC-20 token contract on which I want to perform some testing on a local chain. I got my chain setup, contract deployment and testing scripts ready on my Windows machine. However, since I ...
0
votes
1answer
349 views

How to estimate gas in an address with no ETH at all

Say I have received an ERC20 token in my address. Such address has no ETH and no other tokens except the one I just received. If I try to estimate the gas cost of sending the token from that address, ...
1
vote
3answers
339 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 ...
0
votes
0answers
52 views

gas estimation fails when trying to run a recursive function? Is there an alternative?

I have been trying to traverse a graph kind of data structure and the only way to do this is by using a recursive function is what I feel. So, now when I try to execute my contract code in remix it ...
1
vote
1answer
902 views

Error: Returned error: The execution failed due to an exception. @ web3.eth.estimateGas

I am having problem using bignumber.js with web3: const sender = '0xss'; const recipient = '0xxx'; const amount = 1000; // have to use Bignumber for more than 1000 const decimals = 18; const ...
1
vote
0answers
258 views

Gas estimation errored with the following message (see below). The transaction execution will likely fail

When I try to excute the deposit function it shows Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution ...
4
votes
1answer
66 views

Can I estimate the total gas limit of several dependent transactions?

Assume two dependent transactions A and B. Transaction B depends on transaction A and will fail if transaction A has failed. I would like to estimate the gas limit required for the success of both ...
1
vote
1answer
25 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
1answer
3k views

ethers.js - estimating gas limit

Using the ethers.js library, how can I determine the gas limit when sending a transaction to a contract or deploying a new contract?
0
votes
4answers
4k views

Gas estimation failed - remix

I am trying to figure out what is wrong with the following code as it does deploy successfully on remix. pragma solidity ^0.5.11; contract MyContract { // Storage address contractOwner; ...
0
votes
1answer
51 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 ...
0
votes
1answer
56 views

Why are all “safe low” transactions mined eventually?

On the website ethgasstation.info you see the current fees for fast, standard and safe low transactions, assuming that there are always more safe low transactions waiting to be mined than standard or ...
2
votes
1answer
329 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
73 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
104 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, ...