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.
1,724
questions
0
votes
1
answer
12
views
Why reduce security checks or use `unchecked` to save only a small amount of gas? How significant is the benefit?
I found several different token contracts, some of which add security checks to all operations, while others omit checks for operations that are unlikely to overflow. I would like to know if the gas ...
0
votes
1
answer
18
views
sometimes tx.gasprice fails in sepolia, why?
I have this simple test contract to try to understand why sometiemes when I call getGasPrice() transacion fails:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
contract TesterGas {
...
0
votes
0
answers
20
views
w3.eth.estimate_gas with onlyAdmin modifier
I have a smart contract function with an onlyAdmin modifier-
modifier onlyAdmin() {
require(admins[msg.sender], "You must be an admin to perform this action.");
_;
}
...
0
votes
0
answers
25
views
Swap without gas fee on bnbchain
Does anyone know how this guy can swap with gas price = 0 gwei?
1
vote
1
answer
116
views
Ridiculous high gas fee in production (ERC20)
I was trying to create a new smart contract with Remix. It should be something like a lottery. I made a simple function to enter the lottery:
> function enter() public payable {
> require(msg....
0
votes
2
answers
20
views
what exactly are the limitations of the require() function concerning my custom logic
I wrote some logic for a fundraising contract
function fund() public payable {
// myValue = myValue + 1;
require(msg.value.getConversionRate(s_priceFeed) >= MINIMUM_USD, "...
0
votes
1
answer
18
views
External call recipient can consume all transaction gas
External call recipients consume all transaction gas, leading to transaction reversion.
How to Prevent this?
0
votes
0
answers
8
views
How to efficiently distribute governance rewards?
I want to give a token reward for every governance member who voted to a Snapshot proposal. I know that Snapshot offers a feature called Boost, which will become a paid feature after its beta phase. ...
0
votes
1
answer
27
views
Is it more gas efficient to store a string literal or its bytes representation?
I am aware that it is generally discouraged to store strings on-chain. However, in case there is no way around this, I have a few questions regarding the gas and memory efficiency of storing strings ...
1
vote
1
answer
35
views
In Solidity, is division automatically unchecked?
I recently saw a Smart Contract with an unchecked division.
However, I thought division was automatically unchecked, as:
Biggest possible quotient = type(uint).max / 1 = type(uint).max (no overflow)
...
0
votes
1
answer
15
views
Is it more gas efficient to delete a mappping if it maps to a bool instead of setting it to false?
Consider a mapping of some wallet addresses to a bool to check if they are whitelisted:
mapping(address => bool) wallets;
Is it more gas efficient to delete the mapping when a wallet is not ...
0
votes
1
answer
29
views
Is there any EVM blockchain (not testnet) with 0 gas fees?
I know about SKALE, but is there any other alternatives?
0
votes
0
answers
27
views
UNPREDICTABLE_GAS_LIMIT error
I am getting an error when running a script that is supposed to generate a number of wallets and fund then with a certain amount of ETH once they are created.
Error:
ERROR:
reason: 'processing ...
1
vote
1
answer
25
views
Trying to send as much of my balance as possible through geth console: "gas required exceeds allowance"
I'm trying to send all of my ETH balance to another address. I try to do this the following way, but always receive an error:
[~] $ geth attach ipc:~/.ethereum/geth.ipc
WARN [06-21|15:26:14.974] ...
0
votes
0
answers
11
views
Finding cost of CHI gas token over a series of time
so I wanted to use a database I have to find the cost of the CHI gas token over a series of time. I got all the pools that have a CHI gas token, and I get data1 / data0 from all the sync events in ...
0
votes
0
answers
25
views
EVM Transaction Issue: Inconsistent Out of Gas Errors
I'm facing issue with Inconsistent Out of Gas Errors on BSC Testnet
This is fail transaction: https://testnet.bscscan.com/tx/0x669f2e8150825e9be9e0ec7da13b112691082ee43c0227afbb6b4dcbf08bec6c
Although ...
2
votes
2
answers
149
views
Why transaction with higher gas priority fee executes later than with lower priority fee?
I have found 2 transactions, the first one is has position 1 in block and another one has position 53 in the same block, although the second transaction has more fee to pay for gas and more priority ...
2
votes
1
answer
51
views
Does having identical public keys and messages for bn254 verification decrease gas cost?
I want to verify an aggregate bn254 signature. Now lets say that I am aggregating 3 identical signatures which results in a new signature. So now if I give 3 identical public keys and 3 identical ...
0
votes
1
answer
109
views
TransactionRevertInstructionError: Transaction has been reverted by the EVM
I am now trying to use addLiquidity with Uniswap V2 on sepolia testnet.
I am using web3.js in truffle, but there are some areas where errors keep occurring.
I have posted only the necessary code here.
...
0
votes
1
answer
55
views
Help ERC-20 contract, ERROR Txn: Contract creation code storage out of gas
I have created an ERC-20 token contract, and I have a problem with the gas. I must not have calculated the gas expenditure correctly, and on Etherscan, I get a warning. This is the link to the ...
0
votes
0
answers
99
views
How to multihop swap with Uniswap V2/V3 without transfering back and forth intermediary tokens to caller?
In the case of multihop swap on Uniswap, it is convenient that pools send the output token prior to calling the swap callback.
It allows to pay the first pool with the output of the last pool without ...
1
vote
1
answer
22
views
Reentrancy Vulnerability
I've noticed that the offer function uses the .call{value: amount}("") method to send Ether to the recipient's address.
Could anyone provide insight into whether this function is indeed ...
0
votes
1
answer
34
views
Trying to deposit ETH to my contract with Chainlink Functions. Getting gas estimation errors
We were not able to estimate gas. There might be an error in the contract and this transaction may fail
Keep getting this error when I am trying to deposit to my contract that is using Chainlink ...
2
votes
0
answers
49
views
Gas cost of simple ETH transfers on Arbitrum
Historically, Arbitrum enforced a minimum of 400k gas for transactions. Here's an example of a simple ETH transfer I performed in July 2023, which cost ~411k gas:
https://arbiscan.io/tx/...
3
votes
1
answer
58
views
How are the base fee and the blob base fee trustlessly relayed from Ethereum to Optimism?
I was reading Optimism's docs on Transaction Fees, and I noticed these statements:
The L1 Data Fee is most heavily influenced by the Ethereum base fee that is continuously and trustlessly relayed ...
1
vote
1
answer
201
views
Is there a way to make the user pay "aggressive" gas fees automatically instead of them choosing that in MetaMask?
I am having issues with MetaMask in my DApp because users are using wrong or invalid RPCs.
Is there a way of making users add a network automatically to MetaMask with the right RPC and override the ...
2
votes
1
answer
151
views
Do all EVM chains use the same minimum transaction gas of 21000?
Do all EVM chain use 21,000 gas as a minimum transaction gas for simple ETH payments?
Optimism seems to do so. How about the other EVM chains?
1
vote
0
answers
17
views
Ethereum RETURN opocde memory expansion cost
I am currently implementing a version of the ethereum EVM and am running into a problem when implementing memory expansion costs for the RETURN opcode. When returning data from addresses outside the ...
0
votes
1
answer
25
views
Why can't I buy ETH on Rice Wallet?
I don't have much experience with crypto and I quickly came across a problem. I have a USDT balance on my wallet on the Rice Wallet app. I need ETH, but I can't exchange the USDT for ETH. A message ...
1
vote
1
answer
33
views
Storage ops / gas spent
Is it possible to know the amount of storage operations (or gas spent) that are between, let's say 4 functions, or a full contract?
Is foundry capable of this?
Thanks!
0
votes
0
answers
12
views
Start Native address took my Ethereum instead of my Remix bot [duplicate]
After watching a youtube video on a certain ethereum bot I followed the instructions and somehow found that the money was sent to some start native address and wasn't being used by my bot. I was ...
1
vote
2
answers
102
views
No Gas Consumption for Computations not changing the State of the Blockchain
From my understanding, a Solidity function running on a compatible EVM that doesn't change the state of the blockchain will not cost any gas. And this indeed appears to be the case, as I have ...
0
votes
1
answer
22
views
Convert the following address sum function to optimized assembly via both memory and storage. Slots are dynamic
I'm looking to convert the entire function getCurrentSupply() to assembly code as the potential gas savings in this use case are significant. Note that everything should be within a single assembly{} ...
0
votes
2
answers
46
views
How to further improve Safemoon's reflection token transfer? (ERC20/BEP20)
We all know Safemoon's iconic reflection token code, giving every holder a percentage of every fee on buy / sell.
I've already simplified and improved the gas efficiency and the token logic quite a ...
0
votes
1
answer
17
views
Would small integers saving gas in a struct?
I have a mapping to structs which contain multiple timestamp
struct Entry {
uint256 createdAt;
uint256 solvedAt;
uint256 canceledAt;
...
}
mapping(address => Entry) _entries;
...
0
votes
0
answers
94
views
Zero gas fee for transactions [duplicate]
I saw some people on ethereum and bsc chain that execute transactions paying 0 gwei per gas. How is it possible and how to do the same thing?
0
votes
0
answers
29
views
Why does transaction value have impact on transaction fee in Ethereum?
I am sending a transaction to Sepolia test network from browsers. The code I have is something like:
provider.request({
method: 'eth_sendTransaction',
params: [
{
...
0
votes
0
answers
25
views
Evaluating Cost Saving Potential Layer1 to Layer2
I am trying to evaluate cost savings when using a Layer 2 Blockchain network compared to Ethereum/Layer1. Currently i do not necessarily make use of L1/2 inter-communication, so just deploying and ...
0
votes
1
answer
67
views
Is it possible to create a transaction as an admin and send it but with someone else paying for the gas fees?
I have a mintToken method in my smart contract that is onlyAdmin.
The problem I have is that I don't want to pay for the transactions for my users every time I execute this function (and it also can't ...
0
votes
0
answers
134
views
Web3 validator found 1 error[s]: must NOT have fewer than 1 items
I am using wagmi web3 modal in my project. Recently, I have been getting error in my code.
Code:
const gasLimit: any = await contract.methods[method]
.apply(null, Array.prototype....
0
votes
0
answers
12
views
what would happen to a transaction only has base fee without tip
When sending a transaction to Ethereum network, the total gas you pay is divided into two components: the base fee and the priority fee (tip). A transaction that only pays the base fee is technically ...
0
votes
0
answers
22
views
How to send entire account balance to another address on Base
The below code is what I used to transfer entire account balance to other address on the ERC20 network and it works fine on it, but not on Base. Maybe it's because Base has different transaction fee ...
0
votes
0
answers
96
views
Replacement fee too low, Base Sepolia
This is the code I have for sending a transaction on Base Sepolia. I am using this to split the balance in my account into two halves and sending each half to an address one by one.
export async ...
0
votes
0
answers
15
views
Counting gas for a contract function execution - growing storage mapping structs
I want to count (not estimate for that I would use web3 API) gas per contract function execution - suppose there is a contract with two mapping structs where one is nested in the other. Something like:...
1
vote
0
answers
15
views
Feasibility of Manipulating (Increasing) Ethereum's Basefee (Gas Price)
Has anyone explored how feasible it is to manipulate the block.basefee (i.e., the gas price) on Ethereum? After running some numbers, it seems more achievable than initially thought. Consider this: ...
0
votes
2
answers
33
views
Why out of gas if it doesn't consume that much in the end?
I tried modify gas limit to a number I checked it should be enough to run transfer on USDT (62,800) but failed with "out of gas" error. When I send another transaction without modifying ...
1
vote
1
answer
73
views
Is it possible to check the gas fees for a contract before executing the contract itself?
Is it possible to check the overall gas price of a transaction before executing the contract? I'm trying to implement some arbitrage trade through a smart contract that would find me price ...
0
votes
1
answer
152
views
What's the value of "gasLimit = 21000" of Ethereum in Polygon?
In Ethereum the gasLimit is 21000. The constant.
I haven't found anywhere the value of it for Polygon, though. How much is it? For a token as well as for MATIC itself.
I've found the number 57000 on ...
1
vote
1
answer
570
views
What is the maximum of transaction gas limit?
I have some bulk calculations in a contract, so I used a function that compare the gas left with a constant value and save the current state. At the next time it continues the calculations until it ...
0
votes
1
answer
37
views
maxFeePerGas, is this per gas unit? or per the gas the tx needs?
Let's say I have a tx that requires 10,000 gas units.
Let's say I want to pay upto 50gwei per gas unit.
When I send maxFeePerGas, do I set it to:
50 * 10^-9 ? // i.e. 50gwei, as in "this is the ...