Anyone have tips on lowering gas on contracts? I have this multisender contract…simple contract but it’s always asking for $50 of gas on BSC chain. That’s crazy I must have goofed something up.

Jan 23, 2022, 6:47 PM
how many addresses are you airdropping to
Jan 23, 2022, 6:48 PM
https://bscscan.com/address/0xc91c8e5980edd14815a232153e5e768dc0e058d8#code
just testing two addresses
The tokens are at the creator address...maybe I need to move the tokens to the contract address to lower fees?
Yeah was just testing with two, three addresses. Not a whole airdrop
Thanks for any guidance. I'll try a few other ideas and see if I can suss out the issue.
Jan 23, 2022, 7:02 PM
Could try updating balances directly instead of calling transfer function
That might save some gas from avoiding the function call. But solidity compile might optimize out the call anhyway, not sure
Jan 23, 2022, 7:03 PM
OK both great tips. I’ll look into.
thanks
Jan 23, 2022, 7:03 PM
But that would require adding airdrop support into token contract itself
Jan 23, 2022, 7:04 PM
What is the new ERC system or docs on it?
Jan 23, 2022, 7:04 PM
Which erc standard are you referring to?
Jan 23, 2022, 7:04 PM
That’s not a problem. I’m sure adding more features to the Token Generating Event would be a good idea.
Jan 23, 2022, 7:05 PM
How much gas usage are you seeing for your test of two addresses
Jan 23, 2022, 7:05 PM
0.359BNB to send thru this contract
I was expecting 0.0359BNB
Jan 23, 2022, 7:06 PM
Sorry, gas units
Lkke 1M gas? 500K gas? Etc
Jan 23, 2022, 7:07 PM
I’ll look that up next. I didn’t write it down and away from my desktop.
Thanks for the tips. I’ll look into both those things. I’ll let the group know if successful.
Jan 23, 2022, 7:08 PM
It seems
Jan 23, 2022, 7:10 PM
Store array length on memory, remove that require and make the function external
Jan 23, 2022, 7:11 PM
AHAHAH
Jan 23, 2022, 7:13 PM
I tjink the compiler does the length store for you since when I tried to store the length manually there wasn’t much of a gas change.
Good call on removing the require from the loop
Jan 23, 2022, 7:13 PM
I tried it once too, made a 100k gas diff on 4k iteration loop
Jan 23, 2022, 7:13 PM
Oh wow nice, I will try again then
Jan 23, 2022, 7:14 PM
test with hardhat and use gas reporter
Jan 23, 2022, 7:15 PM
Will do. Thanks
Jan 23, 2022, 7:21 PM
Yes I use hardhat exclusively but just would just manually get gas metrics from tx receipt , is that same detail as gas reporter? Or does it provide more detailed metrics?
Jan 23, 2022, 7:26 PM
well you can get gas reports for each function called
Jan 23, 2022, 7:34 PM
Oh nice ty
Jan 23, 2022, 7:36 PM
I still need to setup hardhat properly. Just been using Remix.
Jan 23, 2022, 7:42 PM
It’s pretty easy once you get the hang of it. Npm install hardhat to install (once you have node and npm installed), then npx hardhat to create new project using templates
Includes typescript templates which is really cool (I love typescript)
Jan 23, 2022, 7:46 PM
I started a test project in Hardhat and Studio Code this past week. Just need to dive in now.
Jan 23, 2022, 7:52 PM
Awesome! Let me know if you have any questions, hardhat is awesome but pretty complicated and can take a little while to get the hang of
Jan 23, 2022, 7:53 PM
Any recommended tutorials or youtube suggestions to learn it better?
Jan 23, 2022, 8:02 PM
To be honest I don’t know I just dive into Google when I have problems. Sometimes it can take a while but you learn a ton
I’d make sure you have a solid understanding of how blockchains work first thiugh otherwise most things won’t make sense
Jan 23, 2022, 8:03 PM
Yeah, definitely. Think I've got a good foundation of Blockchain understanding. Great group here.
Jan 23, 2022, 8:08 PM
Perfect!
Jan 23, 2022, 8:10 PM

© 2024 Draquery.com All rights reserved.