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);
        }
    }
); 
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);
}
});
  • thanks for your answer. Unfortunately I receive an empty array from accounts – Barney Chambers Sep 2 at 9:37

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.