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
0answers
12 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 ...
2
votes
1answer
34 views

Is transfer() still safe after the Istanbul update?

In other words, is using transfer() safe? function transfer(address contractB) public { contractB.transfer(1000); //balances[msg.sender] -= 1000; } How about using call.gas? function ...
0
votes
1answer
16 views

Function Efficiency

Say I have a function that handles 4 cases via if statements. I could break that into 4 separate functions. The case for breaking it up is that each function call would use less gas. The case against ...
0
votes
0answers
13 views

How Gas Cost is defined in EVM gas table?

i was checking into EVM gas table (https://docs.google.com/spreadsheets/d/1n6mRqkBz3iWcOlRem_mO09GtSKEKrAsfO7Frgx18pNU/edit#gid=0) (even though it is old sheet) Have few question: On what basis for ...
3
votes
1answer
16 views

Can I add an int32 to an int256?

I'm trying to reduce the storage size of my contracts by reducing the bytes required to store my int data types (among other things). Can I get the best practice for adding int256 and other smaller ...
0
votes
0answers
32 views

Gas estimation errored with the following message (see below). The transaction execution will likely fail

When I try to excute the deposit function it shows Gas estimation errored with the following message (see below). The transaction execution will likely fail. Do you want to force sending? execution ...
1
vote
1answer
19 views

Can I estimate the total gas limit of several dependent transactions?

Assume two dependent transactions A and B. Transaction B depends on transaction A and will fail if transaction A has failed. I would like to estimate the gas limit required for the success of both ...
0
votes
1answer
22 views

Do I need ETH in my exchange account to send out ERC-20 tokens to an external wallet?

I'm new into ERC-20 tokens. Let's say I buy an ERC-20 token in an exchange with USD. When I want to transfer that token to my own external wallet (say Nano S), do I need some ETH in the exchange (...
3
votes
1answer
16 views

let user create and sign erc20 transactions but i pay the fees?

I try to build an app where users can send and receive ERC20 tokens. I want the transactions for my user to be feeless. So is it possible for a user to create and sign the transactions, my system ...
2
votes
2answers
34 views

loop though all the members of a map

I need to loop though all of the members of a map and change their property (which is a struct). the way i'm doing this is when adding a member to the map object also save it's address inside an ...
0
votes
2answers
29 views

Internal contract-to-contract call

I am confused with the following sentence in the Solidity documentation: During the execution of the fallback function, the contract can only rely on the “gas stipend” it is passed (2300 gas) being ...
0
votes
1answer
27 views

generation random number

uint private seed; // starts from 0 (including) to _length number (excluding) function random(uint _length) private returns(uint) { seed = seed.add(block.timestamp.add(uint(msg.sender))); ...
1
vote
2answers
98 views

Array Costs in Solidity

Why is storing in an array the first time in solidity costs higher than the other times? The other times it has a constant cost which is less than the first time.
0
votes
1answer
16 views

how to handle gas run out in a payable function

function payMe() payable{ // doing some stuff with `msg.value` users[msg.sender].balance += modifiedMsgValue ; } In the above code what if gas runs out on the second line? so there will be ...
0
votes
1answer
22 views

gas usage for a large loop

How expensive are loops in solidity? (in terms of gas usage). I need to loop through ~1000 wallet address, and send each of them some tokens. my code: struct User { uint32 frozenAt ; uint ...
0
votes
0answers
24 views

Gas station network use cases

I'm trying to understand the purpose of EIP 1613. Related to this website says "No more Metamask". So it assumes that a user does not have direct access to his private key / wallet. It means the key ...
2
votes
1answer
16 views

What makes a transaction not mined and stay in txpool?

What Makes a transaction in txPool not mined ?
0
votes
0answers
16 views

What is the maximum gas price that we can set in a transaction?

what is the maximum gas price can we set it in a transaction ? I am always using '3000000' to avoid 'run out of gas exception' (poa network) But when I got 'replacement transaction underpriced' I ...
0
votes
1answer
20 views

can a gas comission be paid by the owner? [duplicate]

I want to create a token but, I want people to send the tokens without them paying for the gas, is there any command to do this
1
vote
1answer
36 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 ...
1
vote
1answer
35 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
20 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
18 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
28 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
36 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
63 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 ...
5
votes
2answers
169 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
33 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
40 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
31 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
21 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
43 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
25 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
39 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
48 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
39 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
46 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
49 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
13 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
43 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
26 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
31 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
30 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
93 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 ...