0

I want to invoke a send transaction from my nodejs code using web3js api. But I'm getting error at eth.sendTransaction step: invalid address. I have added default account assignment after looking at some other posts. But still the same error. Any clue?

bcConn.eth.defaultAccount = bcConn.eth.accounts[0];
var defaultFlag = bcConn.personal.unlockAccount(bcConn.eth.accounts[0], '***whatever***', 15000);
if (defaultFlag) {

    var unlockFlag = bcConn.personal.unlockAccount(fromAddress, passphrase, 15000);
    if (unlockFlag) {

        **bcConn.eth.sendTransaction(fromAddress, toAddress, passphrase, sendAmount, function (err, result)** {
            if (err) return next(err, null);
            return next(null, result);
        });
    } else {
        console.log('DAO unlock error: ' +err);
        return next(err, null);        
    }
}
0

Because sendTransaction method has only a json param, so i modified it, as follows:

bcConn.eth.defaultAccount = bcConn.eth.accounts[0];
var defaultFlag = bcConn.personal.unlockAccount(bcConn.eth.accounts[0], '***whatever***', 15000);
if (defaultFlag) {

    var unlockFlag = bcConn.personal.unlockAccount(fromAddress, passphrase, 15000);
    if (unlockFlag) {

        **bcConn.eth.sendTransaction({from:fromAddress,to:toAddress,value:sendAmount}, function (err, result)** {
            if (err) return next(err, null);
            return next(null, result);
        });
    } else {
        console.log('DAO unlock error: ' +err);
        return next(err, null);        
    }
}

Hope it works~

| improve this answer | |
0

You should be specifying an object rather than a list of arguments to sendTransaction:

bcConn.eth.sendTransaction({from:fromAddress, to:toAddress, value:sendAmount}, function (err, result){...})

Note that I've removed passphrase here - it's not needed.

| improve this answer | |

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.