Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
pragma solidity ^0.5.1;
contract DogPurchase {
address payable public buyer;
address payable public seller;
uint cost;
bool isDogPurchased;
uint currentID;
dogBreed dogPurchaseType;
enum dogBreed {ChowChow, Lowchen, Rottweiler}
event confirmedPurchase(address payable _buy, address payable _seller, uint _paid, uint _timestamp);
event sellerPaid ( address payable _buyer, uint _amountRecieved, uint _timestamp);
event BuyerRefunded(address payable _buyer, uint _amountRecieved, uint _timestamp);
constructor (address payable _buyer, uint _cost) public {
seller = msg.sender;
buyer = _buyer;
cost = _cost;
dogPurchaseType = dogBreed.ChowChow;
function FundPurchase() public payable{
require(msg.sender == buyer &&
msg.value == cost && !isDogPurchased);
isDogPurchased = true;
emit confirmedPurchase(buyer, seller,cost, now);
function payoutToSell() public {
require(msg.sender == buyer);
seller.transfer( address(this).balance);
emit sellerPaid ( buyer, cost, now);
function refundBuyer() public {
require(msg.sender == seller);
emit BuyerRefunded (seller, cost, now);
function DogPuchase () public view returns (dogBreed) {
return dogPurchaseType;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment