Last active
March 31, 2018 08:48
-
-
Save ltfschoen/2ef0201557cfed3ba16bf055f6c79c46 to your computer and use it in GitHub Desktop.
Car Garage Smart Contract
This file contains hidden or 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.19; | |
contract CarGarage { | |
uint256 public totalPurchasedPackages = 0; | |
uint256 public totalEtherDeposited = 0; | |
address public owner; | |
mapping(address => uint256) accountPackageQuantity; | |
event PackagesPurchased( | |
address indexed accountAddress, | |
uint256 etherDeposit, | |
uint256 accountPackageQuantity, | |
uint256 totalEtherDeposited | |
); | |
bytes32 name; | |
function CarGarage() public { | |
owner = msg.sender; | |
} | |
function buyPackageQuantity(uint256 amount) | |
public payable returns (bool) | |
{ | |
accountPackageQuantity[msg.sender] += amount; | |
totalPurchasedPackages += amount; | |
totalEtherDeposited += msg.value; | |
emit PackagesPurchased( | |
msg.sender, | |
msg.value, | |
accountPackageQuantity[msg.sender], | |
totalEtherDeposited | |
); | |
return true; | |
} | |
function getAccountPackageQuantity() | |
public constant returns (uint256) | |
{ | |
return(accountPackageQuantity[msg.sender]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment