How do I set a manual gas price for a contract calling a function? And is nonce management implicit?
See original GitHub issueI have created a contract object with ethers.Contract giving it ABI and address. My necessity is to set a gas price that is constant so that I can do the transaction with lower fees. The problem is I cant find a way to set my gas price.
var provider = new ethers.providers.InfuraProvider('ropsten');
const privateKey1 = Buffer.from(process.env.PRIVATE_KEY_1,'hex')
var wallet = new ethers.Wallet(privateKey1,provider)
wallet = wallet.connect(provider)
......
var contract = await new ethers.Contract(address, originStampABI, wallet);
for(let hash of hashes){
var sendTransactionPromise = await contract.submitHash(hash)
sendTransactionPromise.gasPrice = 20000000000
sendTransactionPromise.gasLimit = gasLimit
console.log(sendTransactionPromise)
/* sendTransactionPromise.then(function(tx) {
console.log(tx);
}); */
}
}
I could only find the way to set the gas price by calling the gas price below the smart contract function call which seems to not work and give default gas price of 1GWEI in etherscan. I am using infura as the provider Also is nonce management implicit in ethers.js. I have not specified any nonce but it seems to be working
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
What is Nonce, Gas Price and Gas Limit?
A nonce is the number of the transaction of the sender's address. Every transaction from an address is numbered sequentially, beginning with 0...
Read more >foundry/README.md at master - forge - GitHub
Foundry will show you a comprehensive gas report about your contracts. It returns the min , average , median and, max gas cost...
Read more >Ethereum Gas: How to set gas price & gas limit in transactions?
FREE TRAININGS (WEB3 DEV, FLASH LOANS...) How to find your first 6-Figures Blockchain Developer Job: https://bit.ly/390ebTq Learn how to ......
Read more >Contracts — Solidity 0.8.17 documentation
Functions can be defined inside and outside of contracts. Functions outside of a contract, also called “free functions”, always have implicit internal ...
Read more >Solidity Documentation - Read the Docs
by calling functions of the code that manages the database. ... The gas price is a value set by the originator of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sssubik , by default, if you don’t override the nonce, ether.js will populate that for you by querying the transaction count from the network. But, if you want to use loop, try the experimental package, NonceManager, it increments the nonce for you.
@sssubik , use the override parameter, see doc here and overrides properties here