Skip to content

Instantly share code, notes, and snippets.

@ltfschoen
Last active March 31, 2018 08:48
Show Gist options
  • Save ltfschoen/2ef0201557cfed3ba16bf055f6c79c46 to your computer and use it in GitHub Desktop.
Save ltfschoen/2ef0201557cfed3ba16bf055f6c79c46 to your computer and use it in GitHub Desktop.
Car Garage Smart Contract
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