Created
May 18, 2018 05:28
-
-
Save PirosB3/eb87c8a01edd7a9db68a3464b70f1701 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
This file contains 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.0; | |
contract Commitment { | |
enum CommitmentState { OPEN, CLOSED } | |
mapping (address => bool) attendeesRegistered; | |
mapping (address => bool) attendeesRefunded; | |
uint totalDeposited; | |
uint totalGuests; | |
uint public depositAmount; | |
CommitmentState public currentState; | |
function Commitment(uint _depositAmount) { | |
depositAmount = _depositAmount; | |
currentState = CommitmentState.OPEN; | |
} | |
function addAttendee() payable { | |
require(msg.value >= depositAmount); | |
require(currentState == CommitmentState.OPEN); | |
require(!attendeesRegistered[msg.sender]); | |
totalDeposited += msg.value; | |
totalGuests += 1; | |
attendeesRegistered[msg.sender] = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment