Skip to content

Instantly share code, notes, and snippets.

@codeWhizperer
Last active July 30, 2022 19:27
Show Gist options
  • Select an option

  • Save codeWhizperer/cb336cfce0a85038ddc15c2ba6970d6c to your computer and use it in GitHub Desktop.

Select an option

Save codeWhizperer/cb336cfce0a85038ddc15c2ba6970d6c to your computer and use it in GitHub Desktop.
// Collect funds in a payable `stake()` function and track individual `balances` with a mapping:
// ( Make sure to add a `Stake(address,uint256)` event and emit)
// After some `deadline` allow anyone to call an `execute()` function
// If the deadline has passed and the threshold is met, it should call `exampleExternalContract.complete{value: address(this).balance}()`
// If the `threshold` was not met, allow everyone to call a `withdraw()` function
// Add a `withdraw()` function to let users withdraw their balance
// Add a `timeLeft()` view function that returns the time left before the deadline for the frontend
// Add the `receive()` special function that receives eth and calls stake()
// receive() payable external {
// stake();
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment