0

Trying to execute a contract function with web3 1.2.1. I have an Erc20 standard token.

mintCoin: function(amount, sender, callback) {

    console.log(contractInstance.options.address); //all good
    console.log(sender);

    contractInstance.methods.mint(amount, sender).send({from:sender})
        .then(() => callback("202"))
        .catch(function(e) {
            console.log(e);
            callback("400 " + e);
        });
}

Error: invalid address (arg="account", coderType="address", value="50000") at Object.throwError ...

I think I'm mistaken in the syntax... any help?

8
  • So what does console.log(sender) tell you? Sep 16 '19 at 15:47
  • It shows me the address that I pass through postman
    – Agus Velez
    Sep 16 '19 at 15:50
  • Yeah I understand that part, but what does it actually show? Sep 16 '19 at 15:50
  • 0x1C3a56Ff8EE71304818E9E590E16F805048724f4 it gives me the value, it doesn't say undefined
    – Agus Velez
    Sep 16 '19 at 15:51
  • 1
    @goodvibration's answer seems to be correct. Sep 16 '19 at 15:57
1

Function mint takes address to as the 1st argument and uint256 amount as the 2nd argument.

You are passing them in reversed order (and web3 tells you that your amount is an invalid address).

2
  • Thank you, I can't believe it was that, I didn't realize
    – Agus Velez
    Sep 16 '19 at 15:59
  • @AgusVelez: No problem. Sep 16 '19 at 16:01

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.