Hello. I want to create a simple smart contract to sell nfts, but I want 100% of earnings to donate to another address. I found that I can use PaymentSplitter from OpenZeppelin. I managed to make it work on ropsten, but I have few questions:
1. Release of funds is not automatic, it is made by calling "release", which spends gas. Is it possible to transfer earnings automatically? Maybe without PaymentSplitter.
2. This is more broad question. How can I calculate how much gas will function spend on mainnet?
Feb 28, 2022, 4:29 PM
1) No, somebody always has to call the contract and pay for the gas
2) It will use the same amount of gas on mainnet as it does on testnet (assuming it doesn't depend on something like looping over receivers). Just the gas prices are different then
2) It will use the same amount of gas on mainnet as it does on testnet (assuming it doesn't depend on something like looping over receivers). Just the gas prices are different then
Feb 28, 2022, 4:30 PM
Thank you! For example, how can I calculate how much gas this operation will consume?
If I get it right, complexity of operation is expressed in gas limit. I can't influence base fee price, it will fluctuate depending on blockchain usage.
These are two transactions which use same function:
https://ropsten.etherscan.io/tx/0x933e33f7aec2709cbcb88349ec3459decd2d9eaccc35e101081b69068ad429ba
https://ropsten.etherscan.io/tx/0xfd193b85b4cf07b7a5d293df4747694f1a7872b2b31ace13eab0b21e312114a2
First one used 108863 gas limit and second one 64263. How can I calculate how much it will be on mainnet?
If I get it right, complexity of operation is expressed in gas limit. I can't influence base fee price, it will fluctuate depending on blockchain usage.
These are two transactions which use same function:
https://ropsten.etherscan.io/tx/0x933e33f7aec2709cbcb88349ec3459decd2d9eaccc35e101081b69068ad429ba
https://ropsten.etherscan.io/tx/0xfd193b85b4cf07b7a5d293df4747694f1a7872b2b31ace13eab0b21e312114a2
First one used 108863 gas limit and second one 64263. How can I calculate how much it will be on mainnet?
Feb 28, 2022, 4:59 PM
It's not about the gas limit, but about the gas usage. If the logic is the same and it doesn't depend on contract state, then the gas usage is the same.
Or, you can initiate the transaction in mainnet and your wallet will tell you how much it will cost, before sending it
Or, you can initiate the transaction in mainnet and your wallet will tell you how much it will cost, before sending it
Feb 28, 2022, 5:01 PM
You mean this gas usage?
Feb 28, 2022, 5:02 PM
Yes
Feb 28, 2022, 5:02 PM
That's what I meant. The function is the same, but two different usages of this finction used different amount of gas. 108863 and 64263. Function is release from openzeppelin's PaymentSplitter. Why gas amount is different?
Feb 28, 2022, 5:04 PM
It then depends on the contract state.
Feb 28, 2022, 5:05 PM
Strange. It shouldn't, I think.
Feb 28, 2022, 5:06 PM