Advertisement
Guest User

solidity-smart-contract-trust-v1

a guest
Mar 31st, 2021
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. pragma solidity = 0.8.1;
  2. contract Trust{
  3. address public parent;
  4. address public kid;
  5. uint public timestampToWithdraw;
  6. constructor() {
  7. parent = msg.sender;
  8. }
  9. function addKid(address _kid, uint _timestampToWithdraw) external payable{
  10. require(msg.sender == parent, 'only the parent can add a kid');
  11. kid = _kid;
  12. timestampToWithdraw = _timestampToWithdraw;
  13. }
  14. function withdraw() external {
  15. require(block.timestamp >= timestampToWithdraw, 'too early');
  16. require(msg.sender == kid, 'only kid can withdraw');
  17. payable(msg.sender).transfer(address(this).balance);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement