Skip to content

Instantly share code, notes, and snippets.

@sumitpatel93
Forked from bitgord/Escrow-Smart-Contract
Last active February 7, 2019 21:24
Show Gist options
  • Save sumitpatel93/3b6abd16a50eefb104675a95c4f59499 to your computer and use it in GitHub Desktop.
Save sumitpatel93/3b6abd16a50eefb104675a95c4f59499 to your computer and use it in GitHub Desktop.
Example of an escrow smart contract
pragma solidity ^0.4.21;
contract Escrow {
address buyer;
address seller;
uint amount;
function Escrow() public{
// setBuyer
buyer = msg.sender;
}
function setSellerAndAmt(address sellerAddress, uint amt)payable public {
seller = sellerAddress;
if (msg.value >= amt) {
amount = amt;
}
}
function release() public {
//Only allow buyer to release the funds
if (msg.sender == buyer) {
seller.transfer(amount);
selfdestruct(buyer);
}
}
function void() public {
//Only allow seller to void the contract
if (msg.sender == seller) {
selfdestruct(buyer);
}
}
}
@sumitpatel93
Copy link
Author

Made few changes in the smart contract acc to the latest solidity version for the compilation of the contract.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment