Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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=
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