Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions legends_crowdfund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import "./legends_token.sol";
* @title LegendsCrowdfund
*/
contract LegendsCrowdfund {

address public creator;
address public exitAddress;

Expand Down Expand Up @@ -40,7 +40,7 @@ contract LegendsCrowdfund {
}
_;
}

modifier recipientIsValid(address recipient) {
if (recipient == 0 || recipient == address(this)) {
throw;
Expand Down Expand Up @@ -88,12 +88,12 @@ contract LegendsCrowdfund {
* @param recipient Address that tokens should be attributed to.
*/
function purchaseMembership(address recipient) external payable saleActive hasValue recipientIsValid(recipient) {

// Attempt to send the ETH to the exit address.
if (!exitAddress.send(msg.value)) {
throw;
}

// Update ETH amounts.
recipientETH[recipient] += msg.value;
totalETH += msg.value;
Expand Down
54 changes: 26 additions & 28 deletions legends_token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ import "./erc20.sol";
* @title LegendsToken
*/
contract LegendsToken is ERC20 {
string public name = 'VIP'; //The Token's name: e.g. DigixDAO Tokens
uint8 public decimals = 18; // 1Token ¨= 1$ (1ETH ¨= 10$)
string public symbol = 'VIP'; //An identifier: e.g. REP
string public version = 'VIP_0.1';

mapping (address => uint) ownerVIP;
mapping (address => mapping (address => uint)) allowed;
uint public totalVIP;
uint public start;

address public legendsCrowdfund;

bool public testing;
Expand All @@ -23,7 +27,7 @@ contract LegendsToken is ERC20 {
}
_;
}

modifier isActive() {
if (block.timestamp < start) {
throw;
Expand All @@ -45,20 +49,6 @@ contract LegendsToken is ERC20 {
_;
}

modifier senderHasSufficient(uint VIP) {
if (ownerVIP[msg.sender] < VIP) {
throw;
}
_;
}

modifier transferApproved(address from, uint VIP) {
if (allowed[from][msg.sender] < VIP || ownerVIP[from] < VIP) {
throw;
}
_;
}

modifier allowanceIsZero(address spender, uint value) {
// To change the approve amount you first have to reduce the addresses´
// allowance to zero by calling `approve(_spender,0)` if it is not
Expand Down Expand Up @@ -89,7 +79,7 @@ contract LegendsToken is ERC20 {
testing = _testing;
totalVIP = ownerVIP[_preallocation] = 25000 ether;
}

/**
* @dev Add to token balance on address. Must be from crowdfund.
* @param recipient Address to add tokens to.
Expand Down Expand Up @@ -118,22 +108,30 @@ contract LegendsToken is ERC20 {
/**
* @dev Implements ERC20 transfer()
*/
function transfer(address _to, uint256 _value) isActive recipientIsValid(_to) senderHasSufficient(_value) returns (bool success) {
ownerVIP[msg.sender] -= _value;
ownerVIP[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
function transfer(address _to, uint256 _value) isActive recipientIsValid(_to) returns (bool success) {
if (ownerVIP[msg.sender] >= _value) {
ownerVIP[msg.sender] -= _value;
ownerVIP[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else {
return false;
}
}

/**
* @dev Implements ERC20 transferFrom()
*/
function transferFrom(address _from, address _to, uint256 _value) isActive recipientIsValid(_to) transferApproved(_from, _value) returns (bool success) {
ownerVIP[_to] += _value;
ownerVIP[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
function transferFrom(address _from, address _to, uint256 _value) isActive recipientIsValid(_to) returns (bool success) {
if (allowed[_from][msg.sender] >= _value && ownerVIP[_from] >= _value) {
ownerVIP[_to] += _value;
ownerVIP[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else {
return false;
}
}

/**
Expand Down