Questions tagged [gas-estimate]

The tag has no usage guidance.

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

how to calculate the gas fee of my nft mint transaction

I have the following function to mint a nft on my smart contract (I am using the open zeppelin ERC721 contract) but I would like to stimate the gas feet from my web3 dapp. I know the formula is ...
0
votes
0answers
4 views

Is there a Java equivalent of estimateGas?

I read from many questions (example: How to estimate the cost to call a Smart Contract method?) that web3.eth has a method estimateGas that can provide an estimate of the gas usage of a transaction/...
0
votes
0answers
12 views

How to estimate gas price of contract call from a web3j-generated wrapper class?

Let's say I have some code as follows: Web3j web3 = Web3j.build(new HttpService(endpoint)); Credentials creds = Credentials.create(pk); DefaultGasProvider gasProvider = new DefaultGasProvider(); MyNFT ...
0
votes
0answers
21 views

How can I measure gas in solidity to increment a user's balance according to the amount of gas spent to call the function? [duplicate]

I have a function that I am calling and based on the logic of that function and how much gas it spends to execute the function, I want to increment a user's balance to reimburse the user for the gas ...
0
votes
0answers
50 views

Minting multiple ERC721 tokens estimating gas cost error

I have a function to mint multiple NFTs in my smart contract (max 10). I have another function to transfer the tokens to the msg.sender. Using hardhat locally, this all works nicely. However on the ...
1
vote
1answer
51 views

How does metamask come up its suggested gas fees?

How does metamask come up its suggested gas fees? How does it come up with a certain amount? What is it optimised for? Should you just use it or should you set your own?
0
votes
0answers
13 views

Redeploying the same contract using more gas on token.transfer()?

I redeployed a contract on Github with the same compiler and optimization parameters. However on token.transfer(), the redeployed contract uses about ~5k more gas than the original contract. Is there ...
0
votes
0answers
12 views

Best practices for functions with highly variable gas cost

I'm developing a Dapp with a function (let's just call functionA) that has potentially significantly different gas cost between invocations. This is due to the need for costly extra computation when ...
1
vote
1answer
32 views

Efficiently Accessing Mappings

I'm working on keeping track of data via a struct stored in a mapping. mapping(uint256 => Session); Here is the Session struct: struct Session { // UID uint256 id; // Timestamp ...
0
votes
1answer
30 views

ERC20 Mint Function returns "Uncaught (in promise) Error: Transaction has been reverted by the EVM"

I want to allow an external app to mint tokens when a user performs an action. I have a separate contract that calls the "mintTo" function for an ERC20 token. Here's the token contract. ...
2
votes
1answer
37 views

How estimateGas works internally?

I am building a sniper bot which continually estimating the gas for buying one token. Once the gas is successfully estimated, a transaction to buy the token is sent. But for many times it estimated ...
2
votes
1answer
73 views

I set a 3 gwei for gas price. Now my transaction has been pending for 48+ hours now. But blocks aren't even full!

I tried to set a gas price of 3 gwei for interacting with a smart contract. Now the transaction is pending for 48+ hours. If the blocks aren't full, why dont the miners pick it up? I can bump the fee ...
0
votes
0answers
73 views

Uniswap/Pancakeswap error -3200 when trying to exchange

I am developing my own contract and I am having the following issue: module.exports = { networks: { development: { provider: () => new HDWalletProvider(mnemonic, `http://127.0.0.1:8545`)...
1
vote
1answer
443 views

gas fee on OpenSea

First, I'm brand new to the Ethereum platform, so I do apologise if any of the following is considered stupid questions. Now, I will ask my question anyway I am setting up the first sale of one of my ...
1
vote
1answer
23 views

Are named returns more expensive?

Say I have the following Smart Contract: // SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.7; contract Test { function f1(uint256 a, uint256 b) external pure returns(uint256) { ...
0
votes
0answers
35 views

contract SwapAtUniswap on Remix Failing with gas costs

Hello Super Shadowy Devs Hi, I am trying to push a Transaction for my newly created contract SwapAtUniswap (deployed on Kovan) but its failing due to the following reasons : Gas estimation errored ...
2
votes
1answer
27 views

How does estimation gas work when using an unpredictable condition on a loop?

I'm new to solidity but a question comes to my mind. Say I have this example dummy contract. contract TestLoop { uint8 public blockNumber; uint8 public counter= 0; event LoopCalled(...
0
votes
1answer
374 views

Gas Estimation Execution Reverted (ERC20: transfer amount exceeds allowance)

I want to estimate gas cost for a smart contract function. It's a kind of deposit function which takes USDT tokens from user wallet to the pool. So I should call the approve() function first to ...
0
votes
0answers
17 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
1answer
168 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
279 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
264 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
46 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
59 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
21 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
31 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
29 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
642 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
112 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
175 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 ...
3
votes
2answers
5k 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
102 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
25 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
38 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
453 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
24 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
30 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 = ...
4
votes
2answers
802 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
86 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
83 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
4k 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
61 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
90 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
9k 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
382 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
126 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
34 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
36 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
51 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!

1
2 3 4 5