DEV Community

Rajan lagah
Rajan lagah

Posted on

Solidity

Multiple deeds

pragma solidity ^0.5.0;

  contract SplitDeed {
    address payable public benificiary;
    uint256 public transferDate;
    address lawyer;`

   constructor(
        address _lawyer,
        address payable _benificiary,
        uint _transferDate
    )
        payable // Allow to send ether on creation of contract
        public
    {
        lawyer = _lawyer;
        benificiary = _benificiary;
        transferDate = _transferDate;

    }

    function withdraw() public{
        require(msg.sender == lawyer, "Lawyer only");
        require(now > transferDate, " Too early ");
        benificiary.transfer(address(this).balance);
    }
}
Enter fullscreen mode Exit fullscreen mode

Escrow

pragma solidity ^0.5.2;

contract Escrow{
    address payable public dev;
    address public website;
    address public customer;
    uint public amount;

    constructor( address payable _dev, address _customer,uint _amount) public {
        dev = _dev;
        website = msg.sender;
        customer = _customer;
        amount = _amount;

    }

    function deposit() payable public{
        require(msg.sender == customer, "Only customer can add money");
        require(address(this).balance <= amount, "Money can not exceed given amount");
    }

    function sendMoney() public{
        require(msg.sender == website, "Only website can transfer money");
        require(address(this).balance == amount, "Amount not proper"); 
        dev.transfer(address(this).balance);
    }

    function getBalance() view public returns(uint){
        return address(this).balance;
    }

}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)