0

I'm struggling with transferring my own ERC20 Token.

I got following code:

contract AccountingToken is ERC20, ERC20Detailed {
constructor () public ERC20Detailed("AccountingToken", "MAC", 18) {
        _mint(msg.sender, 10000 * (10 ** uint256(decimals())));
    }
}

contract Accounting{
AccountingToken instance=AccountingToken(0x000...);

function get_balance()public view returns(uint){
        uint balance;
        balance=instance.balanceOf(msg.sender);
        return balance;
    }
function transfer_to_contract(uint tokens)public{
        address receiver=0x..receiver_address;
        instance.transfer(receiver,tokens);
}
}

Running the get_balance() function gives me the correct amount back.

But running the transfer() function always ends in a JSON-RPC error.

What am I doing wrong?

Thanks!

  • What parameters are you sending to transfer()? What's the error you get? – user19510 Sep 19 at 16:34
  • Found the problem... Tried to send money from a contract that hadn't got the amount of token. So it was a careless mistake... – Moodai Sep 20 at 9:36
0

Found the problem... Tried to send money from a contract that hadn't got the amount of token. So it was a careless mistake...

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.