I'd like to develop a simple Escrow smart contract.

It will designate 3 parties, the buyer, seller and arbiter. A simple use case would be...

The buyer doesn't trust that the seller will send an item through the post, so they use an Escrow smart contract to aid the transaction.

The buyer locks 3 EOS into a smart contract, in which he can only then release the funds to the seller or raise a dispute, engaging the arbiter to take an action.

Should the seller honour the deal, the buyer simply releases the funds.

I have an old example of this written in Solidity.

contract Escrow {

address public buyer; 
address public seller; 
address public arbiter;

function Escrow(address _seller, address _arbiter){
    buyer = msg.sender;
    seller = _seller;
    arbiter = _arbiter;
}

function() payable {

}

modifier onlyBuyerAndArbiter() { if (msg.sender == buyer || msg.sender == arbiter) _;}
modifier onlySellerAndArbiter() { if (msg.sender == seller || msg.sender == arbiter) _;}

function payoutToSeller() onlyBuyerAndArbiter returns (bool){
        seller.send(this.balance);
        return true;
}

function refundToBuyer() onlySellerAndArbiter returns (bool){
        buyer.send(this.balance);
        return true;
}

function getBalance() constant returns (uint){
    return this.balance;
}

}

I know a similar thing can be achieved by simply creating a multisig account but what if I want to employ further logic like the transaction must be done by a certain time?

  • Also keen to find an answer :) How'd you go with this @John? – Dom V Jul 10 at 7:48
  • @DomV Learnt a lot since asking this question, looks like the way to go is set up listening for eosio.token::transfer actions which then keeps a record as to how much someone has sent to the account. Then one can just set up a withdraw action on the contract which has conditions before it would allow the receiver to get the money. I'd love to write a simple contract showing it off however haven't the time at the moment. Definitely on the to do list though. – John Williamson Aug 23 at 22:56
  • John. Can you share the code of a simple escrow EOS contract? Of course, if you did it. – Андрей Овчаренко Sep 15 at 15:04

Check out the code here. Bond contract developed by EOSMETAL is opensource. https://github.com/EOSMetal/tungsten

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.