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
2
votes
2answers
7k views

insufficient funds for intrinsic transaction cost

i've codded a script using js to trigger a buy on uniswap. the way i achieved this is through importing uniswaps smart contracts using this line of code: const router = new ethers.Contract(addresses....
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
1answer
2k views

Can't send a new transaction with a lower nonce while the previous one is still pending

Several days ago I sent a transcaction via MetaMask, to a different account of mine, with a gas fee of 30 gwei. It's still pending due to a fee being too low. A transaction contains all Eth in an ...
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
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?
0
votes
0answers
234 views

Gas estimation failed -- flashloans -- solidity

I am able to deploy a smart contract, and even fund it with WETH from my metamask wallet without any gas estimation failures. When I try to execute my flashloan on this smart contract, however, I get ...
239
votes
8answers
178k views

What is meant by the term "gas"?

An Ethereum application that I want to use talks about needing "gas" to run. What is gas, and where do I get it?
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
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
0answers
17 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
2answers
47 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
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
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 ...
1
vote
1answer
403 views

Is there a way to debug a transaction, and see the gas used by that tx until any given point of the execution? (Ideally in Truffle)

I'm trying to figure out where are the big gas spender instructions from my contract, so I'm simulating some transactions in a forked local node using ganache-cli and debugging the tx using Truffle. ...
0
votes
1answer
580 views

How do I add more gas to the ganache-cli

I started the ganache-cli with 'ganache-cli -l 800000000' I deployed my contract with 'truffle --network development' which is defined in the truffle-config.js file as: networks: { // Useful for ...
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-...
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, ...
5
votes
5answers
4k 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
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
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
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 ...
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
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
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 ...
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 ...
13
votes
2answers
1k views

Can Solidity view/pure functions be arbitrarily complex?

Non-constant functions are limited in computational complexity by the block gas limit. I assume, but am not sure, that this does not apply to view/pure functions. Are view/pure functions in any way ...
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
56 views

My ERC-721 minting gas fee is almost $10000. Too high. How fix it?

I just deployed NFT Dapp on mainnet. Estimated gas fee is too High. It's almost $10000 How can i fix it? I never knew on local canache or rinkeby testnet There was fine gas fee.. is it depend on ...
5
votes
3answers
4k views

ERC20 :: Transferring tokens without sender gas

Let's assume we have 50 ERC20 tokens that we would like to support (deposits) on our website. People are depositing tokens to the ETH adresses we've generated for them. In the end of the day, we want ...
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 ...
1
vote
1answer
949 views

Transaction dropped. How to increase gas fee?

I sent some ether using Ledger Live, but the gas fee was too low. I would like to increase the gas fee. I was told I can do this via Ledger Ethereum Wallet for Chrome. However, when I open Ledger ...
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
364 views

How to cancel pending formation of wallet contract in Mist?

I have an (empty) account with no Ether in it yet. In Mist, I created a wallet contract since I thought I needed it to receive Ether. However, I know now that this is not the case. The wallet ...
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/...
1
vote
1answer
7k views

gas required exceeds allowance or always failing transaction

I really need help with this error. I'm testing the contract by sending ETH to Crowdsale contract .(Ropsten, My ether wallet, Remix). Full code is here: https://ropsten.etherscan.io/address/...
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 ...
1
vote
1answer
451 views

Allowance = Unlimited. What could happen?

Allowance = Unlimited. What can happen? Hi, let‘s say I approve via MetaMask that another address can spend an unlimited amount of ETH on my address. What can happen? Can this address spend all my ETH ...
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
293 views

Remix: How do I set the Gas Limit to Test a Contract?

I am using the Javascript VM on remix.ethereum.org to learn Smart Contract basics. I am following the tutorial here: https://www.youtube.com/watch?v=oTS9uxU6cAM&list=...
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 ...

1
2 3 4 5
28