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
contract StateMachine { | |
enum Stages { | |
AcceptingBlindedBids, | |
RevealBids, | |
AnotherStage, | |
AreWeDoneYet, | |
Finished | |
} | |
// This is the current stage. | |
Stages public stage = Stages.AcceptingBlindedBids; |
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
contract AccessRestriction { | |
// These will be assigned at the construction | |
// phase, where `msg.sender` is the account | |
// creating this contract. | |
address public owner = msg.sender; | |
uint public creationTime = now; | |
// Modifiers can be used to change | |
// the body of a function. | |
// If this modifier is used, it will |
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
contract Coin { | |
// The keyword "public" makes those variables | |
// readable from outside. | |
address public minter; | |
mapping (address => uint) public balances; | |
// Events allow light clients to react on | |
// changes efficiently. | |
event Sent(address from, address to, uint amount); |
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
contract SimpleStorage { | |
uint storedData; | |
function set(uint x) { | |
storedData = x; | |
} | |
function get() constant returns (uint retVal) { | |
return storedData; | |
} | |
} |
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
contract Ballot { | |
enum Vote { | |
None, | |
Direct { proposal: Proposal }, | |
Delegated { to: address } | |
} | |
struct Voter { vote: Vote; weight: uint; } | |
using Proposal = uint8; | |
chairperson: address; | |
numProposals: uint8; |
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
contract Crowdfunding { | |
address recipient; uint goal; uint deadline; | |
struct Contribution { address contributor; uint amount; } | |
Contribution[] contributions; | |
uint contributed; | |
function Crowdfunding(address _recipient, uint256 _goal, uint256 _deadline) { | |
recipient = _recipient; | |
goal = _goal; | |
deadline = _deadline; | |
} |
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
contract Gamble { | |
function Gamble() { | |
owner = msg.sender; | |
address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; | |
nameReg.callstring32string32("register", "UltimateGamble"); | |
} | |
function gamble(uint luckyNumber) { | |
value = value+ msg.value; | |
hash randomness = sha3(block.prevhash ^ hash(msg.sender) ^ luckyNumber); |
NewerOlder