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
13 views

Smart contract breaches

I am new to solidity and smart contracts. I wanted to know that can a smart contract be broken? what if I have my own smart contract made for demo and I want to break it in terms of security? How do I ...
0
votes
1answer
10 views

How much gas does looking up block.timestamp consume?

Trying to get some insight as to whether or not it's more optimal to call block.timestamp repeatedly for comparisons or to set a (memory) variable to hold the value and use it instead. I've looked at ...
0
votes
1answer
22 views

Is there a drawback of setting a too high gas limit for a transaction?

Say, I want to send a transaction that consumes around ~40,000 gas. Could I just set the gas limit of the transaction to 1 million or is there some disadvantage and I should set a more realistic gas ...
5
votes
1answer
87 views

Why does gas cost explode with more than 7 variables in a struct

I'm assuming this has to do with Ethereum's 7 variable stack limit but in the following code test struct TestStruct5 { uint8 m_nOther1; uint8 m_nOther2; uint8 m_nOther3; uint8 ...
0
votes
1answer
11 views

What is the meaning of “Gas Used” on ethgasstation.info?

It's rather confusing cos when I googled "gas used" I don't get any exact result, NOT even from ethgasstation.info and most people are talking about transaction price, gas limit, etc. So, does "gas ...
1
vote
1answer
12 views

How to calculate “gas” and “gasPrice” when referring to ethgasstation.info when sending transaction via web3js?

I'm using web3js to issue token which has a name and description. I'm using ropsten testnet. Here's my tx. const tx = { from: walletAddress, to: contractAddress, gas: 4700000, ...
0
votes
1answer
17 views

Why does Ropsten consume more Gas than Rinkeby?

I deployed the following smart contract both to Rinkeby and to Ropsten. pragma solidity ^0.5.8; contract storeHash{ string private vehicleData; function setVehicleData(...
0
votes
1answer
33 views

Calculated Gas Costs of Contract execution

I have a smart contract that maps a string to a string value and stores it on the Blockchain. I want to analyse the Gas Used by Transaction. One time the execution consumes 92,843 Gas (https://rinkeby....
0
votes
0answers
29 views

Gas is 0 when executing CALL opcode?

I wrote a very simple smart contract like this: contract Test{ function test1(address payable addr, uint256 value) payable public { addr.transfer(value); } } And I compiled it using ...
1
vote
1answer
99 views

How to charge percentage of transaction cost?

Example: uint public createPostCost = 0.0003 ether; function createPost(bytes32 _post) public payable { require(msg.value >= createPostCost); Post memory newPost; ...
0
votes
1answer
56 views

Can't even create a smart contract: Sender doesn't have enough funds to send tx

I wrote and deployed a basic smart contract on Remix Javascript VM Environment. It worked fine. Then I installed and started TestRPC (now ganachi-cli). Then, upon changing the environment to Web3 ...
0
votes
0answers
32 views

How to create an ethereum private network with proof of authtority without gas cost or gas price zero?

I want to create a private network but I don't need to use ether or gas, only I want to run smart contracts and the blockchain using ethereum technology. I find this tutorial Private proof of ...
1
vote
1answer
72 views

Error set address/adding data, error: “gas required exceeds allowance or always failing transaction and the function doesn't work”

I'm trying to do a data access control system with smart contract. I have 3 entity: Client: who can get data and set address of Oracle Oracle: who can add data and have getData() function RBAC: Role ...
1
vote
2answers
24 views

Simple contract throws for no apparent reason

the thing is that i have a very simple contract code that I wrote as a kind of "Hello World!", but it doesn't seem to work properly, and I can't see any reason why it wouldn't work. The code I'm ...
1
vote
1answer
26 views

Why are ERC 20 transfer(…) gas costs different?

We have 2 identical transactions, one spends 22409, and the other 37345 gas, why so? https://etherscan.io/tx/0xaeefbb8aab4fd61fc057b4013f8ca2accd4ed573ec4dcfacc02a1bcfb99cb3f8 https://etherscan.io/...
0
votes
2answers
19 views

Transaction/Function Call Gas consumption

I've read in the documentation that reading data from the blockchain does not cost gas. It costs gas only when saving data to the blockchain or when executing operations like +, -, * etc (see the ...
0
votes
3answers
47 views

Limit the number of times a static function is called

As far as I am concerned, when a function in a smart contract is defined as pure or view it is possible to invoke it without being charged for the gas consumption that its execution requires. This ...
0
votes
0answers
15 views

Find exact gas limit requirements for executing fallback function logic

I have a certain function logic coded for fallback function. This logic also contains some delete operations of storage variables (delete storeVarX;) due to which there might be some gas being ...
0
votes
1answer
28 views

Calculating a total Raiden transactions' gas cost

The Raiden network, which is a off-chain layer 2 implementation based on ethereum has no transaction costs, see link under transaction fees here. The transaction fees are not a factor in gas cost for ...
0
votes
1answer
35 views

Costs/efficiency of locating stored data on Ethereum

Based on the answer to this question, storing IPFS hashes on Ethereum could be done in 3 ways: Store it as a string Store it as a struct Store it in event log Ordered from most expensive to least ...
0
votes
0answers
26 views

Why does my private network transaction use a different amount of gas than my mainnet transaction performed immediately after?

I am forking the mainnet from my own geth node with ganache-cli --fork option. Immediately after the fork, I simulate a transaction to a contract on the forked, private network. I then immediately ...
0
votes
1answer
10 views

will the gas to execute my function increase if the array of object get bigger in the future?

From the contract below, if the logs get bigger and bigger (let's say it contains 1M items). The cost for calling set will be increase or not? I think that the cost for calling when the array size ...
1
vote
1answer
22 views

Prevent Replay protection in Preauthorized functions

I was looking for a way to send transaction on behalf of users in Dapp. Luckily, I came across the EIP 662. I am implementing something suggested here by emansipater As stated in EIP, the replay ...
2
votes
2answers
53 views

How much data can I store in a smart contract, what is the cost and how it is implemented?

If I suppose I use a smart contract as a database, how much data can I store? speaking only of strings and integers, save them in contract data structures does it cost in addition to the gas used for ...
0
votes
1answer
19 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?
1
vote
1answer
60 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
46 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
95 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
29 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
36 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
20 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
16 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
61 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
13 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
442 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
19 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
19 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
43 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
50 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
27 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
46 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
18 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
56 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
61 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
38 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
38 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
34 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
274 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-...