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.

407 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
5
votes
0answers
1k views

Can gas price and amount of gas be automatically set by metamask, or are they required to be set via code in web3.js (EIP-1559)?

I am using web3.eth.Contract to deploy a smart contract to the ropsten testnet. To interact with metamask I am using window.ethereum. I deploy the contract via the code below that I found on https://...
5
votes
0answers
43 views

Deploy gas issue for require reason string

I found a strange case and didn't find out why. ... modifier onlyMaster() { require(msg.sender == master || msg.sender == developer, "caller is not the master"); _; } ... ...
5
votes
0answers
82 views

UNGAS and why was GAS made available to programming smart contracts?

Hardforks, such as Istanbul, have illustrated the best practice that smart contracts should not make any assumptions about gas. Gas costs have, can, and will change, for example: Is transfer() still ...
5
votes
2answers
1k views

Contract creation gas cost depends on code in library function?

I have a contract fooContract which is using a fooLib library, calling fooLib.foo(LibStruct storage param) The transaction cost to create fooContract seems to depend on the code in the fooLib.foo() ...
5
votes
1answer
2k views

Solidity: How could I decrease gas usage of complex structs?

Struct is very expensive as labelled here: It seems extremely expensive when storing struct type. https://www.cryptocompare.com/coins/guides/what-is-the-gas-in-ethereum/: sstore 100 Paid ...
4
votes
0answers
331 views

bitwise multiplication to reduce gas cost

This is the multiplication method from the SafeMath library. /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*...
4
votes
0answers
130 views

Does 'estimateGas' behave the same on Ganache and on mainnet?

I noticed that estimateGas behavior in Ganache has changed: In version 6.4.1, it throws an exception if exceeding the gas-limit. In version 6.5.1, it returns the estimation even if exceeding the gas-...
4
votes
0answers
178 views

Interfaces and gas savings

Does it save gas to link to the bytecode of an interface? I tested this is solidity remix and using the interface to link bytecode instead of the full contract, didn't seem to reduce any gas costs for ...
4
votes
0answers
124 views

Autorefill isn't working on Improved Coin code

I've been trying to write a token contract with the autorefill function, but perhaps the code for the token example on the ethereum website is somewhat outdated, because it isn't working. Did anybody ...
4
votes
0answers
334 views

Gas cost for bigInt library

I am working on a big integer library in the online compiler. Currently having gas/computational time issues with the modulus function. I first implemented it using repeated subtraction: function ...
4
votes
0answers
583 views

Insufficient funds in main account (etherbase)main account for gas

I'm using Ethereum/Mist 087. I have 2000 eth in the main account. Trying to send 1800 from the main account to another ether account and Coinbase account. Each time we get the message: ...
3
votes
0answers
114 views

Does anything change on getGasPrice( ) in Web3js after EIP-1559?

Using getGasPrice in web3js returns the last few blocks median gas price. After EIP-1559, the fees system is divided into Base + Tip. My question is, what is returned using getGasPrice after EIP1559? ...
3
votes
1answer
66 views

Do miners undergo a sunken cost of attempting to verify an invalid transaction signature?

In the case of an 'invalid' transaction whereby the state transition of the execution is deemed to conflict in some way and reverts, the transaction itself is actually valid; gas is consumed, tx ...
3
votes
0answers
796 views

The gas-cost of a static-call of a pure function

A pure function doesn't cost anything when called from an off-chain script (or from some other constant function). But it does cost when called from a transaction (i.e., from a non-constant function). ...
3
votes
2answers
96 views

Set and delete storage variable in same tx

I did some poking around and didn't see an answer... and I figure someone knows this off the top of their head. Question: what is the gas cost associated with setting and deleting a storage variable ...
3
votes
0answers
112 views

Tracking Non-Deployer Transaction Gas Use In Truffle Migrate

In Truffle, gas used by a Migration in deployer.deploy() is tracked by a Reporter using events emitted by the Migration. If I have code of the form: deployer.deploy(MyContract) .then(instance =>...
3
votes
0answers
280 views

Miner accepting 0 price transactions

I am hosting a private blockchain and I am testing out the Geth functionality. I have deployed a Solidity contract based on the Greeter example. The functionality is not important, but suffice to say ...
3
votes
1answer
1k views

Error Ganache: Run out of gas - Works in Remix/Not from dApp

I am working on an application that stores and retrieves personal data on/from the ethereum blockchain. Just working on this to improve my Solidity and SC expertise and get comfortable with the ...
3
votes
0answers
313 views

Difference between execution costs on remix an Ganache?

I created a contract on remix and then deployed it. when I call any function there is an execution cost in gas. I also deployed the same contract on Ganache for testing. I find the execution cost in ...
3
votes
0answers
203 views

Denial attacks by submitting transactions with strategically calculated gas prices

As can be understood from the title, there is a specific form of denial attack where specific transactions are blocked by submitting transactions with strategically calculated gas prices. Example 1: ...
3
votes
1answer
749 views

Loop with optimal gas usage

I currently have the following loop (some stuff left out) mapping (address => uint) pendingWithdrawals; function example () private{ address[] tempList = List; for(uint k = 0; k < ...
3
votes
0answers
246 views

Why are there pending TXs with high gas prices?

Rinkeby has pending transactions, some of which have gas prices of 100+ gwei and have been pending for over half an hour. Why is that? Are sending too little gas?
3
votes
0answers
199 views

What is the runtime performance of Ethereum Libraries compared to Contracts?

I'm looking for the cheapest way (in terms of gas price) to design upgradeable contracts. I don't expect many upgrades. Being inspired by Writing upgradable contracts in Solidity, I'm investigating ...
3
votes
0answers
339 views

contract code couldn't be stored, please check your gas amount

I am trying to deploy multiple dependent contracts with truffle on testrpc. For example,Migration script are as follow: deployer.deploy(a,10000).then(function(instance){ owner = web3.eth....
3
votes
0answers
567 views

The gas price on the Ropsten test net today rose from 0.211 ether per million gas to 1.8 ether per million gas, why?

Seems like Ethereum adjusts its gas price to meet demand. How does it do this?
3
votes
1answer
1k views

Private vs internal cheaper

I know that external is cheaper than public due to how arguments are parsed. Is making a function private or internal cheaper?
2
votes
0answers
23 views

Is there an incentive to delete variables / array values / other stored items?

I am working on an application where my storage will grow and grow. I could delete data as I go, but I dont see any incentive to do so. Is there something I'm overlooking? Specifically talking about ...
2
votes
0answers
42 views

What parameters should I use in my EIP1559 transaction for a fast confirmation time

Looking to take part in some minting gas wars and looking to prepare a transaction before hand. What values should I use for my Base Fee Per Gas, Max Fee Per Gas, and Max Priority Fee Per Gas to ...
2
votes
0answers
2k views

Gas Fees for 10k NFT

I want to mint a collection of 10,000 NFTs. However, gas costs are an unknown. I was wondering if someone could help me understand the following: If I programmatically mint NFTs on the mainnet for ...
2
votes
0answers
347 views

Hardhat: InvalidInputError: sender doesn't have enough funds to send tx

I am getting following error: InvalidInputError: sender doesn't have enough funds to send tx. The max upfront cost is: 1720878550726790368 and the sender's account only has: 47925025381294726 I am ...
2
votes
1answer
44 views

EthGasStation accuracy

I have posted a transaction with a very low gas fee (11 gwei) to the txn pool. Speed wasn't an issue and I can wait for the txn to post. This was 24 hours ago, and the txn is still pending. Currently, ...
2
votes
0answers
71 views

Is gas cost of external calls included in gas cost of the main call?

When I call external methods of other contracts from my contract, is the gas fee of these calls included in the gas fee displayed by MetaMask? My transaction reverts (execution reverted) for an ...
2
votes
0answers
54 views

Sending tokens out on coinpayments success payment using Web3py

I'm writing Django app and want to send out tokens using Web3 once Coinpayments sends me callback about successfull payment. The problem is that Coinpayments sends multiple callbacks at once and just ...
2
votes
0answers
162 views

Simple mixer in ethereum

I have found this mixer proposal https://hackmd.io/@HWeNw8hNRimMm2m2GH56Cw/rJj9hEJTN?type=view I'm is interested in this topic, but from my point of view with a current ethereum state it won't work. ...
2
votes
1answer
15 views

Formula for instrinsic gas value in Ethereum yellow paper

In the Ethereum yellow paper 6.2 there is a formula (54) defining g_0 refers to a sum which is indexed over i. But i doesn't occur on the right side except by making a distinction between i = 0 and ...
2
votes
2answers
497 views

How Does Exchanges Implement Gas Fees for ERC20 Tokens

Any crypto exchange like binance, bitfinex and so on let you deposit and withdraw various ERC20 tokens. Technically I don't understand how they implement gas fees when I withdraw? I deposited 100 ...
2
votes
0answers
102 views

What Web3JS method do I call to know what value to use for the gas price with sendSignedTransaction?

I am using Web3JS 1.0+ to send transactions to my smart contract. I've been using the following constant for the gas price in my code that I got a long time ago from a tutorial. What is the "...
2
votes
0answers
104 views

Why is putting data to storage more expensive during the deployment of contract than storing the same data by a method?

I am working with truffle and solidity (v0.4.23) and found out that when I pass in an argument of constructor some bigger amount of data (16kB) that are saved to storage of a smart contract, it is ...
2
votes
1answer
57 views

Why use different gas?

I have this contract with this functions, why each use different gas amount? pragma solidity 0.4.24; contract Foo { //transaction cost: 21471 gas //execution cost: 199 gas //total cost: 21670 ...
2
votes
0answers
90 views

Gas cost of adding an item to a class-level (storage) array

I would like to make sure that the gas cost of adding an item to a (storage) array is constant, i.e., not dependent on the length of the array. To my understanding, the relevant EVM operation is ...
2
votes
0answers
1k views

Getting Json file from remix

I have been deploying contracts on rinkeby but we are almost done to go to mainnet. I have been comparing deployments with truffle and remix and there is a huge difference in gas uses, so I would ...
2
votes
2answers
3k views

Constantly getting "Gas estimation failed" error when attempting to deploy ERC20 Token contract on Rinkeby testnet

I have included the code for the contract below. The error I get when attempting to deploy in remix via metamask is: Gas estimation errored with the following message (see below). The transaction ...
2
votes
0answers
203 views

Gas cost of a Message Call

I was trying to calculate the cost of a message call (CALL, DELEGATECALL, CALLCODE) following the yellow paper but I've not been able to fully understand it. It seems that Ccallgas is an isolated ...
2
votes
0answers
155 views

How much gas is consumed by a smart contract deployment?

I have a compiled EVM file which is 18,012 bytes large and when placed on the blockchain it creates a contract which is 17,859 bytes large. This size has been checked by running eth.getCode(...
2
votes
0answers
67 views

Out of gas while using transfer function

I simply want the transaction to occur in integral ethers. I wish to refund the balance amount. I am using the following function in my contract for that. I am getting out of gas while running this ...
2
votes
1answer
118 views

Exchange messages between two clients of Dapp without spending gas?

Let's say that I want to build a Dapp such that users can exchange messages between each other. I guess you can consider it a chat Dapp. Is there any way for the two users to find the "address" of ...
2
votes
0answers
100 views

Using smaller parent contract consumes less gas?

Here's my Test Code pragma solidity ^0.4.20; // StandardToken is from zepplin-solidity. import "./StandardToken.sol"; contract Callee { address public caller_; function setCaller() public ...
2
votes
0answers
88 views

How can I check the total gas used by a transaction?

I am trying to figure out the total gas used by a transaction. It appears gasUsed = cumulativeGasUsed but both values don't check out with the following check: gasPrice = 100000000000 Number(...
2
votes
0answers
87 views

Early 2018 gas price volatility

What have caused the recent default gas price To go up (default was in some point near 100 GWei) To come down (now it seems to be 20 GWei) Specifically, was this because of Actual demand for ...
2
votes
0answers
45 views

Posted blocks on ethgasstation/Low gas price watchlist

Does anyone understand the posted blocks on ethgasstation/Low gas price watchlist? I would guess that posted block < mined block is always true - but this is not what I see there.

1
2 3 4 5
9