0

I have follow this SO answer for sending ERC20 tokens from 1 address to another. I am running into an issue where I am receiving an error that my from address is invalid

Error: Error: WalletMiddleware - Invalid "from" address.

The from address works just fine when I use the web3 function contract.balanceOf, so I am not sure why it says my address is invalid

Here is my code:

 contract.transfer(
    '0x002FaCf5B2e8441c7ECb4eb6dCfD9C7b46320c97', //toaddress
    web3.toWei(1, "ether"),      //send 1 token
    {
        from:'0xb8fd65fc6919c5b97453eaba6b895144597985b2' //fromaddress
    }, function(err, transactionHash)
    {
        if(!err)
        {
            console.log(transactionHash);
        }
        else
        {
            console.log(err);
        }
    }
); 
1
  • Can you share the code where you use getAccounts() ? Your question does not seem to match with your description, please make the connection between those two points.
    – kuzdogan
    Feb 4, 2020 at 12:25

1 Answer 1

0

I didn't see where web3.eth.getAccounts() is used in your code, but this is javascript promise and you might wanna use it this way to get the accounts:

web3.eth.getAccounts(function(error, accounts) {
if(error) {
    console.log(error);
} else {
    console.log(accounts);
}
});
1
  • thanks for your answer. Unfortunately I receive an empty array from accounts Sep 2, 2019 at 9:37

Your Answer

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

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