Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

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
1
vote
1answer
32 views

Different gas usage of trivial reverting contract function

We are currently testing functions on Ropsten test network and have an issue regarding the gas usage. Our functions sometimes use 12 gas more and we can not fathom why that would be the case. To test ...
0
votes
1answer
30 views

Does using a very high gas limit somehow get your transactions executed slower?

I'm executing transactions on mainnet with a NodeJS script: async function send(web3, transaction, destAddr, gasPrice, privateKey) { const options = { data : transaction.encodeABI(), ...
1
vote
1answer
17 views

Gas COST for Contract Initialization

I am trying to understand the difference in gas cost between getTokenBalance for the two contracts below. In Example 1 ERC20 is initialized once during the deployment of SomeContract as a part of ...
0
votes
0answers
17 views

VM Exception on variable assignment

I'm encountering a problem related to the gas (I guess). Please note that I'm using the proxy pattern for upgradeable smart contracts: CODE EXAMPLE HERE - Explanation from Openzeppelin I'm trying to ...
0
votes
0answers
23 views

How to deploy contract instance in blockchain with abi and contract address?

I am following this (python ethereum interface tutorial) and contracts to compile and deploy in ganache cli. Till now i am able to compile and deploy contracts with web3.py,py-solc and ganache node. ...
0
votes
0answers
32 views

Do send raw transactions consume extra gas as opposed to a send transaction

I would assume the portion of verifying the signature consumes gas. I'm asking this because it seems infura does not handle signed transactions and I have a getBalance Call that is failing. I would ...
0
votes
1answer
11 views

Does packing bools alongside addresses reduce storage costs?

Say I have a struct like this: struct MyStruct { bool foo; uint256 bar; uint256 baz; address qux; } If I rewrite it like this: struct MyStruct { bool foo; address qux; ...
2
votes
2answers
46 views

Gas cost of a sha256 hash

I'm confused about the cost of the sha256 function, because my understanding of the cost from the yellow paper ( https://ethereum.github.io/yellowpaper/paper.pdf (Appendix E. Precompiled Contracts) ) ...
0
votes
1answer
33 views

Gas optimisation for my art experiment spacecans.com

so I was microdosing some research chems and the thought came to me that I need to do some artsy blockchain stuff for once. It's two tin cans floating in space that you can advertise your so-called ...
4
votes
2answers
134 views

Common Gas Wallet for ERC20 Wallets?

We have a wallet structure where users send tokens to individual user wallet addresses generated for them, we then sweep all the funds in the user's wallets to a centralized pool. The individual ...
0
votes
0answers
25 views

“Out of Gas” while transferring ethereum from account to contract

I am using ganache to create 10 ethereum accounts. I want to transfer ethereum from one account to a smart contract. I am doing this by writing two following smart contracts in solidity; pragma ...
2
votes
1answer
34 views

How to avoid an error caused by wrong determining of gas consumption

I have a function that is being called by multiple users (say 3). That value is set by owner earlier as a constant. Inside this function there's a check whether it's the last user (3) or not. If yes ...
1
vote
0answers
29 views

When I call tranfer_from function, remix saids gas limit exceed

I am owner of the token contract, And when I call transfer_from() function, remix saids gas limit exceed. my gas limit is 300000. this is same contract, and call transfer_from() successfully. "https:/...
0
votes
0answers
19 views

Is Gas consumed in boolean operations that do not change contract state?

Imagine I've created a voting contract, and I'm the owner of this contract. I'm going to deploy it and create a front end to interact with it. Within my contract i've everything secured to add ...
0
votes
1answer
36 views

Gas estimation errored using ERC20 in REMIX

I'm trying to test making some smart-contract that uses DAI ERC20 tokens on Kovan testnet (DAI contract on kovan is 0xc4375b7de8af5a38a93548eb8453a498222c4ff2). I developed this very simple contract ...
0
votes
2answers
24 views

Does a transaction that consumes the block gas limit take an entire block by itself?

Does a transaction that requires the entire block gas limit to be executed (currently ~8M) take the entire block by itself? And if that's true, will that transaction take longer to get confirmed than ...
0
votes
0answers
32 views

gas required exceeds allowance (42000000) or always failing transaction

Below is my solidity code. When i try to run function insertBusinessHash, the error "gas required exceeds allowance (42000000) or always failing transaction" pops up. Any suggestions? pragma solidity ...
0
votes
2answers
46 views

How to reduce the gas price for complicated smart contracts?

This is my smart contract's calculateReward function: function calculateReward(uint256 _amount, address _sender) internal view returns (uint256) { uint256 reward = 0; for (uint256 i= ...
1
vote
1answer
33 views

Is the gast cost of '<=' lower than the gas cost of '<'?

I've been debating on whether I should use < or <= in a for loop. So I decided to conduct a small test and verify that their gas costs are the same. Here is my contract: pragma solidity 0.4....
1
vote
1answer
30 views

Apparently some people send transactions with zero gas and positive gas limit, how do they do this? (and I am NOT planning to this but how)

Have a look at this transaction for example: https://etherscan.io/tx/0x11d96986d36240a5e5e7eab78879aa841631705370e707f15f1488a0b9d6704a 0 gas, 0 ether but plenty of tokens transferred. Obviously the ...
0
votes
1answer
17 views

When calling a contract from an other contract, what happends if the value of callgas argument is above availaible gas?

In such case, the value is replaced with available gas right ? Or Does an out of gas exception is thrown ?
0
votes
1answer
33 views

# issue: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending?

issue: Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? gas required exceeds allowance or always failing ...
0
votes
2answers
45 views

Why is storing via sstore more expensive than via events mechanism?

I just do not understand why emit Event(...) is cheaper than a = b. The only difference I noted between events and storage variables is that event logs is not accessible from Solidity. But both of ...
0
votes
0answers
11 views

Can web3js accurately estimate a transaction that includes an external call?

Can web3js accurately estimate a transaction that includes an external call? For example, will it be accurate in estimating: (bool _success, bytes memory _response) = _to.call.value(_value)(_data); ...
3
votes
0answers
41 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-...
0
votes
0answers
22 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 ...
-1
votes
1answer
21 views

GAS price validation for transactions in OLD blocks

How does Ethereum verify GAS price stated within transaction, to be high enough for transactions stored in past blocks? Does each block include an average GAS-bid experienced by miner at the moment ...
2
votes
1answer
28 views

How to know in advance the gas used by a transaction?

I want to send an ERC20 token (Ropsten network). So I execute a function 'transfer' on a contract. When The transaction is sent, I can get the gas used in the receipt. Few months ago this amount was ...
0
votes
1answer
26 views

When sending tokens from geth, how do I specify a different address to send gas from

When I am sending tokens, is there any way to specify a separate ETH address to send the gas transaction from in geth's web3? Boiler Plate var usdtAbi = [{"constant":true,"inputs":[],"name":"...
0
votes
0answers
29 views

Is gas limit constant for regular transfers? [duplicate]

Afaik the minimum amount of gas, required for a regular ETH transfer is 21000. Is 21000 specific to the protocol itself, or does it depend on the particular network? Does it depend on custom data, ...
0
votes
3answers
65 views

Error transferring balance. Runs out of gas

This is probably a simple problem to fix, but it is very frustrating. I am developing in Solidity using Remix 0.5.10. I have a loan contract that collects funds from borrowers. I now want to ...
0
votes
0answers
20 views

I can see my ethereum but its not going to my wallet

My ethereum has been confirmed delivered but not in my wallet,fairly new but I have made successful transactions before,I can see my ethereum in etherscan.io 0x2ecc74c6e9c42eea14863fbc1e1d9656b339a6ec ...
0
votes
1answer
61 views

What should gas prices be for sending out tokens?

I constantly get failed transactions when sending out tokens like USDT using metamask. I have my gwei set at 10 and the gas limit at 21000. I even tried gas limit set to 51000 and it still fails. ...
1
vote
1answer
23 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?
0
votes
0answers
13 views

Can't send when geth started with no peers

I am trying to follow these instructions to send eth without syncing on my pc. ./geth-1.9.0 --maxpeers 0 console Then TX={ from: FROM, to: TO, value: VALUE, nonce: NONCE, gas: GAS, gasPrice: ...
2
votes
3answers
230 views

Pattern to deploy a smart contract from another one without spending twice the gas

It seems that if we want to deploy a smart contract (let's call it Target) from another one (let's call it Deployer) in Solidity via new, we spend a gas amount linear in the size of the deployed ...
0
votes
1answer
29 views

CRUD storage pattern Infinite gas error when trying to implement in Remix

I'm trying to implement @robhitchens CRUD storage pattern in solidity, and I'm getting infinate gas costs when I import the library. Not sure where to go from here. one of them: Gas requirement of ...
0
votes
0answers
50 views

Why would I use interfaces in this case?

I see suggestions here and there to import an interface instead of the whole contract to reduce contract's bytecode and deployment costs. Consider the following structures: contract Storage { ...
0
votes
1answer
23 views

Different between gas and gasLimit keys when executing transactions

Below is the code that I'm running. When I entered "gas" and "gasLimit" as the keys, both worked. Why is that? What does "gas" represent? And what is the optimum amount of gasLimit should I use (...
1
vote
0answers
27 views

Gas usage difference between Remix and Ganache/public networks

I'm trying to integrate a contract into a front end with MetaMask and getting different gas amounts depending on the network and compile options I use. Remix ("Enable Optimization" checked): 90,410 ...
0
votes
1answer
36 views

Multiple Inheritance at particular contract address

I'm attempting to have 4 different contracts sharing the same data fields. The reasoning behind having 4 instead of 1, is that the different functionality can be broken down so that it is cleaner, ...
0
votes
0answers
89 views

Why is my metamask transaction failing even if I set a high gas limit?

Below is a failed transaction. i set the gas limit to double of what it normally is, but it still failed. How can one figure out the correct gas limit, if the auto settings don't even work. Why does ...
0
votes
1answer
18 views

An automatically gas payment [duplicate]

I’m a noob in smart contract development so I have a question. Is it possible to make that the smart contract itself can pay gas needed for executing? Or could I chose an address which should pay the ...
0
votes
1answer
22 views

Sending an array of addresses and amount to be paid to a contract

I need to pay 50+ addresses each with different amounts of ether. Right now im doing it by looping through an array on my front end and calling the contract function each time with the address and its ...
1
vote
1answer
16 views

Gas cost for contract transaction called form external

If I call my contract and ask it to send x amount of ether to another account y, I know i have to pay a transaction cost. Will the contract also have to pay any amount while sending the ether to the ...
1
vote
1answer
21 views

Where can one get token fee calculations instead of it keep eating up my ETH for gas for guessing the gas limit?

This is kind of ridiculous, every time I try to send out tokens to another address from metamask, it fails. I doubled my GAS limit from 20K to 70K and it still fails. Where can one even find the ...
1
vote
2answers
70 views

Gas usage for same contract is constantly growing

Here is the smart contract. The gas usage for this contract is constantly growing. All state variables are initialized at deployment and never changed. Signers array is about 2-3 in size no more. And ...
2
votes
2answers
61 views

Is there a maximum/optimum amount of ERC-721 that can be issued per contract?

Take a role playing game as example in which players are allowed to create any number of characters (each one defined by an ERC-721 token). What would be the consequences of having more than 10 ...
3
votes
1answer
166 views

How to pay gas fee for new addresses of ERC20 tokens that initially have 0 Eth balance? [duplicate]

I have a confusion, When we create new address/account for an ERC20 token then it have 0 Eth balance. When we send some tokens to this address and then withdraw token again from this address require a ...
2
votes
1answer
90 views

After EIP 198 introduction, how much gas is required for RSA signature verification in solidity?

Thanks to the introduction of EIP 198, RSA signature verification is now feasible in Ethereum. How much gas is required for such a verification?