I've tried
contract OToken {
using SafeMath for uint256;
uint public _totalSupply = 0;
uint public constant _cap = 100000000;
string public constant symbol = "OXN";
string public constant name = "OToken";
uint public constant decimals = 18;
uint public oneTokenInWei = 183.602;
If I want the token price to be $0.02 each and 1 eth is trading at $167 then 1 wei = 183.602 tokens
I can call this function if I want to change the price per token to .03
function setOneTokenInWei(uint w) onlyOwner {
oneTokenInWei = w;
changed(msg.sender);
}
then this function to create the token
function createTokens() payable{
require(
msg.value > 0
&& _totalSupply < _cap
&& CROWDSALE_PAUSED <1
);
uint multiplier = 10 ** decimals;
uint256 tokens = msg.value.mul(multiplier) / oneTokenInWei;
balances[msg.sender] = balances[msg.sender].add(tokens);
_totalSupply = _totalSupply.add(tokens);
owner.transfer(msg.value);
}
this is not adding the current value to the senders wallet