0

I had created 100 million tokens and created a contract for crowdsale in test network

If user sends a 1 ether using contract address i am able to receive 1 ether and send 1000 tokens to user who send via metamask.

https://ropsten.etherscan.io/address/0x44db21d5cc6a773ec7ec68d5059e88325cc2a5a6

When user sends 1 ether i am getting 1 ether in my account and able to send 1000 tokens to user, but in my balance 1000 tokens were not reducing in my account

which function do i need to use to update crowdsale token balance in admin in metamask

2
  • Without the source code of the contract is impossible to tell, but usually if the tokens are minted to the crowdsale address executing token.transfer(msg.sender, token_amount); is the way.
    – Ismael
    Commented Sep 5, 2017 at 14:15
  • Sometimes changing MetaMask network to any then changing it back helps me to see the relevant token balance.
    – someart
    Commented Sep 5, 2017 at 20:45

3 Answers 3

0

MetaMask updates token balances on every block, so if its balances aren't updated, it's probably a problem with your smart contract, not with MetaMask.

0

The token transfer function is responsible of decreasing the balance of the sender and increase the balance of the recipient. Check the code of this function, or share it for us with your question.

0

In case there is an error in your code, a typical ERC20 token transfer function that uses the SafeMath library looks like so:

function transfer(address _to, uint256 _value) public returns (bool success) {
    require(balances[msg.sender] >= _value && _to != 0x0);
    balances[_to] = balances[_to].add(_value);
    balances[msg.sender] = balances[msg.sender].sub(_value);
    Transfer(msg.sender, _to, _value);
    return true;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.