0

This is the function I used to transfer the ethets:

function addBalance(address beneficiary) payable returns(bool success){ if (beneficiary.send(msg.value)) throw; return true; }

Call to the function using web3:

contract.addBalance.sendTransaction(contractAddress, 
        {from: senderAddress, to: contractAddress, gas:1000000, value: web3.toWei(7, "ether")},function (error, result){ 
            if(!error){

                } else{
                    console.log(error);
                }
        });

OR

contract.addBalance.sendTransaction(contractAddress, 
        {from: web3.eth.accounts[5], to: contractAddress, gas:1000000, value: web3.toWei(7, "ether")},function (error, result){ 
            if(!error){
                } else{
                    console.log(error);
                }
        });

When I call this It gives error Saying:

Error: authentication needed: password or unlock
at Object.InvalidResponse (errors.js:35)
at requestmanager.js:86
at XMLHttpRequest.request.onreadystatechange (httpprovider.js:118)

I have already unlocked my account If I change the sender address with address of coinbase it works fine, but not working with any other account address

The call which works fine is bellow :

contract.addBalance.sendTransaction(contractAddress, 
        {from: web3.eth.coinbase, to: contractAddress, gas:1000000, value: web3.toWei(7, "ether")},function (error, result){ 
            if(!error){

                } else{
                    console.log(error);
                }
        });  
1

You have to unlock the account where you send the ethers from:

personal.unlockAccount(eth.accounts[0])

and insert the password in the geth console.

  • Thank you very much, It works, I haven't unlocked that particular account and try to transfer money from it, and hence it shows the error – SwapnilKumbhar Mar 23 '17 at 9:28

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.