From ab9eecb104ae948bf406f301ecb4f323a88ff131 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Mon, 20 Mar 2017 17:18:41 -0300 Subject: [PATCH] 6.1 fix stuck Ether in Crowdsale contract --- contracts/token/CrowdsaleToken.sol | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/contracts/token/CrowdsaleToken.sol b/contracts/token/CrowdsaleToken.sol index c10d08808..062bf9d34 100644 --- a/contracts/token/CrowdsaleToken.sol +++ b/contracts/token/CrowdsaleToken.sol @@ -8,15 +8,20 @@ import "./StandardToken.sol"; * CrowdsaleToken * * Simple ERC20 Token example, with crowdsale token creation + * IMPORTANT NOTE: do not use or deploy this contract as-is. + * It needs some changes to be production ready. */ contract CrowdsaleToken is StandardToken { - string public name = "CrowdsaleToken"; - string public symbol = "CRW"; - uint public decimals = 18; + string public constant name = "CrowdsaleToken"; + string public constant symbol = "CRW"; + uint public constant decimals = 18; + // replace with your fund collection multisig address + address public constant multisig = 0x0; + // 1 ether = 500 example tokens - uint PRICE = 500; + uint public constant PRICE = 500; function () payable { createTokens(msg.sender); @@ -28,9 +33,13 @@ contract CrowdsaleToken is StandardToken { } uint tokens = safeMul(msg.value, getPrice()); - totalSupply = safeAdd(totalSupply, tokens); + balances[recipient] = safeAdd(balances[recipient], tokens); + + if (!multisig.send(msg.value)) { + throw; + } } // replace this with any other price function