-
-
Save sumitpatel93/3b6abd16a50eefb104675a95c4f59499 to your computer and use it in GitHub Desktop.
Example of an escrow smart contract
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Made few changes in the smart contract acc to the latest solidity version for the compilation of the contract.