Questions tagged [gas-estimate]
The gas-estimate tag has no usage guidance.
341
questions
0
votes
1
answer
18
views
gas estimation error because of reverted
here is a situation I have: a user came to my platform to buy mytoken and he paid 44 matic for it and 266,087 | 263,663 (99.09%) which reverted because of the gas out. is there any solution to add gas ...
0
votes
1
answer
31
views
ELI5: Converting an arbitrary gas cost in Remix IDE to USD
Let's say the gas (transaction) cost of a function in Remix is 139508. How would I easily convert this to USD?
I know this is a totally noob question and I know better, but I can't for the life of me ...
0
votes
1
answer
24
views
Solidity variable for contract scope (not state variables)?
I use state variables for the interaction of calls (fallback) between contracts. But copying and clearing state variables uses a lot of gas.
Perhaps there is a better practice, how to have temporary ...
0
votes
0
answers
32
views
Can eth_estimateGas estimate gas for past blocks?
In my understanding, the eth_estimateGas json rpc method can currently only be used to estimate how much gas would be needed for a transaction based on the current/latest state of the blockchain.
...
0
votes
1
answer
14
views
How to Determine the Optimal Gas Limit for Maximum Gas Refund without Excess?
I'm optimizing the gasLimit for transactions to ensure the maximum possible gas refund without leaving any unused gas. Given most web3 network's have a maximum gas refund policy where a portion of the ...
0
votes
1
answer
27
views
How to change the gas price and gas limit in private blockchain
I wan to change the gas price and gas limit in the private blockchain as you know the currrent contract limit is 21000 so I want to change the default and also the gas limit I wan to cut more than 1 ...
0
votes
0
answers
12
views
Why or where should one use Twos Compliment in Solidity?
I was reading through Solidity Docs and came across Bit Operations section
https://docs.soliditylang.org/en/v0.8.21/types.html#bit-operations
Couldn't figure out why one would use this.
However, I do ...
0
votes
0
answers
20
views
Calculating gas a payable function call of smart contract in ethersjs
I am doing something with this logic. But how do I calculate how this will cover different gas amount on different EVM chains
let gasLimit = 210000;
const { gasPrice } = await provider.getFeeData();
...
1
vote
2
answers
105
views
Transaction fails due to: Insufficient funds for gas * price + value
I am trying to make transactions on Polygon Mainnet, but unfortunately when I automatically try to calculate the transaction fees, the transaction gets reverted because I assume that the fees are to ...
2
votes
0
answers
30
views
Understanding the Inner Workings of eth_estimateGas in Smart Contracts
I'm seeking clarification on how the eth_estimateGas function operates under the hood. Does it run the smart contract in a manner similar to a dry run?
When I make a call to eth_estimateGas, and I've ...
1
vote
1
answer
30
views
Simple operation causes Remix gas estimate to become infinite [duplicate]
Completely new to using Remix (first few hours of using it) but confused by this behaviour. In the simple code example below using Remix, why does an operation as simple as incrementing a uint256 (...
0
votes
0
answers
67
views
How to catch the {'code': -32000, 'message': 'gas required exceeds allowance (0)'} exception in we3.py?
I'm using the estimate_gas method to get the gas estimate for the tx that I'm sending and in case balance < gas estimate I wanna trow an exception.
try:
gas_estimate = self.w3.eth.e(...
3
votes
3
answers
197
views
MetaMask incorrectly estimates 100,000 gas for ERC20 transfer. Why?
MetaMask is incorrectly limiting the gas limit estimate to 100,000. This is actually a rather complex "transfer" that will need about 145,000.
Why does MetaMask limit ERC20 .transfer() to ...
0
votes
0
answers
137
views
ProviderError: transaction would cause overdraft when using Uniswap V3 router on Goerli testnet
I tried to call a smart contract (UniswapV3Swap.sol) from another smart contract (UniswapV3Connector.sol). I want to call the swapExactInputSingleHop from UniswapV3Connector.sol, however, the ...
0
votes
0
answers
147
views
Execution Error - ERC20: Transfer Amount Exceeds Balance in Ethereum Smart Contract
I'm encountering a perplexing issue while working on an Ethereum smart contract. It seems to be a parameter related error, but I haven't been able to rectify it. The following error message is ...
0
votes
0
answers
472
views
Getting "err: max fee per gas less than block base fee" when estimating gas cost of a transaction
For the last few days, I have some trouble using the eth_estimateGas function from the Quick Node provider.
Indeed, after fetching a transaction from the mempool, I want to estimate the gas cost of ...
0
votes
0
answers
17
views
Someone can help me with thist issued: Gas estimation errored with the following message (see below)
Some one can help me to solve this issue, I'm student and I try to deploy a Smart Contract for a practic, I must Deploy 3 contract, When I Try to deploy the last one it show me an error "Gas ...
0
votes
0
answers
20
views
How to estimate gas for subsequent contract interaction in the same call
I have the same issue as here:
Can I estimate the total gas limit of several dependent transactions?
But i need to know the result on the fly in my react application.
Anyone has an idea?
0
votes
0
answers
156
views
BEP20 Token : Gas estimate failed, trying eth_call to extract error
I'm new to Solidity and I've successfully built a BEP20 smart contract using Solidity version 8.19. The contract includes several features such as pausable, ownable, blacklist, fee division among ...
0
votes
1
answer
183
views
Error while deploying smart contract on mainnet of ethereum
when I deploy a smart contract on Goerli testnet then it will easily be deployed but when I try to deploy the same contract on mainnet then it gives me this particular error even I have ethers in my ...
0
votes
0
answers
27
views
revert statement causes infinite gas estimation in Remix
I wrote an Ownable contract snippet that uses revert instead of require on the OnlyOwner modifier. This causes remix to estimate infinite gas fees.
Does anyone know why?
// SPDX-License-Identifier: ...
0
votes
1
answer
21
views
Gas estimation failed for marketplace contract
i receive an error upon trying to interact with buy function in my contract below
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol&...
0
votes
0
answers
32
views
Error: Transaction has been reverted by the EVM
I am trying to call the following solidity method from my smart contract in javascript:
address[] public investors;
function addInvestor(address investor) public {
investors.push(investor);
...
1
vote
1
answer
157
views
EtherJS calculates gas fee too low
newbie here so please bear with me.
I am using EthersJS latest v5 in order to interact with our contracts, which works great so far. However, I spotted that for a certain period of time (around 1st ...
0
votes
2
answers
154
views
0xapi swap Asking for a quote for code: 111, reason: 'Gas estimation failed'
const response= await fetch(https://api.0x.org/swap/v1/quote?sellToken=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&buyToken=0x6b175474e89094c44da98b954eedeac495271d0f&sellAmount=100&...
1
vote
1
answer
30
views
Would always keeping a non-zero amount of every relevant ERC-20 token lower transaction costs over time?
There is a Smart Contract call called SSTORE (See ETH Yellow Paper page 27: https://ethereum.github.io/yellowpaper/paper.pdf).
It costs 20000 gas if a zero byte is set to a non-zero byte.
It costs ...
0
votes
1
answer
60
views
EVM OPCODES gas cost source file
Where can I find the source code file where the EVM extracts the gas cost of all OPCODES?
What I need is the file where the EVM calculates the gas cost of SLOAD, ADD, etc.
For example, hardhat-gas-...
0
votes
1
answer
132
views
Gas estimation failed only in mumbai testnet not in VM environment
When I am calling a specific function I get this error. In Remix IDE, when I deploy and test the contract in a development environment like VM London, It is working without an error. I have tested ...
0
votes
1
answer
99
views
Error: cannot estimate gas
when calling the following code from a js script a get "Error: cannot estimate gas; transaction may fail or may require manual gas limit " , how to fix this error ? :
function ...
0
votes
1
answer
34
views
Why is MyCrypto is disabling the Sign Transaction button?
I'm using MyCrypto to execute a function of a smart contract but the sign Transaction button is disabled. I'm using the setting to auto calculate the Gas Limit and its suggesting a limit of 68908 with ...
0
votes
1
answer
29
views
Smart contract which uses more gas than estimated
I need to create a smart contract for which it would be hard to estimate gas usage.
Specifically, if I estimate execution gas usage at 90 000 gas, I want to consume e.g. 110 000 gas, so that the ...
1
vote
1
answer
825
views
Estimate Gas from a smart contract on polygon with ethers
I deployed a smart contract on polygon mainnet and want to estiamte gas costs before calling the function. This is my smart contract:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import &...
2
votes
2
answers
684
views
How to find out when pending transactions go through? Ideally I'd be alerted
How do I know when transactions are either successfully mined or still sitting in the mempool? I don't want to just overbid on gas to get my transaction to get mined faster / more instantly from the ...
0
votes
1
answer
90
views
Smart contract gas costs
What is the gas cost of deploying a Solidity contract, and how can I estimate it before deploying? Are there any strategies for minimizing deployment costs?
0
votes
3
answers
402
views
USDT transfer on my contract fails
I am now developing a ICO smart contract which receives USDT tokens from other people and withdraw.
My withdraw function in contract is below.
function withdraw() external onlyOwner ...
0
votes
0
answers
138
views
Error: cannot estimate gas; transaction may fail or may require manual gas limit in goerli testnet
I am Trying to send transaction to my smart contract and I get this error:
I estimated the gas price with const gasPrice = await provider.getGasPrice(); got the error tried using gas price greater ...
1
vote
1
answer
50
views
Gas cost of mapping operations
Suppose, your contract has something like
if (_balances[account] >= someNumber) {
_balances[account] = _balances[account] - _balances[account]/10;
}
What is the gas cost of this operation? I ...
0
votes
0
answers
60
views
Right way to estimate gas needed for a token transfer
I'm designing a forwarder wallet contract, user will deposit ERC/BEP-20 tokens and i will collect them back to a central wallet by calling my contract's function which will simply make a transfer of ...
0
votes
1
answer
44
views
reactjs get contract call fees
Chain used: Poylgon/mainnet or mumbai
I am trying to get gas fees for a contract call.
I should be able to let user chose if : Medium or High
Same as metamask does it:
but this should be done on user ...
1
vote
2
answers
35
views
Predict future gas price
I am wondering, is there a way to "predict" future gas prices? I would like to find a gas price or at least approximation of it for the future block, so the one that is currently pending.
1
vote
0
answers
26
views
Complex factory optimization
After two and a half years of developing smart contracts on a non-EVM blockchain (Tezos), I started working on a few solidity projects, and I'm trying to understand some things.
I built a factory ...
0
votes
0
answers
431
views
transfer all ether from one account to a smart contract with ethers.js
i want to transfer ALL the ether in my account to the smart contract.
I am calculating the gasEstimate and then subtracting it from my total ether balance...but i get an ERROR saying code: -32000, ...
1
vote
0
answers
268
views
estimateGas with prerequisites (gas estimation requires approvals first)
I am trying to estimateGas for an Ethereum transaction with ethers signer.estimateGas(). This transaction should execute several trades on arbitrary DEXs.
To execute the transaction approvals of ERC-...
0
votes
1
answer
21
views
What is the optimal way to estimate dependent transactions together?
I am looking for a solution to estimate multiple transactions together before submitting any of them. However some of these transaction depend on the other in the sense, if they are not submitted in ...
0
votes
2
answers
97
views
how to estimate the gas price while performing bridge using Axelar network?
I am using the Axelar network to transfer tokens from chain A to chain B I am using the function callContractWithToken in the Axelar network I need to figure out the gas fee which I should send to the ...
2
votes
0
answers
24
views
What values for the global state variables does geth use for estimateGas?
What values for the global state variables does geth use for estimateGas?
For example, block.timestamp.
1
vote
0
answers
99
views
tx.gasprice gives wrong gas estimation
I am using tx.gasprice and block.basefee in my contract to calculate the used gas.
The problem is that I can't estimate the gas correctly or sometimes not at all when the contract uses tx.gasprice;.
...
0
votes
1
answer
100
views
Wrong gas estimation when using tx.gasprice
I use tx.gasprice and block.basefee in my Smart Contract to calculate how much eth the User spent, to send the spent amount back to the Relayer, because I am using meta Transactions.
Now I wanted to ...
2
votes
1
answer
1k
views
How to get gas estimate and gas price on Polygon Mumbai Chain using web3.py?
I have deployed a contract on Goerli test net and used the following to get the estimated gas and current gas price.
contract = web3.eth.contract(address=contract_address, abi=contract_abi)
...
0
votes
0
answers
36
views
Can Ethereum smart contract sell token at fixed price that includes gas fee?
I am new to solidity and Ethereum in general.
I am using openZeppelin lib and trying to modify an existing contract that exchanges ERC-1155 tokens so, that the price it expects to be payed for token ...