-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathDeadmansSwitch.sol
36 lines (29 loc) · 1.09 KB
/
DeadmansSwitch.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract DeadmansSwitch {
// TODO: Declare state variables
// Hint: You'll need variables for the owner, beneficiary, and last check-in block
// TODO: Implement constructor
constructor(address _beneficiary) {
// Hint: Initialize state variables
}
// TODO: Implement still_alive function
function still_alive() public {
// Hint: Update the last check-in block
}
// TODO: Implement release funds function
function releaseFunds() public {
// Hint: Check if 10 blocks have passed since last check-in
// If so, transfer the contract balance to the beneficiary
}
// TODO: Implement receive function to allow the contract to receive Ether
receive() external payable {}
// Helper function for testing (optional)
function getLastCheckInBlock() public view returns (uint256) {
// TODO: Return the last check-in block
}
// Helper function for testing (optional)
function getCurrentBlock() public view returns (uint256) {
return block.number;
}
}