Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created May 18, 2018 05:43
Show Gist options
  • Save PirosB3/6049d2c370c9b5be3d3c59ae53dbe291 to your computer and use it in GitHub Desktop.
Save PirosB3/6049d2c370c9b5be3d3c59ae53dbe291 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=
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