Skip to content

Instantly share code, notes, and snippets.

@chpapa
Created April 21, 2016 07:46
Show Gist options
  • Save chpapa/b9f91b05cec1ecbccb86c89e35581df8 to your computer and use it in GitHub Desktop.
Save chpapa/b9f91b05cec1ecbccb86c89e35581df8 to your computer and use it in GitHub Desktop.
Solidity Sample
contract Cannabis {
string public motherPlant;
string public plantDate;
string public location;
uint8 public supply;
address public grower;
struct Dispensary {
address dispensaryAddress;
uint8 storageJar;
uint8 supply;
}
struct Customer {
address customer;
}
mapping(address => Dispensary) public dispensary;
mapping(address => Customer) public customers;
function Cannabis(
string myMotherPlant,
string myPlantDate,
string myLocation,
uint8 weight) {
motherPlant = myMotherPlant;
plantDate = myPlantDate;
location = myLocation;
supply = weight;
grower = msg.sender;
}
function soldToDispensary(address toDispensary, uint8 storageJarNum, uint8 weight) {
if(msg.sender != grower) { throw; }
dispensary[toDispensary] = Dispensary({
dispensaryAddress: toDispensary,
storageJar: storageJarNum,
supply: weight
});
supply = supply - weight;
}
function soldToCustomer(address toCustomer, uint8 weight) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment