Skip to main content
Share Your Experience: Take the 2024 Developer Survey

Questions tagged [gas-refund]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
5 votes
4 answers
108 views

Does it make sense to remove unused entries from contract mapping in 2024

im wondering if it still makes sense to remove entries from mappings in ethereum contract. It seems like initially there was a relatively big benefit of cleaning up the storage but from what i read ...
mat13mn's user avatar
  • 51
0 votes
1 answer
15 views

When deleting a struct, do I get back the gas of setting the attributes of the struct to 0, or only for the struct itself?

I have a mapping(bytes32=> exampleStruct) public myMapping where: struct exampleStruct { address owner, uint256 number, uint256 anotherNumber } To optimize gas sometimes I delete ...
Hiperfly's user avatar
0 votes
1 answer
31 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,703
1 vote
2 answers
46 views

Can a simple ether refund without storage checks be hackable(reentrancy attack, ...)?

As the title says, I am wondering if the following ether refund(using .call) can be hackable. I am not entirely sure no reentrancy attack can be performed in it, but I think so since I am not updating ...
Demain's user avatar
  • 11
0 votes
1 answer
14 views

Any alternatives to reducing msg.value without resorting to refunds?

In my contract, users are required to deposit a specific amount of Wei. I want to prevent users from overpaying and need to decrease the value of msg.value. Currently, I'm refunding the difference, ...
Damir Olejar's user avatar
0 votes
1 answer
240 views

EVM Gas refund and total gas calculation

My understanding is that the total gas refund can never exceed 20% of the transaction total gas cost, which I guess means that the EVM will first add-up all the transaction gas cost then deduct the ...
Alberto Molina's user avatar
1 vote
1 answer
674 views

Is it possible to reverse the gas used in case of using revert?

I try to refund gas to the minimum even after using revert with the following example. uint A = IERC20(base).balanceOf(address(this)); IERC20(token).transfer(owner,1000000); then I run swaps ...
jhonatanalfred's user avatar
0 votes
2 answers
265 views

Gas Less ERC-20 Token Minting

How can I create ERC-20 token on Ethereum blockchain without paying gas fee using Remix.ethereum.org Please provide code to help I saw Zeroswap DEX allow us to trade without paying gas fee.
Divyansh Singh's user avatar
0 votes
1 answer
236 views

Is the all of Gas Fee refunded if the transaction fails?

function burn(uint256 _value) public returns (bool success) { balances[msg.sender] = balances[msg.sender].sub(_value); totalSupply = totalSupply.sub(_value); Burn(msg.sender, _value); ...
imelon2's user avatar
  • 548
2 votes
1 answer
95 views

Why does releasing a storage variable cost more gas than it saves?

I am experimenting on saving gas by releasing some storage on my smart contract. In the smart contract there is a mapping, which i fill with data by calling the function setStorage. The other function ...
Atrox's user avatar
  • 21
2 votes
1 answer
615 views

What is the gas refund for clearing out storage via SSTORE?

There is a lot of conflicting information due to the change in the gas refund mechanism from EIP-3298. According to evm.codes the user will still be charged net 200 gas for clearing out a storage slot....
alphak3y's user avatar
1 vote
0 answers
87 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 ...
pokrovskyy's user avatar
0 votes
1 answer
394 views

Can you create and destroy a contract in a single transaction?

Is it possible to create and destroy a contract in a single transaction? Specifically could I: deploy to a known address using CREATE2 call a function on that contract destroy the contract and ...
willemolding's user avatar
0 votes
1 answer
70 views

Does it cost gas to cancel a transaction? Can I replace / speed up the transaction to just 1 gwei then cancel to reduce fees?

My transaction is stuck, but can I speed it up by replacing the fee with 1 gwei then cancel it to reduce the fees to cancel? I tried to cancel and speed up but its still stuck. I check etherscan and ...
Patoshi パトシ's user avatar
0 votes
1 answer
162 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 ...
karma badger's user avatar
0 votes
1 answer
26 views

What happens when creating contract but out of gas? [duplicate]

I am new to ethereum. I have learned that all states will be rolled back if out of gas. Assuming that there is a transaction with value field, but it runs out of gas. Will the value be back? (i know ...
KHJUAF403456ZS3K564WAEF's user avatar
1 vote
0 answers
151 views

What would be the safest way to prevent paying unnecessary high gas fees for transferring USDT?

Bitfinex paid a seismic $23.7 million dollars in a gas fee for a comparatively nominal $100K transaction, link. At 11:10 UTC on the 27th September a deposit transaction was made using a hardware ...
alper's user avatar
  • 8,395
0 votes
0 answers
18 views

Something Weird Happening w/ Blockchain, Gas fee is hold and historical ETH balance is changed [duplicate]

I am trying to send ETH from Ledger to CoinMetro account. I tried 4 times, with slow, medium and fast options. Each time it failed due to "out of gas" error. The 4th one failed immediately. ...
kuzey arman's user avatar
0 votes
0 answers
46 views

ETH Transaction Fails but My Funds are Not Delivered Back

I am trying to send ETH from Ledger to CoinMetro account. I tried three times so far, with slow, medium and fast options. Each time it failed due to "out of gas" error. I did some research ...
kuzey arman's user avatar
0 votes
1 answer
39 views

Is the gas usage O(1) for this code?

Is the gas usage constant for this function regardless of mapping/array size (assuming non-zero array entries)? items is an array, and presence is a mapping function clear() public { for (uint i = ...
David Callanan's user avatar
0 votes
1 answer
1k views

Do NFT bids, and refunds from being outbid, have the same transaction/gas fees?

If I bid on crypto art to the tun of $50 in transaction/gas fees, can I expect the same amount of fees to incur if I am outbid on that item, and the NFT platform refunds me my bid? $50 fee there, and $...
user610620's user avatar
  • 1,528
0 votes
2 answers
905 views

How are gas refunds "payed"? [duplicate]

I have a doubt about the gas refund concept. Imagine that I created a smart contract 1 month ago and now I want to call the SELFDESTRUCT because I want to send the current balance to an address and ...
Josep Bové's user avatar
0 votes
0 answers
67 views

Make transactions free of charge for the user

I involved in a project that aims to create a token for public use (non blockchain familiar users). User will have an ERC20 token, but I don't want they to have ETH to pay the gas. One obvious ...
Alexander Herranz's user avatar
0 votes
1 answer
348 views

refund function in smart contract [closed]

I am looking to add a Refund function in my smart contract. Like If User A deposited 1 ETH in the contract, and uses refund function, he gets 1 ETH - Gas Fee back. I can do the transfer(address....
Avi Thour's user avatar
  • 115
1 vote
1 answer
66 views

Do gas refunds apply in a fallback function? What is the limit for non matching function identifiers?

I know that a fallback function called with a .transfer only has gas limit of 2300. What happens if the fallback function deletes some storage variables in the fallback function? Would the fallback ...
Terence Chow's user avatar
4 votes
1 answer
531 views

Understanding gas tokens and create2

I am going through a sample gas token code on Ethereum. The token mints some dummy smart contracts using CREATE2 and then calculates the address. Later on it destroys them to get the gas refund. ...
smartContract's user avatar
0 votes
1 answer
479 views

Does self-destruct() delete contracts data from the storage as well?

Destroying two contracts: (1) contract A with 1 integer variable stored in it and (2) contract B with 100 integer variables stored in it, would result in the same amount of refund: 24000 gas. So does ...
user3700436's user avatar
3 votes
2 answers
1k views

Gas refunds via “Self-destruct” prior to a revert()

In a transaction that eventually calls revert(), if prior to the revert we have SELFDESTRUCT some contracts and thus received a gas refund, does the gas refund also get reverted?
Ben Schoeler's user avatar
0 votes
1 answer
3k views

is it possible to get gas refunded if a smart contract call fails to complete?

I am using trust wallet, and whilst using a number of exchanges (for example - uniswap, balancer liquidity pool) I have paid gas prices without the exchange actually taking place. Is it possible to ...
ÈSJ7777's user avatar
1 vote
1 answer
80 views

If gas is refunded, is it required to call? [duplicate]

Suppose a smart contract external function uses very much gas, but refunds (with .transfer()) the used gas to the caller. Question: Can it be called with a small amount of gas despite it uses much? ...
porton's user avatar
  • 1,804
0 votes
1 answer
1k views

How to refund gas to the smart contract caller? (What is the number?)

I have this function: function setAccount(BaseUBI _ubi, address _user, uint256 _startTime, uint _esiaID, bool _setToZero) external { uint256 _refund = (gasleft() + 0/*FIXME*/) * tx....
porton's user avatar
  • 1,804
0 votes
1 answer
731 views

Refund mechanism - How is it possible to have transactions with M$ fee?

As stated here, my current understanding is that an unused gas is refund when the transaction succeeds (otherwise it is fully consumed) Lately I found an article about some fee mistakes that led to ...
petherlipo's user avatar
1 vote
1 answer
2k views

How can I measure the gas used in a block of code?

This answer explains well how to measure the gas used in a block of code. I had actually been using this method before I found that answer: pragma solidity 0.4.26; import './IERC20Token.sol'; ...
goodvibration's user avatar
0 votes
0 answers
75 views

Which are the operations providing gas refund available immediatly for the current running transaction?

Most of gas refund operation aren’t available immediately, but instead increase the refund counter (which if I understand correctly is refunded not after the end of contract creation or call by ...
user2284570's user avatar
  • 1,018
1 vote
1 answer
88 views

Does the 10,000 refund apply to booleans too?

I understand from this thread that you're refunded up to 10,000 gas when setting a value to 0. Does this also apply to boolean values? That is, going from true to false?
Paul Razvan Berg's user avatar
5 votes
2 answers
3k views

Is there a drawback of setting a too high gas limit for a transaction?

Say, I want to send a transaction that consumes around ~40,000 gas. Could I just set the gas limit of the transaction to 1 million or is there some disadvantage and I should set a more realistic gas ...
hefeleal's user avatar
  • 147
0 votes
1 answer
312 views

Which `EVM` bytecode is actually used to "deposit" the transferred Ether?

A quick question. Which EVM opcode is actually used to "deposit" the transferred Ether into the contract? From the EVM opcode list, there are only two opcodes related to the fund transfer: balance and ...
lllllllllllll's user avatar
2 votes
0 answers
47 views

Is the refund gas paid up-front?

Excerpt from chapter 9 of the yellow paper, "Execution Model", describing the behaviour of the EMV when clearing storage: This refund is effectively paid up-front since the initial usage of a ...
Paul Razvan Berg's user avatar
0 votes
1 answer
306 views

Gas usage higher when using the delete keyword

I'm currently working on a marketplace demo for the consensys bootcamp, you can find my entire code here. Stores inside the marketplace (which are structs) are stored inside a mapping and the keys ...
Daniel Gretzke's user avatar
4 votes
2 answers
377 views

Understanding the formal description of a transaction and its associated refunds

Excerpt from page 8 of the yellow paper: I fully understand that contracts can self-destruct and, when that happens, according to this thread, all the balance is refunded to the address specified as ...
Paul Razvan Berg's user avatar
2 votes
1 answer
867 views

How to use ETH GAS refund in contracts?

How can we use refunded GAS from a transaction in subsequent ETH transfers? In general, how is refunded GAS used? How can we check the status of the amount of refunded GAS?
Ajay's user avatar
  • 61
1 vote
1 answer
419 views

How to use / see refunded gas in ETH blockchain?

I buy a GAStoken contract which requires say 21000 GAS at 1 Gwei and later when we delete/destroy the contract when the Gwei is around 50. I understand that we will get around 50% refund of GAS at the ...
Ajay's user avatar
  • 61
3 votes
4 answers
702 views

Is our smart contract required gas,every time it executes.

form my understandings, after the first execution of a smart contract, the network will return the remaining gas to the contract sender. if so, how will the contract obtain gas for future execution??...
Akshay Dev's user avatar
1 vote
1 answer
274 views

is there any way to have a permanent refund contract for ERC20 tokens?

Im a newbie when it comes to Ethereum but from what I gather, there is a type of crowdsale where if the goal is not met, the investors can send back their tokens and get a refund. However, this is ...
Bradley M's user avatar
2 votes
0 answers
393 views

Paying for gas on behalf of users?

I'm exploring ways to enable contracts/dApp owners to pay for gas on behalf of users. I know contact abstraction should enable this eventually, and the first step has been done with EIP208 which ...
Mihailo Bjelic's user avatar
0 votes
1 answer
96 views

storage gas refund, is gas only refunded when storage is completely deleted? What if a key / value in a mapping is deleted?

I have a which tracks ids for some structs for different users. mapping (address => uint[]) usersStuff This mapping for each user can grow or shrink. If it happens to shrink to 0 for a single ...
Terence Chow's user avatar
2 votes
2 answers
276 views

Refunding gas fomula in Ethereum yellow paper

After execution of the transaction by miner, the transactor is refunded a remaining gas. it is explained in section 6 of Ethereum's yellow paper. When calculating the amount to be refunded gas, the ...
Eps Yoo's user avatar
  • 41
1 vote
2 answers
372 views

How can I claim a refund from a failed ICO (Watertech)

My questions is about claiming a refund from a failed ICO. The ICO in question is WaterTech and the token is WATR
John POLLARD's user avatar
3 votes
2 answers
695 views

Resetting storage slot increases gas usage although should decrease it

I have a simple contract that deletes the last element of the array: pragma solidity^0.4.11; contract GasRefundTest { uint[] myArray = [1, 2]; function deleteLastElem() public returns(...
medvedev1088's user avatar
1 vote
2 answers
5k views

ICO refund: "Insufficient funds...account you tried to send transaction from does not have enough funds" [duplicate]

EDIT: Please note that this concern revolves around the "Contracts" portion of MyEtherWallet. I'm not trying to send funds from my account, I'm trying to recover funds for a failed ICO using the ...
ICONewb's user avatar
  • 11