JGcarv / SolidityJourney

Series of small projects and implementations I'm doing with the go of improving my solidity skills.
15 stars 1 forks source link

optimization suggestions for Will_v1.sol #1

Open cylobi opened 2 years ago

cylobi commented 2 years ago

Hey There I found some ways of optimization for your code that I thought I could share with you. No looping is ever needed for this contract:

Also I'm not sure about this one but I think the division of heirs[getHeirsAddress(i)] / total will result in integer instead of floating point and I don't think that is what you want.

Apart from these there is possible re-entracy attack opportunity in your code. I advise you to replace claim with a new function that each person could withdraw they're share and then before you transfer the amount ,set their weight to 0.

JGcarv commented 2 years ago

Hey! Thanks for taking the time to review my code. This was done purely as a learning project and quite a while ago, so I'm sure it's full of issues and vulnerabilities.