Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tx
Tokens
Tokens
Contract
Data
Contract
Contract
Data
Contract
contract Voting {
...
function voteForCandidate(bytes32 cand) {
votesReceived[cand] += 1;
}
function totalVotesFor(bytes32 cand) returns (uint8) {
return votesReceived[cand];
}
...
}
> node web3.<function>
> geth console web3.<function>
geth
testrpc
ROPSTEN
HOMESTEAD
https://etherscan.io
http://faucet.ropsten.be:3001/
Account 1
Account 2
Account 10
...
Account:
0xd871a40290563381F6BD203B20B8013cAcc1152B
> node solc.compile()
Balance: 3Eth
solidity
Compile
Deploy
pragma solidity ^0.4.11;
contract ProjectEngagement {
// Project name
bytes32 project;
// Influencer UID
bytes32 influencerUID;
// Engagement reward
// I.e. tokens awarded for each engament point
uint8 engagementReward;
// Total reward accumulated
unit8 totalReward;
// Engagement performance. Mapping period to engagement for that period
mapping (bytes32 => uint8) public periodEngagement;
// Has the influencer aggreed to this contract
bool accepted;
/*
Constructor to initialize contract
*/
function ProjectEngagement(bytes32 project, bytes32 inf, uint8 reward) {
project = project;
influencerUID = inf;
engagementReward = reward;
}
// Update weekly performance
function updateEngagement(bytes32 period, uint8 engagement) {
periodEngagemett[period] = engagement;
totalReward += engagement * engagementReward
}
// Total rewrd accumulated so far
function totalReward() return (uint8) {
return totalReward;
}
}