You have no tokens transfer functionality in the crowdsale contract, so tokens balance of the investor address can't be changed after investment. You should modify buy()
method and add tokens transfer functionality to it.
function buy ()
payable public
whenNotPaused
beforeDeadline
afterStartTime
saleNotClosed
{
require(msg.value >= minContribution);
uint amount = msg.value;
// Compute the number of tokens to be rewarded to the sender
// Note: it's important for this calculation that both wei
// and PDT have the same number of decimal places (18)
uint numTokens = amount.mul(rate);
// --- NEW CODE STARTS HERE -------------------------------------------
require(tokenReward.transfer(msg.sender, numTokens));
// --- NEW CODE ENDS HERE ---------------------------------------------
// update the total amount raised
amountRaised = amountRaised.add(amount);
// update the sender's balance of wei contributed
balanceOf[msg.sender] = balanceOf[msg.sender].add(amount);
// add to the token balance of the sender
tokenBalanceOf[msg.sender] = tokenBalanceOf[msg.sender].add(numTokens);
FundTransfer(msg.sender, amount, true);
// Check if the funding goal or cap have been reached
checkFundingGoal();
checkFundingCap();
}
In addition to make this code workable you should transfer some tokens cap to the crowdsale contract address. If you don't want to do that and want keep all tokens on some separate ASSET_MANAGER_WALLET
address, then you should approve
some tokens amount from this address to crowdsale contract address and instead of call transfer
function you should call transferFrom
function.
require(tokenReward.transferFrom(ASSET_MANAGER_WALLET, msg.sender, numTokens))