Lunyr Coding Challenge
Applying to the front end developer position.
Personal Website | rachel@blockchaindevelopers.io | UI Design Portfolio | LinkedIn | twitter
Process Outline
- Read and understand the contract. Find all plainly obvious bugs (insecure-firstPassNotes.sol).
- Run the contract through the remix compiler and check their analysis (remix-compiler-notes.md). Resolve all bugs.
- Think through the problem: Where can you use modifiers to encapsulate code? Are you emitting events where you should be? Have you thought about as many security angles as you can?
- run it through the compiler again to catch any additional bugs.
- final version: insecure-final.sol
As I went back through the contract I:
- added a struct to the shares map
- added some modifiers to ensure that only authorized users could engage certain parts & to lock the contract against reentrance.
- added more events to mark different locations of execution success or failure.
- I wrapped parts of the execution in
if
/else
statements to be more precise and to allow for both success and failure events.
The gas cost is a concern with the for
loop in the dispense
function. If there are enough shareholders the gas will run out.