1

enter image description hereenter image description hereenter image description here

Can anyone explain the above pics?

I sent 98,200 tokens. It was successful. But my qty and the receivers qty are doubled.

Please Help!!??!!

  • For those trying to follow along, here's a link to the token contract: etherscan.io/address/0x944fb74240b9ebd8dd48fb119b66a5d4994c2852. – user19510 Feb 9 '18 at 20:24
  • I'm assuming you deployed the contract. Does that mean you have the source code for it? If so, please share it. The source code has not be published on Etherscan, which makes it pretty hard to investigate. – user19510 Feb 9 '18 at 20:24
  • I have published it - just waiting for etherscan to approve it. I will post it at our site address: ameritoken.com/erc20-ameritoken-code – Todd Oswald Feb 9 '18 at 23:29
  • I tried to post it here, but was too long.. Thank Guys for any help. Apparently biysync.io is having the same issue. They dont have an answer either. – Todd Oswald Feb 9 '18 at 23:30
1

From the source code, every transfer is effectively done twice. transfer updates the balances and then calls _transfer, which does it again:

function _transfer(address _from, address _to, uint _value) internal {
    require(_to != 0x0); // Prevent transfer to 0x0 address. Use burn() instead
    require(balanceOf[_from] >= _value); // Check if the sender has enough
    require(balanceOf[_to] + _value > balanceOf[_to]); // Check for overflows
    uint previousBalances = balanceOf[_from] + balanceOf[_to]; // Save this for an assertion in the future
    balanceOf[_from] -= _value; // Subtract from the sender
    balanceOf[_to] += _value; // Add the same to the recipient
    Transfer(_from, _to, _value);
    assert(balanceOf[_from] + balanceOf[_to] == previousBalances); // Asserts are used to use static analysis to find bugs in your code. They should never fail
}

function transfer(address _to, uint256 _value) public returns (bool) {
    if (balanceOf[msg.sender] >= _value) {
        balanceOf[msg.sender] -= _value;
        balanceOf[_to] += _value;
        _transfer(msg.sender, _to, _value);
        return true;
    }
    return false;
}

It seems like the simplest fix would be to modify transfer:

function transfer(address _to, uint256 _value) public returns (bool) {
    if (balanceOf[msg.sender] >= _value) {
        _transfer(msg.sender, _to, _value);
        return true;
    }
    return false;
}
| improve this answer | |
  • You know how dumb I feel right now? Thank you sooo much for this! – Todd Oswald Feb 9 '18 at 23:50
  • Is there a way to update a contract once it has been deployed? Maybe a newby question, but I need to ask.. – Todd Oswald Feb 9 '18 at 23:51
  • No, contract code can't be changed after deployment. – user19510 Feb 9 '18 at 23:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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