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
13 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'; ...
1
vote
0answers
13 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 ...
0
votes
1answer
19 views

Error: Returned error: gas required exceeds allowance (89459648255865) or always failing transaction

I am running a contract on a private network in geth, and using web3js. I have the following error when I run a transaction: web3.min.js:1 Uncaught (in promise) Error: Returned error: gas required ...
3
votes
2answers
19 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 ...
4
votes
1answer
47 views

How transactions are selected by the miners?

The deployment of transaction executions is bounded by the block gas limit that changes dynamically. If a block fits only one transaction, then the gas limit per transaction is, in theory, the same as ...
1
vote
1answer
16 views

Multiple transactions with same nonce, pending ones makes me crazy rest is ok, but why?

I am playing with smart contracts in code, sending/receiving transactions to/from it. Some transactions with lower gasPrice are stuck in a pending state. However, having same nonce with a higher ...
5
votes
1answer
105 views

Gasless transaction and easy approval integrated to an ERC-20 token

I am planning a token swap for an old pre-ERC-20 token. The new token will have its ledger smart contract written from a scratch. While doing it, I would like to integrate new EIP features to the ...
0
votes
1answer
23 views

remix compiler warning infinite gas requirement

I'm trying to deploy a trivial faucet program which compiles OK with remix but I get the following error. "Gas requirement of function Faucet.withdraw(uint256) high: infinite. " This means that while ...
0
votes
0answers
14 views

All tokens created on ethereum use (ETH) gas to pay for the transaction fee. What about other currency like Waves?

I just wonder to know if other crypto platform (like Waves) use its main currency (eg.waves) to pay for transaction fee when a user transfer his own-created Token to other user's address (like what ...
0
votes
2answers
23 views

Will people who buy my newly created erc20 Token also have to buy ETH as well?

I'm currently deciding which crypto platform to go for (Ethereum or Waves). So I'm asking this question because I just wonder if the people, who will buy my newly created token, will HAVE TO buy Ether ...
0
votes
0answers
14 views

How to pay Gas for client? [duplicate]

I'm building a DApp for donations and I do not want my donator ( or donatee) to pay for Gas. Thus I'm looking for a solution wherein gas is to be deducted from my wallet (third party) and not from ...
0
votes
0answers
21 views

Contract wallet allowance and fees

I just want to ask, does Contract Wallet need an approval/allowance? as far as i know, Contract Wallets are executed by Wallet owner (Owner account) and the gas fees are paid by this owner account. ...
1
vote
0answers
26 views

Gas limit vs gasleft() for failed call

I am having the following piece of code in my smart contract: uint256 gasBefore = gasleft(); externalContract.call.gas(gasLimit)(abi.encodeWithSignature( "myFunction(uint256,uint256)", param1, ...
1
vote
0answers
22 views

Extra fee for cross shard transactions

I have been looking into sharding and I wanted to figure out how much extra fee or gas does a person needs to spend on a cross shard transaction compared to a transaction within a shard. What could ...
2
votes
1answer
20 views

It is possible to run out of gas when calling bytes32[]?

Is possible to run out of gas when calling bytes32[], even when count e.g. 1k entries?
0
votes
0answers
35 views

Geth automining includes only 1 transaction per block

I am trying to perform a heavy load and scalability tests on a smart contract. However, the test takes a lot of time because only 1 transaction is added per block. I read that this might be due to ...
1
vote
2answers
37 views

Why does a miner still pay gas for a reverted transaction?

I ran a contract here, I got the message "Transaction mined but execution failed". : [vm]from:0xca3...a733cto:Will.deceased() 0xbbf...732dbvalue:0 weidata:0x72f...af2d9logs:0hash:0xac5...6c5be ...
0
votes
2answers
58 views

Solidity 0.6.1 Receive Fallback Forwarder reverts due to insufficient gas

I am playing around with Solidity 0.6.1 and trying to build a simple funds forwarder. So ETH is sent to the contract and it sends the funds to another address. I deployed it to Ropsten. But every ...
0
votes
0answers
33 views

gas estimation fails when trying to run a recursive function? Is there an alternative?

I have been trying to traverse a graph kind of data structure and the only way to do this is by using a recursive function is what I feel. So, now when I try to execute my contract code in remix it ...
0
votes
1answer
21 views

GasPrice: is dipendent by the moment of the call and/or the network?

I'm testing a system to store a small amount of data on the blockchain using a contract. So I've some js using web3.js to make a call to a contract function that mutates states. I obtained, using ...
0
votes
1answer
37 views

Multiple GasLimits on my Private Ethereum network?

I am wondering if it is available to make multiple gas limit block in one of my private networks. The multiple gas limits blocks in a private network means that size 10, 100, 1000 and so on, those are ...
0
votes
2answers
40 views

Use uint[] to map uint(address) to uint

Is there any reason not to use uint[2**160-1] addressIndex; instead of mapping(address => uint) addressIndex; ?
0
votes
1answer
17 views

ERC20 decimals and gas costs

This question is twofold: The standard number of decimals for an ERC20 token is 18. If we lower this number, can we expect decreased gas costs when creating/transferring the token, since this should ...
1
vote
1answer
45 views

Is it safe to do multiple payments in between locks (Reentrancy Guard)?

https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/ provides a simple example related to using a Reentrancy Guard. Another approach to preventing reentrancy is to ...
3
votes
1answer
391 views

What's the vulnerability in my contract?

I've got a contract deployed at 0xe559835D7979dAe994331DEfaEc2FBA057E56C27 on the mainnet. Every time I go to call the payable function, which is solve, a bot beats me to it. My transaction gets ...
3
votes
2answers
32 views

Variable Names and Memory

Is there a cut-off where a variable name uses more memory? For instance: uint public priceOfEthYesterday9AMUSAET vs uint public pEth One is more descriptive, but if it's costing me gas I don't ...
1
vote
1answer
44 views

How are transfer and send protecting against reentrancy if the gas is taken from the EOA (msg.sender)?

I guess transfer and send simply allow 2300 gas but no gas is taken from the contract? In other words if a wallet calls this function with say one million wei gas: function sending() public payable { ...
4
votes
0answers
54 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
1answer
577 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
22 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
23 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
23 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 ...
1
vote
0answers
54 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 ...
2
votes
1answer
29 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
42 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
33 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
36 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
34 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
2answers
46 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
151 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
17 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
23 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
29 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
21 views

What makes a transaction not mined and stay in txpool?

What Makes a transaction in txPool not mined ?
0
votes
0answers
24 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
22 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
37 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 ...
2
votes
1answer
73 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
22 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
20 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 ...

1
2 3 4 5
18