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
0
votes
0answers
4 views

Does brownie have functionality to analyze gas costs for all function calls?

Does brownie have any sort of functionality that gives a breakdown of the cost to deploy all contracts and execute all function calls within a brownie project with min, max and average gas cost ...
0
votes
0answers
7 views

What is a layer-1 and layer-2 bridge?

I understand that Ethereum mainnet is layer-1, and an ERC-20 token like Polygon to be a layer-2. But what is a bridge between these layers? Practically, in code, and financially? Especially interested ...
0
votes
0answers
8 views

Deploying Migrations using network Matic-- insufficient funds for gas * price + value

Trying to connect to the Matic network on Metamask. I funded the account with matic and followed the directions using Polygon's documentation. How do you solve the insufficient funds error?
1
vote
0answers
12 views

Is there a way to have a smart contract pay for its own invocation? [duplicate]

I want to introduce people to Ethereum (and clones) by way of giving them an NFT related to an event we are organising. I realise most people don't have an Ethereum (or any other EVM compatible ...
0
votes
0answers
18 views

How to avoid high ERC20 transaction cost?

I need to send USDT from Binance to WazirX (local Indian exchange) through APIs over a hundred times a day. Binance supports ERC and TRC chains, while WazirX supports only ERC. Is there some ...
0
votes
0answers
29 views

Testnet, "error: out of gas" when calling other contract's function within contract

so i tried to use address.call(abi.encodeWithSignature("function()")) in my caller contract to call the callee contract's function. It seems every time i deployed it into testnet and then i ...
0
votes
0answers
12 views

how can i fix these loop warnings and gas fee warnings. the code is compiled fine just want to update these warnings before launch

Here's the contract code to the token "alex". Below are the warnings from remix. Thanks for any assistance // SPDX-License-Identifier: MIT pragma solidity 0.8.4; contract alex { ...
0
votes
1answer
35 views

Gas Estimation Failed idk why

the contract has 0 error's i am trying to deploy it trough injected web3 after i have full filled the constructor amounts and trying to deploy it i get this error creation of RATCOIN errored: [ethjs-...
1
vote
1answer
33 views

How much can I trust on the truffle test gasUsed value?

I'm trying to guarantee that I'm not going to require more than the 200k gas limit on VRF fulfillrandomness call. I'm running the truffles test and they present to me gasUsed on the txn value of the ...
0
votes
1answer
17 views

How to add a mediator smart contract between wallet and another smart contract

Is there any way to achieve the following functionality.. I have a wallet, and 2 smart contracts(BankMediator and Bank). When I send eth to BankMediator(using deposit method below shown) from wallet, ...
0
votes
1answer
19 views

how to reduce transaction fees on private blockchains?

I have some questions regarding transaction fees on private blockchain. I'd appreciate your help. Also, if there are any references I can read about this, please let me know. Do transaction fees ...
0
votes
2answers
48 views

Gas Cost for setting whitelist addresses on contract

I know we all have high gas cost problems with whitelist. I noticed that there are two approaches to set whitelist addresses on the contract. I want to know which one costs lower gas. [approach 1] ...
1
vote
2answers
54 views

Deploying a simple contract to ETH Mainnet (from remix) costing $500? Am I doing this wrong?

I have a simple contract that I've tested on my ganache network, and now I'd like to push it to the mainnet. So I funded my Metamask with around $100 or 0.025 eth, figured that would be enough to ...
0
votes
1answer
18 views

Why does mining difficulty, gas prices raise, yet some transactions still fail?

I would be grateful if someone was able to clarify this, given my assumptions: Mining difficulty is depending on the amount of computational power invested into verifying transactions on the ...
0
votes
2answers
26 views

Is it possible for a server to execute a contract call but for a user to pay the gas fees?

I have a smart contract which contains a function called "withdraw" - which basically increases a users balance by X amount of an ERC20 token. The user can decide how much to withdraw by ...
0
votes
0answers
25 views

Refund gas fee Solidity

I have a solidity smart contract function which can only be called by the owner (onlyOwner modifier). A Node.JS app calls this function, it has the owner wallet mnemonic, and the function executes. ...
0
votes
1answer
22 views

Handling transactions fees when using Chainlink

I have a smart contract which must reach out to an off-chain data source (custom API) in order to verify that the wallet calling the function can do so. My understanding is that this is done via a ...
0
votes
0answers
16 views

How to allow contract function to run only after receiving gas payment

I am creating a dApp where there are 2 major stakeholders. Clients and multiple organizations. For a background on the Smart Contract, it has modifiers like onlyAdmin & onlyOrganizations. Where a ...
1
vote
1answer
26 views

Is it better practice to use smaller uint sizes when applicable?

My understanding of uint sizes is that smaller sizes will decrease gas costs. In my current dapp I'm building, I am dealing with time, for which it seems that uint32 will be plenty for my purposes (...
0
votes
0answers
7 views

How to see bytes in bytecode to estime gas cost of deployment

Pretty much title, trying to estimate my gas cost. I know each byte costs 200 gas. When I compile on Remix I see this object property. Is counting the number of characters in that an accurate measure? ...
1
vote
1answer
44 views

Does the EVM calculate the gas used for a transaction in real time?

Does the EVM calculate the gas used to execute a transaction on the fly as opcodes are being executed? So if there's a branch in code whose conditional is satisfied then additional gas is used to ...
0
votes
1answer
25 views

How do crypto games make users not pay gas

I am researching blockchain games, such as Axie Infinity, Crypto Cars, etc. As I understand it, when connecting a website to the ethereum/BSC blockchain to submit a transaction, the user will have to ...
1
vote
1answer
41 views

What is the gas limit for a view function call *not made from a contract*?

So this question seems trivial but I can't find any comprehensive answer, though reading through: Is there a gas limit for view requests? Why view/pure functions need gas? Exceeds block gas limit ...
0
votes
1answer
13 views

How do I have the Eth in one contract pay for the gas costs for operations in another contract?

I've got a semi-newb question about paying for gas to make an operation happen in Solidity. Can someone tell me whether something like this would worK? And if it can be done, if someone could point me ...
1
vote
1answer
33 views

Do I need to initialize the 'i' variable in a for loop?

Do I need to explicitly initialize the 'i' variable in a for loop? Since i is a uint and its default value is 0, why should I spend gas in a MSTORE operation to initialize the variable with 0? The ...
0
votes
1answer
29 views

How can I get the current ETH gas fees in python

I am trying to make a python program that gets the ETH gas prices. I am trying to avoid selenium scraping because I am using this for a discord bot. Does anyone know any good python APIs I can use?
0
votes
1answer
15 views

Different gas costs for token transfer on Fantom network

Can someone explain why the same WFTM transfer costs one time 38k and another time 23k gas? Here are the two transactions: https://ftmscan.com/tx/...
0
votes
0answers
9 views

gas vs gasLimit in web3.js [duplicate]

I've seen a bunch of stackoverflow posts on this and want to make sure I've got it right. I'm running into an issue where on test networks I can do this: contract.methods.mint(1).send({ from: ...
1
vote
1answer
16 views

Is it more gas efficient to declare variable inside or outside of a for or while loop?

In solidity does declaring a variable inside a while or for loop result in that variable being redeclared during each loop iteration? And if so does that make it less gas efficient than say declaring ...
0
votes
0answers
13 views

Truffle test: How to Calculate transfer Gas cost to be 2300 wei?

I am using gasleft() function. I am storing the gasleft() before transfer and gasLeft() after transfer, and then finding the difference. But I am getting wrong result maybe 7554. Somebody please guide ...
0
votes
0answers
18 views

When you deploy a smart contract that uses a library, does the entire library get deployed?

I'm taking a Udemy course on Solidity. I'm learning about libraries and wondering about the cost, in gas, of deploying a smart contract that uses a library? Is the entire library that is called ...
0
votes
0answers
34 views

Can you lazy minting an onchain NFT?

I want to mint my already created SVGs. I know we can encode svg to base64, and currently the gas price making onchain data minting is very expensive. Can we use rarible or opensea api to lazy mint ...
0
votes
1answer
33 views

Is the gas cost for constant and immutable about equal?

According to this question the Solidity 0.5.0 Compiler cannot compute a constant state variable that invokes a function, however I'm also experiencing this issue on Solidity 0.8.10 using the ...
0
votes
0answers
9 views

Do you think blockchain technology viable with very fragile and volatile gas fee?

This is not a technical question and I am wondering about the future of blockchain technology from a professional's perspective. Polygon being a layer 2 solution, it's gas fee has increased by 16 ...
0
votes
1answer
16 views

How does the EVM track the operations it performs when tallying up gas cost?

How does the EVM track the operations it performs when tallying up the gas cost of a tx? For example when a word is pushed to the stack - there is nothing in the solidity code explicitly saying to ...
0
votes
0answers
26 views

How can I check how much gas I'll need to deploy a contract with eth-brownie?

I kind of accidentally deployed an ERC20 token contract on the mainnet and brownie didn't even ask me to confirm so I ended up spending $700+ worth of ETH to practice. I didn't think it would cost ...
0
votes
1answer
19 views

Smart Contract Uploaded with single mint option; did not take into account multiple mints at once

Very simple question with I'm assuming no answer or a difficult to implement answer. We have a smart contract with a mint function that takes no arguments. It only allows for the minting of one token. ...
0
votes
2answers
32 views

Why does gas usage differ so much for two very similar functions that just check a condition and set a boolean?

I am facing one issue when interacting with my smart contract. Just to add, I have deployed by smart contract in bsc testnet. It has two similar functions- enableQuestion & disableQuestion, whose ...
0
votes
1answer
35 views

Why is gas used depended of the given gas limit?

I have an interesting phenomena EDIT: on the Fantom network, sorry if this is the wrong place to ask which I do not understand, so maybe someone is able to explain this: When I send a transaction with ...
0
votes
1answer
12 views

Gas cost too high on using IERC20.sol by openzeppelin

I am new to Solidity. I have deployed a smart contract for a multi-sig wallet on the Rinkeby Testnet. Here I used the IERC20.sol file by Openzeppelin for deposit, withdrawal and checking balances of ...
1
vote
0answers
31 views

Charge a user a fee based on gas price?

I want to let users mint NFTs and charge them a fee for each NFT that is a percentage of the gas price they are paying to mint. For example, if the total gas cost of minting one token is 0.1 ETH, and ...
0
votes
0answers
19 views

How much extra gas is incurred per transaction when using a proxy contract?

Say I have a contract Foo with method bar that has a gas cost per call of x, now say I choose to implement a proxy contract Proxy for interacting with Foo to allow for upgradability to FooV2 if the ...
0
votes
0answers
33 views

Minimising cost of on-chain NFTs

I am thinking of minting an on chain NFT collection by using various SVG layers. I want to layer the SVGs on top of each other to make a "complete" SVG, and I would like to nest it twice. ...
0
votes
1answer
15 views

how to tackle block gas limit to send large data file as transaction on ethereum

I want to send ethereum blockchain a file approx 39KB. The file is like array generated by python code. I dont want to use IPFS and oracle. Is this file exceed block gas limit? if yes, then can i ...
1
vote
2answers
64 views

Sending entire ether balance to another wallet

I found the same question but it was asked over 4 years ago but it doesn't seem to work anymore? How do I send the entire ether balance from one account to another account? const Web3 = require('web3')...
0
votes
1answer
35 views

Bulk update array / mapping in solidity by a call: that is the best method gas wise?

So I have to prepare a smart contract that need to be the most possible gas optimized. So far so good, but then i came across this requirement. Given a json file with pairs containing address: value, ...
1
vote
2answers
300 views

How do I get my ETH back? Transaction cancelled but ETH are gone :/

On Dec 18th I connected my Coinbase wallet to buy Adidas NFT on opensea.io It did not work several times but then it seemed to work. But finally I gut the confirmation that Transaktion was cancelled. ...
1
vote
0answers
21 views

The Matcha can't swap in the Celo chain [closed]

there is some wrong in Matcha when I try to swap in the Celo chain, and The Matcha Warns "Insufficient CELO balance". In fact, there are some celos in my wallet as gas. Is a bug with Matcha?
1
vote
1answer
24 views

Is it possible to modify the gwei of an internal transaction?

I am developing a contract that allows users to withdraw funds but I want to send them faster so I'm wondering, how can I modify the transaction gas price (gwei)? (bool sent, bytes memory data) = ...
0
votes
0answers
21 views

Error: transaction underpriced

The below code just stops working at the line "Attempting to deploy from account: .." in console and after sometime it gives "Trnsaction was not mined within 750s, please make sure your ...

1
2 3 4 5
28