A few possibilities:
price
could be 0, resulting in a divide-by-zero.
price
could be such that noOfTokens
is greater than the remaining tokens.
- If neither of those are stopping things first,
client.transfer(noOfTokens)
probably is.
client.transfer(noOfTokens)
tries to transfer ether to client
. The amount of ether attempted in the transfer is noOfTokens
wei. I see no reason to expect the contract to have that much ether.
You probably want this (msg.value
instead of ethval
) and transferring that much to client
:
function sendToken() payable
{
testDebug("Before",client,totalSupply,investors[msg.sender]);
assert(remaining < totalSupply);
uint noOfTokens = msg.value / price;
assert(noOfTokens < totalSupply-remaining);
investors[msg.sender] = noOfTokens;
remaining = remaining+noOfTokens;
testDebug("After",client,remaining,noOfTokens);
client.transfer(msg.value);
}
Just be sure to actually transfer ether when you call sendToken()
. (You can set the amount of ether sent with the transaction in the upper right in Remix with the "value" field.)
Best Answer
This error jumps out for some (unpredictable) reasons when, may be, the internal remix ide stack is corrupted and/or your deployment silently fails.
Very often if you save, exit and reload it does not appear anymore.
If it appears again and again with your code, try to save/exit/reload and then deploy it again using a 10x gas limit.
I encountered this problem in 0.6.3 and 0.6.4 (currently online) version of remix ide. I hope it will be fixed for the next 0.7.0 (that is the alpha version today).
In these cases it is a system error, anyway. Your code is not affected if not for the amount of gas required in order to deploy it.