Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
8 views

How do I get the transaction fee used by a transaction in web3py

I am using web3py to do transactions for token and ether. Now I need to keep a track of transaction fee applied for each transcation. How can I get the transaction fee from transaction hash?
0
votes
1answer
10 views

Metamask Failed transaction when sending out BAT tokens

I've been trying to send some BAT tokens out of my metamask wallet for quite awhile and it keeps eating up all my eth gas fees. I even increased the gwei fee to 100 and paid .50 USD as the fee. And it ...
1
vote
2answers
25 views

Best way to delete element of a dynamic array without knowing the index

I have this mapping mapping(bytes32 => address[]) public authorisation; This maps a hash with a list of authorised users. I have a function to add, and confirm - these work and its not an ...
1
vote
0answers
20 views

Why is one of my transactions using more gas when both carry out the same function of sending ether?

Below are two functions that I have in a simple lease smart contract. I am running a TestRPC node with Remix on version 0.5.1. When I call the terminate function, it executes and terminates the ...
7
votes
1answer
88 views

Why does adding a view function make write functions cost more gas?

When I add a view or pure function to a contract, it sometimes impacts the gas costs for unrelated write functions in the same contract - requiring another 22 gas. pragma solidity ^0.5.0; contract ...
1
vote
2answers
24 views

Smart contract function call from many accounts

Lets say that I have a smart contract C witch has a function setf(uint256). Also let's assume that there are many users(with different accounts) that want to call that function with argument 5 for ...
0
votes
1answer
27 views

remix - gas limit exceeded, but contract is running on blockchain

i studying remix and ethereum, and create my local blockchain. and create contract with remix.the contract just print simple word. pragma solidity ^0.4.8; contract HelloWorld{ string public ...
1
vote
0answers
19 views

Why JUMP opcode costs more than the rest

Looking here, most of the basic opcodes are 3 while JUMP is 8. Wondering why this is, why the 3x multiplier on this instruction.
1
vote
0answers
13 views

How come the gas usage of an empty fallback function is not integer?

I am trying to compute the gas usage of an empty (i.e., the most basic) fallback function. My on-chain code (compiled via Truffle 4.1.15): pragma solidity 0.4.25; contract MyContract { function(...
0
votes
1answer
21 views

How to set default gas limit for my custom private network?

I've connected to my custom private ethereum network in remix with web3 provider. Everything was fine, account balance, and address was retrieved successfully. But I don't know why, but I could not ...
1
vote
1answer
12 views

Function which only reads data still using gas/tx fee

I have a function call which only reads data from contract but it still costs gas to execute: function foo(int256 x) public returns (bool) { if(tuna[x].validOnce == true){ if(dog[x] == ...
5
votes
2answers
319 views

How is it possible to pay 2,100 Ether ($309,267) for a transaction fee?

Here is the transaction details that has transaction fee for 2,100 Ether ($309,267.00) only for sending 0.1 Ether. There is no fairness for users, hence accidentally adding a zero might cause them ...
1
vote
1answer
16 views

Costs in gas of changing the value of a variable

Maybe a little bit weird question, but can the amount of gas, when: SSTORE is used(for changing an existing variable), be lesser than 5000 gas? If no, are there discussions in community to reduce ...
0
votes
0answers
15 views

Example of a low-level transaction

I am looking at this trying to understand exactly what a transaction can be like (from the outside, I don't know much about blockchain). I have also taken a look at these: https://medium.com/@...
1
vote
1answer
33 views

ERC721 - How is gas worked out with TokenID?

ERC721 - I have minted a tokenid (tokenid=444) and my account owns it. When I try and transfer it, I get this message stating the gas cost is the normally calculated one and the total cost has the ...
2
votes
2answers
32 views

Does a string message increase the gas usage of a `require` statement?

In solc 0.4.22 onward, it is possible to provide a string message containing details about the error that will be passed back to the caller (in require, assert and revert statements). Does the gas ...
0
votes
1answer
20 views

Gas displayed on “Remix”

Is Gas displayed on "Remix" at function execution the same as when executed on the main net? I'm using the Javascript VM as the environment.
1
vote
1answer
31 views

How does USDC manage to only cost 25k gas instead of 35k++ for transfer?

I am baffled why Centre's USDC only costs around 25k for token transfer instead of 35k++ like other common ERC20. For example this is Gemini USD: https://etherscan.io/tx/...
0
votes
1answer
14 views

What is the cheapest way to send ERC20 to multiple Addresses? [duplicate]

Let's say I got 100 tokens of any ERC20, and I want to send one of each to 100 differents addresses. What would be the cheapest in term of gas between 1) creating a smart contract which takes in ...
1
vote
1answer
36 views

Designing for stalled transactions

We have been developing a dapp which submits a very basic transaction (placing a short hash and some Eth into a contract). We set the gas relatively high (250000). Often the transaction is mined in ...
2
votes
1answer
39 views

Where can I learn to read a flow of opcodes and learn how to debug transactions?

There are many tools and visualizers to use to read through a transaction, but where can I go to learn how to understand this? Fore example, that first link has a series of opcodes (and their ...
3
votes
1answer
49 views

Switching from 'storage' to 'memory' increases the gas-cost

I've read several related answers and blog posts, all of them suggesting that for the sake of reading complex state variables (i.e., arrays and structures), one should always prefer declaring the ...
0
votes
1answer
21 views

How much does the gas prices in the main eth network differ from that in the ropsten test network

I'd like to know, to which degree does the Gas prices from the main eth network are comparable to the ropsten test network.
0
votes
0answers
25 views

Remix Gas Error in ERC20 Token Contract

I successfully deployed to ROPSTEN a very simple ERC20 Token Contract - the code for which I copy-pasted from OpenZeppelin's GitHub repo. -I used remix to do this (see screengrab below) -I'm 99.9% ...
2
votes
0answers
31 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 =>...
1
vote
1answer
106 views

Remix - Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails). What can be done?

I get the following error when deploying my contract in Remix: Contract creation initialization returns data with length of more than 24576 bytes. The deployment will likely fails. More info: eip-...
2
votes
1answer
104 views

Is gas burned in a PoA network?

I read in another thread that since sealer nodes don't get rewards, the gas spent in the network is burned and doesn't go to anyone. However to limit spam, there needs to be a non-zero gas price. Do ...
0
votes
2answers
19 views

How to calculate the difference between what was transferred and what was sent / received?

Hi I'm trying to get some clarity as to what the difference is between what was Transferred Sent Received Shouldn't what's transferred and received be the same? Transferred means the amount that was ...
0
votes
2answers
19 views

If Ethereum gas charges based on the individual CPU instructions

I'm trying to understand exactly how gas works. Wondering if it charges based on actual individual CPU instructions (like Assembly-level x86 instruction set architecture level of detail), or if it ...
0
votes
0answers
23 views

Matching inside my contract fails with multiple participants

my contract (can be found on my gist: https://gist.github.com/fabs993/e13fa6ecd9526d30c8a6d85c10180075) fails at more than 5+ participants. So in my use-case I have two kind of participants Producer ...
1
vote
1answer
27 views

Processing gas cost on a sidechain

I am developing a sidechain that will store data and I want to evaluate the processing of this data in the ethereum network to get the cost in gas. I'm going to develop a smart contract that will ...
0
votes
0answers
59 views

Transactions always fails on POA sokol testnet blockchain

POA Sokol is a ethereum like testnet blockchain. I am using ether.js to make a contract call . The eth_estimateGas method in testnet gives this response but works in mainet: { "jsonrpc": "2.0", ...
1
vote
1answer
53 views

Using web3 estimateGas API (with infura) always returns the last block's gas limit

I am entirely unsure what the root cause is, but every time I use web3.eth.estimateGas with my call's parameters, it results in the last blocks gas limit as the result (~8 million). I have even tested ...
1
vote
2answers
20 views

Storing gas in a contract for next interaction to be “free”

I have a contract where the user has to interact twice. Is it possible to deposit GAS and store it in the contract for the first interaction, so the later interaction will be "free"? (and additional ...
0
votes
0answers
26 views

Why I can use a lower gasPrice than the node I set in --gasPrice

I established a private network recently and I use web3.eth.sendTransaction({from:"0x14ca04ff85747def87d6c6c566db84cc24e4643b",to:"0xa04fce8906c870a47a8a7f5f7547dfc4a62cae7a",value:"1000000000",...
1
vote
0answers
24 views

Is there a standard way for 3rd party to pay gas?

A smart contract can be modified to provide, for each functions that allows a 3rd party to pay gas, an alternative of that function which takes a signed message and assume the signer to be the sender, ...
1
vote
1answer
322 views

Out of gas error for a view function

having a problem with calling a method of my deployed contract in the main Ethereum network. I have a 'view' function which returns user's refund balance, everything worked fine in my local ...
3
votes
1answer
83 views

web3.eth.getGasPrice() always return 1GWei

For estimate transaction cost, I use web3.eth.getGasPrice() function. The return callback value always 1Gwei(1,000,000,000) in ROPSTEN. web3.eth.getGasPrice(function(error, result){ console.log(...
0
votes
2answers
126 views

ropsten: insufficient funds for gas * price + value using web3

Im using "web3": "^1.0.0-beta.37" And I want to understand How can I send rawTransaction My code is: const pk = 'xxxxxxx'; const rawTransaction = { "to": "...
0
votes
2answers
29 views

The cost of using Ethereum as a reference database

As stated in the documentation there are 3 types of storage in the Ethereum VM (EVM) The storage, the memory, and the stack Each account has a data area called storage, which is persistent ...
0
votes
1answer
46 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 ...
0
votes
1answer
26 views

How do miners claim gas from an invalid transaction?

Suppose a transaction T changes the state from S to an invalid state S'. For example, say, it ran an long loop of no operations (no_op), and attempted a double spend. Since this T transforms the state ...
2
votes
2answers
1k views

How much Ethereum is used daily in gas?

I can see from this site - https://etherscan.io/chart/gasused - the amount of gas used on the Ethereum network daily. What I cannot work out is how much ETH that corresponds to. Is there some other ...
3
votes
2answers
65 views

Why is the Eternal Storage approach still used if it hugely increases gas usage compared to storing data in structs?

I was wondering why is the eternal storage approach (first code snippet) still used? I know it's meant to make contracts upgradable but it seems too expensive to me. contract Storage { mapping(...
0
votes
1answer
95 views

What is the gas cost of keccak256(“abc”)?

According to this answer, the gas cost of keccak256 is: 30 gas + 6 gas for each word (rounded up) for input data to a SHA3 Keccak-256 operation I'm assuming that the size of a word is 256 bits and ...
0
votes
1answer
51 views

I have question about private block chain gas structure

I have a basic question about gas price charged for transaction. Say I have a private ethereum block chain with ten nodes and I don't want to charge any fee for the transaction taking place in this ...
0
votes
2answers
99 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 ...
0
votes
1answer
28 views

Difference between transfer/transferFrom and approveAndCall in cost

Which of these functions cost less, computationally and in terms of gas usage?
3
votes
1answer
115 views

Gas costs of the following contract

I'm calculating the gas costs of the following contract: 0x6001600190016007026005016002900460049060016021900560150160030260059007600303600960110a60005260086000f3. Disassembled versions: contract ...
0
votes
2answers
83 views

Gas issue on sendRawTransaction on the rinkeby network

I'm facing a gas issue on rinkeby network on sendRawTransaction. Tested with various gas value to experiment and getting either insufficient funds for gas * price + value or exceeds block gas limit. ...