1

From Past 3 Days I am trying to deploy my 1st greeter contract But always I am getting the Undefined greeter.address. Below Steps I am following

1) geth Version

C:\Block_Chain\Eth_1>geth version
Geth
Version: 1.4.9-stable
Protocol Versions: [63 62 61]
Network Id: 1
Go Version: go1.6.2
OS: windows
GOPATH=
GOROOT=c:\go

2) Created coinbase account

3) Initialised A New Chain

geth init genesis.json

4) Start geth

geth --testnet --datadir "C:\Block_Chain\Eth_1\testdir" --unlock 0  --networkid 5 --port 8081  console

5) Start Mining

miner.start(1)

6) Check Ethers

> web3.fromWei(eth.getBalance(eth.accounts[0]).toNumber(), "ether")
"1947.1775"

6) Using Browser compiler -> Compiled the contract

personal.unlockAccount(eth.accounts[0], "test");
var greeterCompiled = '0x60606040526040516102cd3803806102cd8339016040526060805160600190602001505b806001600050908051906020019082805482825590600052602060002090601f016020900481019282156071579182015b8281111560705782518260005055916020019190600101906054565b5b50905060989190607c565b8082111560945760008181506000905550600101607c565b5090565b50505b50610222806100ab6000396000f30060606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b51461004f578063cfae32171461005c578063f1eae25c146100d55761004d565b005b61005a600450610110565b005b6100676004506101a4565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f1680156100c75780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e06004506100e2565b005b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b565b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156101a157600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60206040519081016040528060008152602001506001600050805480601f0160208091040260200160405190810160405280929190818152602001828054801561021357820191906000526020600020905b8154815290600101906020018083116101f657829003601f168201915b5050505050905061021f565b9056'

var greeterABI = [{"constant":false,"inputs":[],"name":"kill","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"greet","outputs":[{"name":"","type":"string"}],"type":"function"},{"constant":false,"inputs":[],"name":"mortal","outputs":[],"type":"function"},{"inputs":[{"name":"_greeting","type":"string"}],"type":"constructor"}];

var greeterContract = web3.eth.contract(greeterABI);

var greeter = greeterContract.new(_greeting,{from:web3.eth.accounts[0], data: greeterCompiled, gas: 300000}, function(e, contract){
    if(!e) {
      if(!contract.address) {
        console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
      } else {
        console.log("Contract mined! Address: " + contract.address);
        console.log(contract);
      }
    }
})

Output : I0830 13:43:31.602619 eth/api.go:1191]  Tx(0xbf65e574f03b7b923b5687a28b10c11396d7ae577d747b27af1fd00cf88fe6d9) created: 0x51b72c11e3ece5bfd923d80cb3ad8d75b676938b
Contract transaction send: TransactionHash: 0xbf65e574f03b7b923b5687a28b10c11396d7ae577d747b27af1fd00cf88fe6d9 waiting to be mined...

Any Idea what I am doing wrong. Any help will be highly appreciated.

  • There is a step-by-step guide to deploying the greeter contract at ethereum.stackexchange.com/questions/2751/… – The Officious BokkyPooBah Aug 30 '16 at 9:37
  • Thank You for you your help, Now I am able to successfully deploy the contracts. One more help I need , I am doing below ether txn from one account to another , But balance is not updating in 2nd account var sender = eth.accounts[0]; var receiver = eth.accounts[1]; var amount = web3.toWei(0.06, "ether"); eth.sendTransaction({from:sender, to:receiver, value: amount}) > web3.fromWei(eth.getBalance(eth.accounts[1]).toNumber(), "ether") "0" – Akash Sagar Aug 30 '16 at 11:10
  • You are using --testnet with --networkid. Try replacing --testnet with --dev. You can also remove --networkid. Use a new clean directory so you can create a new chain. – The Officious BokkyPooBah Aug 30 '16 at 11:50
  • When you --unlock 0, should you not add --password password.txt? – Xavier Leprêtre B9lab Aug 30 '16 at 13:55
  • Thank you , It is working fine now. but I am facing problem for connecting to peer in same network both are in dev Env : > admin.addPeer("enode://3a3862384c67eecb8fdd5e46279656bae2a198565bb9c9bd895246c953d307e00adc2b7d385ed005ac37469d00be827cc90e42915d01131447a2e4433a8f3} true > net.peerCount 0 – Akash Sagar Sep 2 '16 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.