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
0 votes
0 answers
14 views

Is it gas efficient to call another contract's external function in a loop?

I am trying to create a staking protocols where rewards and staking are separate. But there are multiple tokens that get rewarded and I need to update each of them in a loop. Now, my question is how ...
user avatar
  • 363
0 votes
0 answers
8 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 ...
user avatar
  • 66
1 vote
0 answers
35 views

Make all transactions gas-less for an EOA

As a service provider, I would like to pay for any transaction a user makes from my app. I've read about meta transactions and contracts that implement EIP-3009, which allow the delegation of gas ...
user avatar
  • 11
0 votes
0 answers
13 views

Cheapest way to call contract

I just looked into the DSProxy contract, and now I'm trying to figure out how to make an external contract call (call contract2 from contract1) as cheap as possible. The usual way ofc is: address ...
user avatar
0 votes
1 answer
26 views

What should I do to mint 2000 items?

When I try to mint 2000 items in remix I get this error: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? ...
user avatar
  • 1
9 votes
1 answer
5k views

Why does ++i cost less gas than i++?

Why in solidity, i++ & ++i works the same but one costs a little bit more gas? Take a look at this contract: contract foobar { uint[] public arr = [1,2,3,4,5]; function find() public ...
user avatar
  • 175
0 votes
0 answers
19 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 ...
user avatar
  • 1
0 votes
0 answers
18 views

Ethereum 0 gas cost Blockchain

Hi guys, I am looking for an Ethereum Blockchain like Quorum to use like a database for JSONs. I am actually using geth PoA with one node un my home and two nodes in AWS EC2. I have been facing some ...
user avatar
0 votes
0 answers
13 views

Who pays the fee(GAS)of internal txns?

Am I correct in my understanding as follows? Internal txns must have a parent txn. A executer of the transaction need pay for the transaction and its child txns(=internal txns).
user avatar
  • 1
1 vote
1 answer
26 views

Why is the gas price so low even though daily transactions have not decreased

The Ethereum gas price is currently about 6 gwei, the lowest I've seen it in a very long time. It was over 100 gwei most of the time for over a year I think. However daily transactions on the network ...
user avatar
1 vote
1 answer
603 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 ...
user avatar
0 votes
0 answers
48 views

How can we calculate next base fee?

I'm trying to understand gas in ethereum with EIP 1559. During my search I found this article https://www.blocknative.com/blog/eip-1559-fees (I have a light node deployed so I have access to block ...
user avatar
  • 1
0 votes
1 answer
60 views

Transaction gas cost in Foundry `forge` unit tests

forge test includes support for reporting gas usage by method externally with --gas-report. However, I would like to measure gas usage within a given unit test, which from reading the documentation ...
user avatar
  • 205
0 votes
0 answers
15 views

Is there a gas effective algorithm to generating a permutation from a seed

I have an array [1,2,3,4,5,6] and I want to permute it randomly. Let's say I have a number bytes32 seed, that is obtained through a verifiably random number mechanism or for my purposes it just needs ...
user avatar
  • 209
0 votes
0 answers
14 views

Which blockchain uses oracle to determine gas price?

I just only want to know that is there any blockchain which determines gas price by using oracle?
user avatar
0 votes
0 answers
15 views

geth error exceeds block gas limit"

im running a local geth node to increase transactions speeds for nfts minting however during a nft mint that had a contract set Gas limit to 250k there was gas wars and eth gwei went up to 500 gwei ...
user avatar
0 votes
0 answers
47 views

Why gas used on fantom is different from estimate gas and changed if gas limit changed

here is code and gasEstimate is 25000, tx_receipt.gasused is 50000 when gaslimit is 300000, 170000 when gaslimit is 1500000 tx = contract[network['name']].functions.test2().buildTransaction({ ...
user avatar
  • 11
0 votes
1 answer
26 views

How much gas does the overflow check cost?

From solidity 0.8.x the compiler automatically checks for overflows and underflows. This costs additional gas. My question is how much gas it costs and how much you can save by using the unchecked {}. ...
user avatar
  • 246
-1 votes
0 answers
19 views

i created a contract then the money not display [duplicate]

I created a metamask wallet, then treated a contract and transferred money from the wallet address to the contract address. How I can get the cashback, please. Then the contract was transferred money ...
user avatar
0 votes
2 answers
25 views

If two public getter function are returning same kind of output and both are uninitialised yet they why they charge different gas

I am having a solidity code which is having two uint256 , while calling public getter function both charges different amount of gas why so ? p.s both are uninitialised yet
user avatar
  • 23
0 votes
1 answer
9 views

How can a miner pack more transaction in one block?

Other than lowering the gas price and increase the gas limit, is there any simple configuration change to ensure the miner increase as many transactions as possible until the block is almost full?
user avatar
0 votes
1 answer
40 views

How to find out the cost of deploying a contract in HardHat

I deploy the contract to the Rinkeby. Can I calculate the contract deployment cost from HardHat?
user avatar
0 votes
0 answers
12 views

Linked library vs. standalone contract

What is the benefit of a linked library over a standalone contract? Let's say I want to reuse code between multiple contracts. The code itself has no state. Example library: library SafeMath { ...
user avatar
0 votes
1 answer
18 views

How is transaction pushed to the block?

Let's imagine we have a 30kk gas limit block in ETH. 25kk of gas are already taken, and it's time for my transaction, which consumes 10kk gas. Will it be pushed to this block, with kind of "Out ...
user avatar
  • 23
2 votes
0 answers
24 views

Measure gas left in block in solidity

There is a gasleft() to check how much gas left for my smart contract execution in solidity. But how is it possible to check how much gas left in block? I am having quite a big solidity function, and ...
user avatar
  • 23
0 votes
0 answers
71 views

Invalid BigNumber value error. Arguments="value", value=undefined

so I'm getting this error on my deploy script. I have seen the other questions and have tried their solutions but they are not working for me. So this is my deploy script const { netowrk, network, ...
user avatar
1 vote
1 answer
125 views

Why does a constant function that reads a struct memory cost the same as accessing the struct member directly?

Context I have recently introduced a new constant getter in my contract, and I have thought that that it would lead to an increase in gas costs. Below you can find those snippets of code that ...
user avatar
1 vote
2 answers
35 views

How to calculate GWEI back to ETH/USD?

According to Owlracle, right now the recommended Ethereum fees are: According to them, an Ethereum fee of 90.73 GWei is equal to roughly 7.7 USD. Can anyone explain how they get to that number? I ask,...
user avatar
1 vote
1 answer
78 views

Max Priority Fee and Max Gas Fee difference and definition

What is the definition of max priority fee and max gas fee in EIP-1559 enabled Ethereum?
user avatar
1 vote
0 answers
20 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 ...
user avatar
0 votes
0 answers
7 views

How to calculate amount of gas? [duplicate]

How I can calculate gas used for transfer token for example Shiba Inu. I need to calculate it before transaction.
user avatar
0 votes
1 answer
22 views

Who pays for the gas used when reading from storage or calling pure / view functions?

I a little confused about this, i've read that pure / view functions don't cost gas / require a transaction when called, other people say that it does cost, but you're not the one pating for it. So ...
user avatar
0 votes
0 answers
8 views

What is the composition of a transaction ? (size, purpose...) [duplicate]

I want to know more about transaction : What are the components of a transaction? (theirs size and purpose) What is the size (bytes) of an Ethereum transaction? (min and max) I know there is a "...
user avatar
0 votes
1 answer
21 views

Max addresses that can be cleared from an array before breaking gas

I've been trying to properly test this for about two days with issues here and there. I got to 240, and it errored out bc of Gas when i attempted to clear.. Good thats what i wanted to see..but I have ...
user avatar
0 votes
1 answer
35 views

Different gas amount for erc20 Transfer functions

I have used Transfer function for an erc20 in different contracts with the same codes. The point is here, in different times there was different gas while the function was the same. The input of the ...
user avatar
0 votes
1 answer
15 views

Is it advisable to "wrapped" my tokens in order to use inside my Dapp to lessen gas cost?

I created a token ABC and have another smart contract for my dapp. My Dapp requires a lot of ABC token burning for every tx, my question is, is it advisable to convert my ABC token from on-chain to my ...
user avatar
0 votes
1 answer
41 views

Gas optimization of calldata input variables

I have some external functions what receives address lists as calldata to save gas. I know that creating a copy from global variables inside functions can be useful to read less from blockchain ...
user avatar
  • 196
0 votes
1 answer
26 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 ...
user avatar
0 votes
0 answers
20 views

How to estimate the transaction size of a Blockchain (Ethereum) from the given data?

The following is the data given for different blocks; The 'size' column here refers to the block size. The aim is to estimate the transaction size for each block and compare that with the block size. ...
user avatar
1 vote
0 answers
59 views

Cannot estimate gas when trying to use smart contract

Whenever I try to approve or do anything with my smart contract I keep getting this error. This is my smart contract. pragma solidity 0.6.12; import "@openzeppelin/contracts/token/ERC20/IERC20....
user avatar
0 votes
2 answers
105 views

sendSignedTransaction web3js

I see that with sendTransaction you can specify maxFeePerGas. see here However, if you use signTransaction and then sendSignedTransaction you can only send gas. and here. How to send a signed ...
user avatar
  • 53
0 votes
0 answers
34 views

Gas estimation reverts

I am quite new to blockchain programming and am trying to estimate the gas cost of calling a function from a smart contract. I am using Web3 js and the Kovan network through an Infura node. What am I ...
user avatar
0 votes
1 answer
60 views

How long before transaction is removed from the Mempool

So I have a transaction T1 that has been stuck in pending because I put the gas really low. I forgot about this and then tried to process two transactions after with $126 gas fee and $111 gas fee. I ...
user avatar
0 votes
1 answer
80 views

NFT mint call reverted while testing

So I have gotten to the point in my NFT project where I am testing the minting from the website that I setup to mint from. I deployed to Rinkeby, and when I go to mint NFTs on my website, I get the ...
user avatar
5 votes
1 answer
121 views

Why chi token save 50% and not more?

I have a smart contract on bsc network and I want to reduce my gas used. I use chi gas token based on this code: modifier discountCHI { uint256 gasStart = gasleft(); _; uint256 gasSpent = ...
user avatar
0 votes
0 answers
96 views

Hardhat Polygon gas price error

I'm developing a NFT minting API with Hardhat, Ethers and alchemyapi. In Rinkeby network it's working!! But when I deployed my contract to Polygon it's returning some erros when Mint function is ...
user avatar
0 votes
0 answers
37 views

How to save gas in solidity structs with packaging

I am trying to figure out how to package my structures to optimize them. This first structure takes full 3x256 bits. struct FirstStruct { uint128 numberOne; // takes one 256bit slot uint256 ...
user avatar
  • 775
0 votes
0 answers
9 views

Permissioned networks vs Access Control in public networks

I've been working with both public and permissioned EVM networks the last years. Everybody is aware about the benefits of public networks in terms of security, community, solutions ecosystem, ...
user avatar
  • 705
0 votes
1 answer
36 views

Gas optimisation: maximum of two numbers

Any ideas if I can optimize the gas of the following function from Math library of OZ: function max(uint256 a, uint256 b) public pure returns (uint256) { return a >= b ? a : b; } *I checked ...
user avatar
0 votes
0 answers
13 views

why creating new wallet doesn't cost any gas, though its using network storage to store account details?

Creating new wallet doesn't cost us any gas, but the account state and account information is stored in Ethereum blockchain, which is using networks storage and as we can see the details of account in ...
user avatar

1
2 3 4 5
31