Questions tagged [gas]

Gas is a 'sub-currency' which enables the EVM and Ethereum's decentralised computer to run -- with each operation, an amount of gas (proportional to the computational effort required to perform the operation) is consumed.

Filter by
Sorted by
Tagged with
2 votes
1 answer
22 views

How to estimate gas cost for a polygon zk evm transaction?

I understand how to estimate gas cost for L2s like Arbitrum and Optimism because their documents provide some details, e.g. total gas cost = L1 poster fee + L2 network fee. But I really cannot find ...
Felix's user avatar
  • 21
0 votes
0 answers
12 views

How to query or compute historical gas usage by address?

I'm trying to understand how services like fees.wtf calculate lifetime gas used by and address. Is there an JSON-RPC call or would I have to run a modified full node to index? Similarly for top gas-...
casualprogrammer's user avatar
0 votes
0 answers
12 views

Gas reporter does not report gas usage for low level calls

I am using npx hardhat test command to get the gas usages analysis. My configuration to get the report is like below. In my tests. I have tests for deployment, functions calls, but also some other ...
Ferda-Ozdemir-Sonmez's user avatar
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 ...
Helia Marami's user avatar
0 votes
0 answers
10 views

Do gas prices vary based on volume of transaction?

Do gas prices vary based on volume of transaction ?
Izuchukwu Emmanuel's user avatar
0 votes
0 answers
15 views

Setting High Gas Limit

I hope you guys are doing well! I am new to the Web3 space, so please excuse my ignorance. After viewing numerous tutorials, many of the tutorials like to do this when setting the gas limit const ...
Matt Gates's user avatar
0 votes
1 answer
18 views

How can I control how much gas is left in the middle of a function?

I am working on an ethernaul challenge (below). The challenge is to successfully call enter(). I have it all solved except for the part where gasleft() % 8191 has to be 0. I tried using a while (while ...
user127148's user avatar
1 vote
0 answers
18 views

Why smart contract call() is cheaper than sendTransaction when send ether to a wallet holding ether

// Solidity function sender(address payable _to, uint _value) private { (bool success,) = _to.call{value: _value}(""); require(success,"Fail Send By Call"); } // ethers ...
imelon2's user avatar
  • 455
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 ...
Ashraile's user avatar
0 votes
2 answers
23 views

New Account with no transaction

I'm working with my metamask wallet to interact with my DApp. While reading about data in Ethereum, I read that the blocks in the chain do not store any account information. It will have only ...
Valli Nayaki's user avatar
1 vote
2 answers
31 views

Optimizing Gas Costs and Replacing For Loops in Solidity Function with Large Dataset

I have a Solidity smart contract with a function drawLottery that processes a large dataset of potentially 1 million tickets. The function contains several for loops for iterating through the tickets ...
PraveenMatheesha's user avatar
0 votes
1 answer
30 views

Gas griefing in "typed" external calls

I was wondering whether the "insufficient gas griefing attack" is possible in cases when the external call is a typed call rather than an inline call with lower level utility functions (i.e. ...
Mila A's user avatar
  • 264
0 votes
1 answer
51 views

trying to create contract on anvil/forge get error intrinsic gas too high

exact message: message: intrinsic gas too high -- CallGasCostMoreThanGasLimit, data: None generic counter contract from how to. googling around got me some old error somewhat related but not sure ...
Pavel Zaitsev's user avatar
1 vote
1 answer
57 views

Tracking the spedup transactions from metamask

while building a Dapp using metamask to make transactions, i figured that metamask is not responding correctly when a transaction is spedup, making my code wait forever for a canceled transaction that ...
Kaki Master Of Time's user avatar
0 votes
2 answers
22 views

What is the most efficient way to make sure there are no duplicates in an array?

Is a nested for loop (like below) the best and most gas efficient way to make sure there are no duplicates in say an array of addresses? I can't think of a better one but it seems very inefficient for(...
auditor_chick's user avatar
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 ...
Andriy's user avatar
  • 1
0 votes
0 answers
31 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. ...
MShakeG's user avatar
  • 1,443
0 votes
0 answers
29 views

Deploying On Remix Returned Error 32000 Gas Issue?

So i am trying to publish a smart contract using a guide. https://github.com/tanishbaansal/legendary_token/blob/main/Legendary.sol When i am trying to deploy to livenet it gives me the following error,...
Jim Mike's user avatar
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 ...
MShakeG's user avatar
  • 1,443
0 votes
1 answer
45 views

Converting an optimized for addition loop into inline assembly (0.8.20)

I have to loop through an array that will contain <10 addresses. I've already optimized for gas costs as much as possible using native Solidity. But I realized this loop can be improved further ...
Ashraile's user avatar
3 votes
2 answers
51 views

Are storage variables tightly packed like struct fields?

Tight variable packing is a known coding pattern in Solidity for saving gas by placing struct fields that are lower than 256 bits closer to one another. Does this logic apply to storage variables? ...
Paul Razvan Berg's user avatar
1 vote
0 answers
38 views

How does Gelato's Relay service work? How is it possible for another wallet to send my signed transaction (matching sender address) and pay gas?

How does Gelato's Relay service (used by gnosis safe relayer) work? How is it possible for another wallet to send my signed transaction (matching sender address) and pay gas? Does it require Gnosis to ...
Nic Szerman's user avatar
1 vote
1 answer
37 views

Why don't ETH transfers cost more when the recipient's balance is zero?

The SSTORE opcode has differential pricing depending on what the original, current, and new storage values are (see EIP-2200 for the full details). In short, the idea is that setting a zero value to a ...
Paul Razvan Berg's user avatar
1 vote
2 answers
170 views

Remove the element from array where order matters?

I am presenting my use case here. Let's think of a dating app where each candidate enters their preferences and we store their data and add them to an array. when someone enters that matches with any ...
Rashid Ul Haq's user avatar
1 vote
2 answers
192 views

Why is Transaction Value showing 0 ETH on Etherscan?

I'm not sure why the transaction value on Etherscan is showing as 0 ETH when the transaction was confirmed. According to the recipient, they haven't received anything in their wallet either and I'm ...
Dan's user avatar
  • 11
0 votes
1 answer
26 views

Read from a state variable without sending a transaction

https://solidity-by-example.org/state-variables/ the site says "you can read state variables, for free, without any transaction fee". But when I do a get - call in Remix, a transaction is ...
Forgotten Semicolon's user avatar
0 votes
0 answers
21 views

Eth::Client::ContractExecutionError - transaction underpriced

I am using the eth gem ruby library https://q9f.github.io/eth.rb/ to execute a function called from the ABI but it keeps getting the error transaction underpriced. I assume that it has something to do ...
javanoob2pro's user avatar
0 votes
1 answer
23 views

how pay network fee for many accounts

i have crypto pay getaway in my application And we only receive Tether on the (Ethereum and BSC and Tron) networks The application creates a wallet address for each user 0x123...User1 (Only USDT ERC-...
ioxoi's user avatar
  • 3
1 vote
1 answer
95 views

Optimizing Gas Costs in Solidity Smart Contracts: Best Practices?

I'm working on a Solidity smart contract and I'm concerned about the gas costs associated with its execution. I want to optimize my contract for gas efficiency to save on transaction fees and improve ...
Mehran Ra's user avatar
  • 481
1 vote
1 answer
60 views

How can I avoid out of gas on multiple eth transfers when looping addresses?

Hello everyone good day, I'm working on an automated eth distribution function that sends eth to all the nft holders of a determined collection (using ERC721A as standard for the nfts), it works well ...
baeza.eth's user avatar
1 vote
1 answer
335 views

Significant gas cost difference between store data in initial variable and change data

// SPDX-License-Identifier: GPL-3.0-only pragma solidity ^0.8.10; // when SAVE == address(0) call setSave execution cost 22622 gas // when SAVE != address(0) call setSave execution cost 5522 gas ...
imelon2's user avatar
  • 455
2 votes
4 answers
89 views

What is the purpose of (success); after a call?

I'm looking through the EIP-4337 account abstract sample repository and am not sure what the purpose of (success); is in the following function. function _payPrefund(uint256 missingAccountFunds) ...
Milk's user avatar
  • 391
0 votes
1 answer
34 views

Gas cost on mapping

I'm reading docs on Venom and they said that the problem on using mapping in ERC20 contract is "Now let's imagine that we have an erc-20 like mem-token contract with one large hashmap of token ...
dang.pm.IT's user avatar
1 vote
2 answers
102 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 ...
Dakata's user avatar
  • 205
1 vote
0 answers
77 views

Can I make a contract call to refund the unused gas fee to a specific address instead of the msg.sender?

Can I make a contract call to refund the unused gas fee to a specific address instead of the msg.sender? I want to use this as a means of charging fees for my project.
Benjamin's user avatar
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 ...
undefined's user avatar
  • 121
0 votes
0 answers
56 views

Is there anyway to reduce gas fee for uniswap v3 ExactOutputSingleParams?

Question is simple. Is there anyway to reduce gas fee for ExactOutputSingleParams ? function swapExactOutputSingle(uint256 amountOut, uint256 amountInMaximum) external returns (uint256 amountIn) { ...
xlogic land's user avatar
0 votes
0 answers
25 views

How to estimate gas cost to update uint256?

I have a need to update a uint256 state variable in a solidity contract that was deployed with a proxy. When calling the function to update the variable programmatically with Ethers, the total cost is ...
Vektor's user avatar
  • 101
0 votes
0 answers
66 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(...
user124283's user avatar
0 votes
1 answer
102 views

Where do arbitrum gas fees go?

Similar question to here except, based on the arbitrum docs: ⚠️ Note: There is no protocol level incentive to run an Arbitum full node. I know the sequencer gets paid some amount of the fee, but I ...
Patrick Collins's user avatar
1 vote
0 answers
22 views

Reduce gas price?

I'm working on a sniping bot on uniswap, and i have a little problem : the first ones to buy are those who pay the most. Pretty logical, but I don't really want to pay 300$ in priority gas to be the ...
Newly Sama's user avatar
0 votes
0 answers
22 views

Simple function causing very high gas fees solidity

Hello everyone i just recently dpeloyed my first main net contract. Now on solidity and locally all the fees looked good and it was quite minimal. I have this function which creates a bet and just ...
Wesley van S's user avatar
0 votes
0 answers
14 views

Web3.py: 'intrinsic gas too low', how to select gasPrice and gas?

In previous question on the forum this issue was already discussed, but it does not address another one: how to select gas and gasPrice so that you wouldn't bet all wallet's money and transaction ...
EndOfTheGlory's user avatar
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 ...
Joe B's user avatar
  • 3
0 votes
1 answer
263 views

unpredictable gas limit error doesn't go away after setting gasLimit manually

I have this contract which is written in solidity and one of the functions (getMyActivity()) returns an array of structs and im trying to call it from my frontend which is written in ReactJS but i get ...
Shadq's user avatar
  • 83
0 votes
0 answers
35 views

`gas` vs. `gasLimit` fields

I am trying to submit a transaction with a gas limit set. In the documentation, I find a field referred to as gasLimit with the following description gasLimit – the maximum amount of gas units that ...
davidsawyer's user avatar
1 vote
2 answers
27 views

How to populate large integer arrays in Solidity?

I'm currently building an NFT fantasy league game on ethereum where I want to add the functionality of on demand minting of random tokens. For that I need to keep track of the tokens that are ...
Inshal Aamir's user avatar
0 votes
1 answer
280 views

How to correctly specify maxPriorityFeePerGas?

I am trying to send a transaction quickly by adding a priority fee that is half the base fee with the following logic: const { baseFeePerGas } = await client.getBlock(); const priorityFee = ...
Sam Scolari's user avatar
0 votes
0 answers
17 views

Why does my transaction not start with full gas?

Im trying to optimize the gas costs of my smart contract, and noticed a large chunk called "Initial gas" in the tenderly debugger. Upon digging further, I confirmed that the function call ...
Tilman Kieselbach's user avatar
0 votes
1 answer
138 views

How much does it cost to clog the Ethereum Network exactly?

Currently the largest gas guzzler to clog the Ethereum network is the Mint contract below. Supposedly there are users purposely causing high gas prices using this function. Why would anyone do this ...
Patoshi パトシ's user avatar

1
2 3 4 5
34