Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with Distribute challenge #14

Closed
EWCunha opened this issue Oct 15, 2022 · 3 comments
Closed

Trouble with Distribute challenge #14

EWCunha opened this issue Oct 15, 2022 · 3 comments

Comments

@EWCunha
Copy link

EWCunha commented Oct 15, 2022

I am having some trouble trying to optimize the Distribute contract. I believe that I need to do something about the transfer functions. I tried putting the 4 transfers in a for loop and also defining a local memory array that copies the contributors storage array, so that it does not get cold access for each element. But nothing of that worked. Could you give some tip that can help me solve this challenge? Thank you

@RareSkills
Copy link
Owner

Hi @EWCunha we can't put hints here, but this particular problem is indeed quite challenging. Note that if you copy the addresses from storage to memory, this will be an additional cost compared to just reading them from storage and doing a transfer.

Definitely try to think outside the box with this one!

@EWCunha
Copy link
Author

EWCunha commented Oct 16, 2022

Well, that doesn't help at all. I am honeslty out of ideas. I tried googling for gas efficient ways to send ETH to a batch of addresses, but didn't find any. I am also doing the Yul and Assembly Udemy course and tried some Yul code, but also didn't achieve the gas target. I tried storing the contract's balance to a variable, because it seems to me that reading the contract's balance costs a lot of gas, but on the test script, the balance is set artificially, without actually sending ETH (which seems like cheating to me), which does not update state variables. If at least I knew I am going to the right direction...

@Ayuilos
Copy link

Ayuilos commented Oct 22, 2022

Everything which is far more than test case is able to use. Even let this contract just be able to use once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants