//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract Deed {
    address payable public beneficiary;
    address public lawyer;
    uint public earliest;
    uint public amount;
    uint constant public  PAYOUTS = 10;
    uint constant public  INTERVAL = 10;
    uint public paidPayouts;

    constructor(address payable _beneficiary, address _lawyer, uint offset) payable {
        beneficiary = _beneficiary;
        lawyer = _lawyer;
        earliest = block.timestamp + offset;
        amount = msg.value / PAYOUTS;

    function withdraw() external {
        require(msg.sender == lawyer, "only laywer can withdraw");
        require(block.timestamp >= earliest, "you can only withdraw after a specific period specified by the contract");
        require(paidPayouts < PAYOUTS, "no payouts left");
        uint elligiblePayouts = (block.timestamp - earliest) / INTERVAL;
        uint duePayouts = elligiblePayouts - paidPayouts;
        paidPayouts += duePayouts;
        beneficiary.transfer(duePayouts * amount);
  • The contract is quite simpl e. It divides the initial deposited amount into PAYOUTS parts. Every INTERVAL seconds after an initial offset the layer will be able to claim a payout.
    – Ismael
    Jun 29, 2022 at 4:08
  • Thanks! But how does "paidPayouts" get incremented? Because, as far as l see, when you subtract it in "duePayouts", it is 0, it is not incrementing in any way
    – ETH guy
    Jun 30, 2022 at 5:39
  • When calling withdraw in this line paidPayouts += duePayouts, the variable paidPayouts is incremented by duePayouts.
    – Ismael
    Jun 30, 2022 at 16:21


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.