Questions tagged [gas-estimate]

The tag has no usage guidance.

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

How can I reduce the gas cost of my Solidity contract functions and improve performance?

How can I optimize the gas usage of my Solidity contract functions, and what are some tools and techniques for doing so?
  • 355
0 votes
1 answer
10 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?
  • 355
0 votes
3 answers
23 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
14 views

I have this smart contract for smart parking, but I don't know if gas cost is normal or not

This estimate for gas consume I need evaluate this value if high or normal // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Payment { address owner; uint ownerBalance; ...
0 votes
0 answers
21 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
25 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 ...
  • 111
0 votes
0 answers
26 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 ...
  • 115
0 votes
1 answer
20 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
26 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.
  • 33
1 vote
0 answers
14 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
80 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
72 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
17 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 ...
  • 1,234
0 votes
1 answer
26 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
18 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.
  • 21
0 votes
0 answers
36 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
58 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 ...
1 vote
1 answer
331 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) ...
  • 53
0 votes
0 answers
27 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 ...
3 votes
0 answers
39 views

Elegant way to purposefully charge more gas in a smart contract

I am trying to run tests to see how much a smart contract will cost, but since I am in my research period, I have to make some assumptions on how my smart contract will be developed. I would like to ...
0 votes
2 answers
403 views

How to call contract function with ethersJs?

I wanna call my smart contract function using ethersjs , but when i call function i got this error: Unhandled Runtime Error Error: cannot estimate gas; transaction may fail or may require manual gas ...
  • 290
0 votes
1 answer
61 views

Transaction gas problem

I wanna send transaction and before that i wanna calculate the gas fee and input value as much as : finalAmount = value - gasFee For doing this i get gas price from provider this way: const gasP = ...
  • 290
0 votes
2 answers
48 views

Getting "Unknown Proposal ID" when casting vote in DAO

I am having trouble voting in my DAO. I have created a ERC721 Token and a DAO, both using the OpenZeppelin Wizard // SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import "@openzeppelin/...
0 votes
1 answer
39 views

What factors does the opensea NFT origination gas cost depend on?

I am trying to understand what opensea NFT origination gas fees depend on. My main question is if the fees depend on the size of NFT (video vs plain image), but I have put together a list of all ...
  • 103
0 votes
0 answers
13 views

How to benchmark a function for gas over a range of input values?

Say I have a function some_math(uint256 x). I wish to benchmark the gas consumed for x in the range 0 to 100. Foundry has fuzz testing but it's for randomized values. I omit out of bound values using ...
1 vote
0 answers
23 views

Deterministic gas use

In ether, any pure ether transfer will always cost 21000 gas. However, due to the nature of the MPT used in the Balances tree, wouldn't some addresses have more layers of the tree to hop through and ...
  • 11
0 votes
1 answer
155 views

How to estimate gas needed

For the context (can be skipped) : I have some deposit accounts containing some ERC20 token but no ETH. I would like to send all this ERC20 to a main account. In order to do that, I need to send ETH ...
0 votes
0 answers
12 views

0X swap quote api return expected slippage null

Why in the response object, expected slippage variable is null when a user fetch for swap-quote? In the docs its available for only few ethereum pairs but not others. How else can we warn the user of ...
1 vote
1 answer
44 views

Payable function won't get executed (gas estimation fails)

Hey guys I am trying to create a function that would send Ether to a contract based on how many "USD" I put into an argument. But it keeps failing to estimate the gas and thus the ...
  • 143
1 vote
0 answers
10 views

NodeJs or Python libraries for estimating the gas costs

I am looking for libraries in Python or NodeJs which can provide gas cost estimations like the one provided by Hardhat. Please share knowledge you have regarding this..
0 votes
2 answers
155 views

modifier vs function which method is more efficient in terms of gas?

contract test { address public _onwer; error NotOwner(); modifier OnlyOwner1() { if(msg.sender != _onwer) { revert NotOwner(); } _; } function OnlyOwner2() ...
  • 189
0 votes
0 answers
23 views

Liquidity removal strategy ERC 20 UniswapV2 (max tx)

I deployed a token a few months ago, provided liquidity (1 ETH), locked liquidity, and renounced to the ownership. The specifics of the contract are: 1,000,000,000 supply 20,000,000 tokens max tx 5% ...
0 votes
0 answers
154 views

How to calculate the estimated gas of a smart contract method like MetaMask?

I deployed a smart contract on testnet and used the following method to estimate the gas of a method: web3.eth.getGasPrice((err, gasPrice) => { if (err) { // Error handler } ...
0 votes
0 answers
53 views

Node module for dynamic gas price calculation

Are there any modules written in JS/TS to dynamically adjust the gas price to ensure transactions are included? I.e. if the transaction is not included after a while, the gas price should be increased ...
0 votes
1 answer
125 views

I'm trying to call a function from a deployed contract, But I'm getting the following error:

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution reverted: ERC20: insufficient allowance { "...
0 votes
2 answers
105 views

Gas estimation errored with the following message (see below).When sending ethers to the deployer of the contract

This contract is a simple contract that let other people send eth to the holder of the contract. The sender should send minimum of 50$ in form of eths. But every time I get this error This is my code
0 votes
0 answers
129 views

Error: Cannot estimate gas; transaction may fail UNPREDICTABLE_GAS_LIMIT

I have this error when I try to deploy with Fuji and also with a Subnet, but using Hardhat local node I have no problems. I have tried different options. Here is my hardhat.config.js with the ...
0 votes
0 answers
94 views

Difference Gas Report and Reality

I work with Foundry (Forge, Anvil, Cast). According to their documentation one can run a gas estimation for the tests one has written. I have a very simple test for which I wanted to have a gas ...
0 votes
1 answer
45 views

doing a trial run to calculate gas before submitting a transaction

I'm wondering if there is a possibility of doing a trial run of a transaction so that the gas can be worked out before submitting to the network? I know that there are estimates but in certain cases ...
  • 105
0 votes
0 answers
14 views

How does eth_estimateGas work? [duplicate]

I'm getting an UNPREDICTABLE_GAS_LIMIT error on goerli for a transaction but I can't reproduce it on hardhat. I'm wondering if it might be due to some subtle differences in implementations of ...
1 vote
0 answers
273 views

Gas estimation failed error

Following error is coming: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution reverted { "...
0 votes
1 answer
60 views

Mapping/variable in struct. Which one is cheaper in terms of gas?

Considering the following different approaches: 1st approach struct Apartment { string apartmentAddress; string description; string image; } struct Reservation { Apartment apartment; uint32 ...
0 votes
0 answers
56 views

gas usages of Uniswap-v2-periphery for each pair with swapExactTokenForToken

Currently, I'm using uniswap v2 periphery in my contract and using swapExactTokenForToken, the question is why there are a lot of differences in gas used between swap functions in multiple pairs? BOO ...
  • 108
0 votes
1 answer
47 views

Ethernaut #11 Elevator, Gas estimation failed

I'm trying to solve Ethernaut #11 Elevator. My solution works when I deploy a copy of the instance contract by myself on Remix VM, but when I try it on the real instance on the Rinkeby network, using ...
  • 1
1 vote
1 answer
141 views

Incorrect Gaslimit estimation for transaction

So, I have been testing a transaction with hardhat and etherjs, that internally makes two staticcalls and a low-level call. However, by default, the transaction fails at the low-level call, as it is ...
1 vote
1 answer
709 views

Why ether transfer sometimes use more that 21000 gas?

I noticed that some ether transfers use more that 21000 gas. Here is an example which transferring ether from an UOA to a contract used 21033 gas: unusual transaction While another transfer with same ...
0 votes
1 answer
82 views

How to estimate gas of a receive method() in truffle

I know that if my contract has a name() method. I can go to the truffle console and try contractInstance.name.estimateGas() and this will give the estimate gas for that method. but what if have a ...
0 votes
1 answer
185 views

Remix gas estimate to be infinite for a super simple contract

I have an extremely basic contract, but saw infinite execution cost on Remix. Any insights will be appreciated. //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Config { address ...
0 votes
0 answers
94 views

Conditional gas settings for BSC transactions with MetaMask

The main objective is to conditionally set the gas price for the transaction on MetaMask in BSC. I understand that MetaMask by default provides with the settings or to speed up the transaction but the ...
0 votes
1 answer
31 views

Smart contract unpredictable gas for seemingly simple method

I'm having an issue where a method that seems straightforward is showing a huge amount of gas requirements. I tried to run it from the verified polygonscan UI and metamask tells me it can't estimate ...
  • 101

1
2 3 4 5
7