Questions tagged [gas-estimate]
The gas-estimate tag has no usage guidance.
281
questions
0
votes
0
answers
2
views
getting error while calling getrandomnumber in my smart contract
error message: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?
execution reverted { "originalError": {...
1
vote
0
answers
10
views
Maximum gas estimate
eth_estimateGas provides estimated final gas consumed by transaction and accounts for gas refund in the end of transaction. However, is there a way to estimate maximum gas the transaction may consume ...
0
votes
1
answer
26
views
How to query estimatedGas for an ERC20 transaction?
This is the json-rpc call I make
{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [
{
"from": "...
0
votes
2
answers
27
views
The Ethernaut King Challenge
I am trying to pass level 9 of Ethernaut challenges known as the King contract.
My designed contract for hacking the King contract is as follows:
pragma solidity 0.8.0;
contract MaliciousKing {
...
0
votes
1
answer
21
views
I am misunderstanding the gas data i'm seeing. Where is my disconnect?
I must be missing something. Maybe someone can help me see where i'm misunderstanding.
Forgive me if this question has been asked already. I'm seeing some adjacent questions but haven't been able to ...
0
votes
0
answers
21
views
How does web3.eth.estimateGas work?
I have tested two situations using "web3.eth.estimateGas" to estimate the gas cost of contract transaction.
First one is to get contract by the address of a deployed contract and estimate ...
0
votes
1
answer
47
views
How do node providers (e.g. Infura, Alchemy) determine gas pricing on contract writes?
When writing to a smart contract, we can specify the priority and fee per gas.
await contract.connect(owner).foo({
maxFeePerGas: "<YOUR FEE>"
maxPriorityFeePerGas: "<YOUR ...
-1
votes
1
answer
22
views
What is the state of the art of transaction costs in a pure gambling smart contract?
AFAIK, the vast majority of crypto gambling uses crypto only as a payment rail, and then implements the gambling step in a traditional (though usually provably fair) way. Using a smart contract to ...
0
votes
0
answers
34
views
How to estimate gas for a solidity function params
I have a function that takes multiple structs like so:
struct A {
bytes myBytes1;
bytes myBytes2;
bytes myBytes3;
}
struct B {
bytes myBytes1;
bytes32 myBytes32;
bytes myBytes3;
}
struct C {
...
0
votes
0
answers
39
views
Is gasleft() the best way to manage big loops in solidity?
I'm developing an Smart Contract that has to iterate through an undetermined size list of ERC20 tokens, and make a swap for each token. I'm aware that you cannot loop an undetermined size list, ...
0
votes
0
answers
17
views
Gas fee for deploying smart contract
From ETH gas station, I see that the fee is relatively low. However, when I tried to deploy my own smart contract, why does it cost so much more? Is it a way to deploy my smart contract cheaper? ...
1
vote
1
answer
55
views
estimateGas gets called too early and doesn't return correct value
I am using a alchemy node to calculate the gas limit of a smart contract once the state of the contract has changed to what I am looking for. I monitor this change by calling a read method on the ...
0
votes
2
answers
196
views
Web3.py : Eth.estimate_gas method returns always the error when checking two address are equal
Following is the smart contract code, setMessage method always fail with revert while estimating gas using web3.py, even when the address user is same as msg.sender.
when the contract is deployed on ...
0
votes
0
answers
25
views
Is there still gas refund for SSTORE to 0 instructions?
I'm trying to optimize a contract and wondering if I can still rely on gas refunds to optimize for gas?
https://twitter.com/n2ckchong/status/1365843261567365121
I've read from this tweet that there ...
0
votes
2
answers
87
views
Understand the output of eth-gas-reporter
So, I am using the eth-gas-reporter package to understand how much gas functions costs (via hardhat test). But I don't understand the output. What is the meaning of 5 gwei/gas,calls, what are the ...
1
vote
1
answer
454
views
Estimate gas fees for smart contract function call with Ethers.js
Let's say you have a function in your smart contract, like:
function saveUser(address newUser) public {
// Saving user
}
How can we estimate, with Ethers.js, what the gas price will be for ...
1
vote
1
answer
277
views
What is max amount of ETH that can be spent during a single transaction (theoretically)
I know users can set up a gas limit as not to spend too much.
I am also aware of the "gas block limit" (how much gas can be consumed in a single ETH block). However, the user can set the gas ...
0
votes
1
answer
31
views
What's the relative cost of reading `msg.value` more than once?
Let's say we have the following payable method defined in a contract:
function foo() public payable {
if (msg.value >= thresholdValue0) {
// some logic..
} else if (msg.value < ...
0
votes
0
answers
78
views
Gas estimation failed Error Deploying Contract
I am trying to deploy a contract on Binance test network using remix but every time I try to deploy I get the error Internal JSON-RPC error. { "code": -32000, "message": "...
0
votes
0
answers
71
views
web3j: how to estimateGas before sending transaction
I am working with web3j, and I have the following code to send a transaction and get its receipt:
TransactionReceipt mr = contract.mintTo(WALLET1_ACCOUNT1_PUBKEY, tokenURI, tokenId).send();
But I ...
0
votes
1
answer
236
views
Execution will likely fail Internal JSON-RPC error. { "code": -32000, "message": "stack limit reached 1024 (1023)" } On The Polygon Network
I have been working on this Flashloan arbitrage and when I call the execute operation function I get Gas estimation errored with the following message (see below). The transaction execution will ...
0
votes
1
answer
194
views
Changing Gas Price value in Metamask input field with JS
Hello I have a problem when I need to accelerate transaction in Metamask, I want to increase the gas fee price but it`s not working...
As u can see in image I run script to change value but metamask ...
0
votes
1
answer
58
views
Avoiding transaction failures in truffle migration to mainnet
I am trying to deploy my smart contract with truffle and an Infura HDWalletProvider. Here's my dry run (I edited/shortened it for brevity):
Migrations dry-run (simulation)
=============================...
0
votes
0
answers
15
views
Gas estimation inconsistency between different instances of web3
I have web3 instance in front-end with Metamask as a provider and in back-end I have a web3 instance with HDWallet as a provider. First I estimate gas for the call in front-end but the actual call is ...
2
votes
1
answer
229
views
Is there an Ethers.js equivalent of Low, Medium, High gas preferences?
I'm finding polygon main network transfers to be quite slow, taking ~5 minutes on average. If I execute them on polygonscan directly, I can speed them up by setting the gas preference slider to High ...
1
vote
0
answers
184
views
Ethersjs estimateGas bypassing insufficient funds
I am using ethersjs to call my contract methods. The problem stems from trying to making the Metamask popup despite the account has insufficient funds in the first place. I am trying to do the popup ...
0
votes
1
answer
745
views
How to calculate transaction fee using ethers.js
I am trying to calculate the transaction fee of a tx before prompting MetaMask using ethers.js. So for I have:
const gasPrice = ethers.utils.formatUnits(await ethers.getDefaultProvider().getGasPrice(),...
0
votes
1
answer
25
views
Estimate contract transactions fees
I swapped some BNB to Cricket tokens on Pancakeswap and I had a bad surprise when I had to swap back those crickets to BNB. Indeed the transaction fees were very high (7.41$) as you can see here: ...
0
votes
0
answers
179
views
How to estimate gas manually given the source of a contract?
I am using ethers.js to call my own smart contract. I am getting this result:
Error: cannot estimate gas; transaction may fail or may require manual gas limit
I also get the above message when I ...
0
votes
0
answers
35
views
Who's responsible for estimating gas price and gas limit?
I know that when you use Metamask, gas estimation is done for you automatically. Also ethers.js has a getGasPrice function that does this for you. I was wondering what happens under the hood? Do both ...
2
votes
0
answers
107
views
Does brownie have functionality to analyze gas costs for all function calls?
Does brownie have any sort of functionality that gives a breakdown of the cost to deploy all contracts and execute all function calls within a brownie project with min, max and average gas cost ...
1
vote
1
answer
109
views
Does the EVM calculate the gas used for a transaction in real time?
Does the EVM calculate the gas used to execute a transaction on the fly as opcodes are being executed? So if there's a branch in code whose conditional is satisfied then additional gas is used to ...
0
votes
1
answer
288
views
How can I get the current ETH gas fees in python
I am trying to make a python program that gets the ETH gas prices. I am trying to avoid selenium scraping because I am using this for a discord bot. Does anyone know any good python APIs I can use?
0
votes
0
answers
12
views
gas vs gasLimit in web3.js [duplicate]
I've seen a bunch of stackoverflow posts on this and want to make sure I've got it right. I'm running into an issue where on test networks I can do this:
contract.methods.mint(1).send({
from: ...
0
votes
0
answers
64
views
Truffle test: How to Calculate transfer Gas cost to be 2300 wei?
I am using gasleft() function. I am storing the gasleft() before transfer and gasLeft() after transfer, and then finding the difference. But I am getting wrong result maybe 7554. Somebody please guide ...
1
vote
2
answers
483
views
How can I check how much gas I'll need to deploy a contract with eth-brownie?
I kind of accidentally deployed an ERC20 token contract on the mainnet and brownie didn't even ask me to confirm so I ended up spending $700+ worth of ETH to practice. I didn't think it would cost ...
0
votes
1
answer
54
views
Do any one had a template API to display/show estimated gas price for a transaction?
Description of the issue: I do not have sufficient funds in my wallet to transfer a token from my wallet to an external wallet. So the transaction will fail and shows us an error message. Instead of ...
0
votes
1
answer
109
views
estimate gas usage for a contract
I'm trying to estimate the gas usage for a smart contract for an NFT token - is it possible to do before the actual sale?
contract is already published and all functions as well.
so I want to know how ...
1
vote
1
answer
15
views
why did this transfer transaction fail on eth?
https://etherscan.io/tx/0x8ad822a326243e69c4d5bcd3fe07466a82c2c00edbc53cbc0a211c6efbdd7dd2
checked ethgasstation and doubled the gas but it still failed, any ideas why it would?
1
vote
0
answers
55
views
Error when trying to estimateGas()
I'm getting the following error:
{ code: 13, message: 'execution simulation failed: status = 106' }
When executing this code:
const gasEstimate = await WJEWELContract.methods.mint(amount).estimateGas(...
0
votes
0
answers
178
views
Estimated Gas in JS Doesn't Match Metamask Gas Fee
I need help with figuring out the estimated gas for an approval. I'm able to get a number but it doesn't match what's in metamask. I'm a noob to web3 and so I'm not even sure I'm passing the correct ...
0
votes
1
answer
50
views
Computing gas fees to store a plaintext blob
I'm doing some math to figure out how much it would cost to store a multiple KB text blob in a single transaction, but the number I'm getting is too low to make sense.
Let's say I want to store 20KB ...
0
votes
0
answers
41
views
How to provide enough Gas while calling a function from another function
Here are my two functions. One of them loops over the other. However, when I execute the scheduleMultipleTransactions(), it seems it runs out of gas for calling scheduleTrasnactions() several times. ...
0
votes
0
answers
623
views
Hardhat estimatedGas error on smart contract deployment
I'm getting the following error when trying to deploy to BSC testnet:
Hardhat Error: cannot estimate gas; transaction may fail or may require manual gas limit (error={"name":"...
0
votes
1
answer
102
views
Help to find missing tokens
Actually, it's become a little complex. I am missing around 2 million-plus tokens now.
Here are the actions I have done.
Purchased GenshinShibInu tokens for $129 using Binance Smart Chain Wallet in ...
0
votes
1
answer
77
views
Method works on local but fails on Ropsten [closed]
Trying to debug this transaction (it's a large one that deploys a contract) that works on local but fails on ropsten.
First, it said
Error: cannot estimate gas; transaction may fail or may require ...
0
votes
1
answer
156
views
How to estimate gas cost (not gas price) per transaction?
Sorry for the newbie question.
So i had 2 different transactions with the same gas price and same function called
But it used different amount of gas unit (not gas price)
https://bscscan.com/tx/...
1
vote
0
answers
2k
views
Automated gas cost calculation in Hardhat?
Context
I've learned from this question that it is not (always) possible to compute the gas-costs of an arbitrary solidity contract a.sol because the amount of computation that it takes may depend on ...
0
votes
0
answers
13
views
What mainnet activities contribute to gas fees being and staying so high on Ethereum?
Gas above 100 gwei has been the norm for the past several weeks. This is a very expensive transaction cost when translated to dollars.
What contributes to such a high gas fee, and how come it's been ...
1
vote
1
answer
1k
views
If Ethereum 2.0 won't reduce gas fees on mainnet, what will? [closed]
For much of 2021, people who buy and sell ERC-721s believed that Ethereum 2.0 would reduce gas costs, while knowing that the London Hard Fork that was released in summer would only help reduce gas ...