Questions tagged [gas-estimate]

The tag has no usage guidance.

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

Infinte Gas Estimation by Remix

New to Solidity here but heres my issue. Here are the mappings I'm calling: mapping1 (address => uint32[7]) mapping1; mapping1 (address => uint32[7]) mapping2; function myFunction() external ...
0
votes
2answers
101 views

Gas estimation failed:“transfer amount exceeds spender allowance”

I want to execute function Tip and transfer IERC20 Token. However, this message is shown. Uni::transferFrom: transfer amount exceeds spender allowance { "originalError": { "code": ...
0
votes
1answer
233 views

Gas estimation errored with the following message (see below). i am trying to deploy in bsc testnet

i am trying to deploying a contract to bsc testnet but it getting this error : Gas estimation errored with the following message. The transaction execution will likely fail. Do you want to force ...
0
votes
1answer
79 views

Estimating transfer gas for ERC20 tokens using ethers js without needing the token

I am trying to be able to accurately estimate the gas it will take to send an ERC20 token using Ethers js without first needing that token. Currently, I am able to get an estimate though it does not ...
2
votes
0answers
34 views

how to estimate the gas cost of a contract function that will fail

I am trying to estimate the gas cost of a contract function that will fail. when i do that using standard web3.py's contract.function(args).estimateGas(txArgs) it ends up failing and raising an ...
0
votes
0answers
36 views

“Gas estimation failed” error when sending eth to Chainlink VRF function?

I have a simple request and fulfill randomness using chainlink VRF, and it works fine when calling with 0 ether, but if I send a non-zero amount I get a 'gas estimation failed' error. To be clear, I ...
0
votes
0answers
12 views

What is the gas cost when manipulating on-chain variable multiple times within one transaction?

Changing variables that are stored on the blockchain is expensive. How are gas costs calculated if I change one variable multiple times within the same transaction? For the sake of having a simple ...
0
votes
0answers
14 views

Gas estimation fail only when sending eth to contract?

I have a payable function that works fine when calling without any eth, but if I try to call it with eth it gives me a gas estimation fail. I have another function that is payable and works fine when ...
0
votes
0answers
23 views

Get accurate gas fees with Remix IDE on testnet?

How can I get accurate gas fees when testing with the Rinkeby testnet? When I test, the default gas is 1 gwei which always works, which obviously isn't accurate.
0
votes
0answers
22 views

Difference in Gascost between buying on Uniswap through UI and interacting with Uniswap Router contract on Etherscan

Why is the gas cost of going to uniswap.exchange and making a trade (significantly!) lower than the gas cost of going to https://etherscan.io/address/0x7a250d5630b4cf539739df2c5dacb4c659f2488d#...
1
vote
1answer
165 views

Ethers js estimateGas() without needing ETH in account

I am trying to estimate the gas used for a uniswap transaction. I am able to perform this on the Kovan testnet however when I try and run the same script on the mainnet it raises an error, "Error:...
0
votes
0answers
54 views

Calculating Gas of A Uniswap Exchange With Web3js

I am trying to calculate the gas that a contract will use prior to executing it. I realize that it is not possible to get a 100% exact value but I would still like to calculate an estimate. I am new ...
0
votes
0answers
89 views

Gas estimation failed — flashloans — solidity

I am able to deploy a smart contract, and even fund it with WETH from my metamask wallet without any gas estimation failures. When I try to execute my flashloan on this smart contract, however, I get ...
2
votes
2answers
1k views

Estimate gas price with ethers.js

I'm looking to estimate transaction fees in an application. In order to do so I need to estimate the current gas price before I execute the transaction. I see web3.js has a getGasPrice method: https://...
2
votes
1answer
72 views

web3 estimateGas() from fallback function

When I sign and send raw transactions with web3 in javascipt , to call a method from Smart Contract, I always pass the transaction gas variable after getting it with estimateGas function, from Smart ...
0
votes
0answers
19 views

Traded like 12$ of ethereum for husky at like 6 GWEI how long do those trades usually take?

I tried using "UniSwap" but 40$ prices for a 12$ trade seemed ridiculously high so I just went on a random site which allowed me to change "gwei" and I put it to 6 I think, I also ...
0
votes
0answers
29 views

Web3.eth.getGasPrice() returns incorrect result

Web3.eth.getGasPrice() returns incorrect result (just two results 6 gwei and 10 gwei) at which time gasTracker showed about 58 gwei. I am confused why just two fixed value (6 and 10) when this happens ...
2
votes
0answers
220 views

Ethers and Web3-React: Cannot estimate gas when trying to connect with contracts deployed on testnet and using Alchemy as node provider

I'm trying to connect with contracts deployed on the Rinkeby testnet using a node provider. When I was testing using hardhat as a local node, the contracts are called with no problem, but when I ...
0
votes
0answers
21 views

How to shorten IF statement with require() inside?

I'm trying to make the if statement shorter, to require a less gas it the case of emergency, here how it looks like: if (input == token0) { require(amount0Out > amount, "1"); } else ...
0
votes
1answer
15 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
209 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
54 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
71 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
2k 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
30 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
53 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
7k 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
293 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
82 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
29 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
25 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
36 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!
3
votes
1answer
5k 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
36 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
32 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
140 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
112 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*...
1
vote
1answer
921 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
54 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
10 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
123 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
412 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
289 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
65 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
43 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
169 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
576 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
1k 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 ...

1
2 3 4 5