I deployed a smart contract for crowdsale that has a function of receiveETH():
function receiveETH(address beneficiary) internal {
uint coinToSend = bonus(msg.value.mul(COIN_PER_ETHER).div(1 ether)); // Compute the number to send
Backer backer = backers[beneficiary];
coin.transfer(beneficiary, coinToSend); // Transfer right now
backer.coinSent = backer.coinSent.add(coinToSend);
backer.weiReceived = backer.weiReceived.add(msg.value); // Update the total wei collected during the crowdfunding for this backer
etherReceived = etherReceived.add(msg.value); // Update the total wei collected during the crowdfunding
coinSentToEther = coinSentToEther.add(coinToSend);
// Send events
LogCoinsEmited(msg.sender ,coinToSend);
LogReceivedETH(beneficiary, etherReceived);
}
this contract I have deployed on testnet, but it could not receive ether. For example, I use some test accounts to send ether to that deployed smart contract address, everytime it says success on etherscan and the Tx cost is deducted, while the ether is not successfully transferred and smart contract ether amount remains 0. link
I wonder what's wrong here? Does crowdsale contract has a function that's triggered everytime a new transfer comes in?
P.S. just noticed I have the fallback function defined:
function() stopInEmergency respectTimeFrame payable {
receiveETH(msg.sender);
}
it looks perfect for me, but still my contract does not receive ether when I try to send to it. What else is wrong here?