2

I run local private ethereum network using the below commands.

./geth --datadir=./data/test init genesis/genesis.json

./geth  --datadir=./data/test --rpc --rpccorsdomain "http://localhost:8000" --rpcapi "db,eth,net,web3,personal,miner"  --rpcaddr "localhost" --rpcport "8545"

I have installed chrome plugin for solidity Solidity realtime ethereum compiler and runtime.

I have below contract.

contract CalculatorV2 {

  uint result;

  event NumberAdded(uint n);
  event NumberSubtracted(uint n);
  event NumberMultiplied(uint n);
  event NumberDivided(uint n);

  function CalculatorV2(uint num) {
    // constructor
    result=num;
 }

  // returns the result
  function getResult() constant returns (uint){
   return result;
 }

  // result = result + num
  function addToNumber(uint num) returns (uint) {
   result += num;
    NumberAdded(num);
   return result;
 }

 // result = result - num
 function substractNumber(uint num) returns (uint) {
   result -= num;
   NumberSubtracted(num);
   return result;
 }

 // result = result * num
  function multiplyWithNumber(uint num) returns (uint) {
    result *= num;
    NumberMultiplied(num);
    return result;
  }

  // result = result / num
  function divideByNumber(uint num) returns (uint) {
    result /= num;
    NumberDivided(num);
    return result;
  }

}

Then I clicked the node icon on the right side and choose web3 provider with value 'http://localhost:8545'.

Authorization error

When I click create button, this gives to error Error: authentication needed: password or unlock.

I'm not sure where I've to save the authorize or login to compile and deploy the smart contract.

  • Not sure about this plugin, but with web3js, before makign a transac that requires to spend ether, you need to unlock the account that is doing the transaction with web3.eth.personal.unlockAccount(). Maybe there is something in your plugin to do something similar. Or you can try my command on your geth node – Florian Castelain Nov 13 '17 at 0:56
  • Andromelus - you are almost correct. Login to geth console and personal.unlockAccount(main_acct_id, paasword) worked. – Rajkumar Natarajan Nov 13 '17 at 1:08
  • So problem solved? – Florian Castelain Nov 13 '17 at 1:10
  • Andromelus - Yes. – Rajkumar Natarajan Nov 13 '17 at 1:42
3

You can also try like:

geth --datadir ~/ethereum-private-network/chaindata --nodiscover --rpc --rpccorsdomain "*" --unlock <addressWithoutQuotes> --password <passwordWithoutquotes>

or

geth --datadir ~/ethereum-private-network/chaindata --nodiscover --rpc --rpccorsdomain "*" --unlock <addressWithoutQuotes>

after this, you will get something like:

INFO [03-03|21:56:51] Starting peer-to-peer node               
instance=Geth/v1.7.3-stable-4bb3c89d/windows-amd64/go1.9
INFO [03-03|21:56:51] Allocated cache and file handles      
INFO [03-03|21:56:51] Disk storage enabled for ethash DAGs     
INFO [03-03|21:56:51] Initialising Ethereum protocol 
INFO [03-03|21:56:51] Loaded most recent local header
<some more information>
INFO [03-03|21:56:51] Starting P2P networking
INFO [03-03|21:56:51] RLPx listener up                         
INFO [03-03|21:56:51] HTTP endpoint opened: http://127.0.0.1:8545
Unlocking account 0x3230248b2c3dade18a183bb168fa6ff97fe5030f | Attempt 1/3
Passphrase: INFO [03-03|21:56:51] IPC endpoint opened: \\.\pipe\geth.ipc
<it will wait for few seconds here, type the password>
<some more information>
INFO [03-03|21:56:53] Mapped network port 
INFO [03-03|21:56:55] Unlocked account                        
address=0x3230248b2C3dADe18a183bB1E8Fa6ff97fE5030F

And the account will be unlocked.

2

When initialising your Geth nodes, make sure to unlock the account associated with them so that your Web3 provider can access all necessary functions.

e.g.

geth --identity "MyGethNode" --rpc --rpcport "8545" --rpccorsdomain "*" --datadir Library/Ethereum/dataDir --nodiscover --port "30310" --rpcapi "db,eth,net,web3" --networkid 161 --unlock 0 console

Notice --unlock 0, this is to prompt the user to unlock the account stored at the zeroth element in the eth.accounts array for that Geth node. You must have already created an account for this to work.

You can also do this manually like so:

enter image description here

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.