3

I'm attempting to run the greeter contract on the live network. I'm following the commands as per the official tutorial, which worked on a test network when I tried it a while ago (on a different machine).

On entering the commands I'm getting an undefined response, though all variables are correctly defined when manually called on the console.

On entering the final var greeter, I'm correctly prompted for the passphrase of the account being used, which seems to go through. However, the pasted script itself doesn't seem to be called - there's no console log output.

Any ideas what I've missed out?

[Note: There's plenty of ether in the account being used.]

[Note2: The console has truncated long lines in the below log. I've confirmed they copied correctly.]

> {g) public { greeting = _greeting; } function greet() constant returns (string) { return greeting; } }'
undefined
> 
> var greeterCompiled = web3.eth.compile.solidity(greeterSource)
undefined
> var _greeting = "Reason has always existed, but not always in a reasonable form."
undefined
> var greeterContract = web3.eth.contract(greeterCompiled.greeter.info.abiDefinition);
undefined
> {,{from:web3.eth.accounts[0], data: greeterCompiled.greeter.code, gas: 1000000}, function(e, contract){
         if(!e) {

               if(!contract.address) {
               {saction send: TransactionHash: " + contract.transactionHash + " waiting to be mined  .");

                   } else {
                     console.log("Contract mined! Address: " + contract.address);
                     console.log(contract);
                   }

             }
       })
Please unlock account <account_address_removed>.
Passphrase: 
Account is now unlocked for this session.
undefined
8
  • Are you sure that geth is synced? Feb 12, 2016 at 21:04
  • Yes - I've got the logs ticking away in an attached window. Feb 12, 2016 at 21:10
  • did you try web3.eth.defaultAccount = web3.eth.accounts[0] ?
    – jayD
    Feb 12, 2016 at 21:19
  • By the way it is your actually code ? are you trying to run the contract for the first time ? cause it looks incorrect if you do var greeter = greeterContract.new(_greeting,{from:web3.eth.accounts[0], data: greeterCompiled.greeter.code, 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); } } })
    – jayD
    Feb 12, 2016 at 21:27
  • 2
    undefined in javascript isn't a bad thing. Variable declarations always return undefined, its nothing to worry about. Feb 14, 2016 at 6:51

1 Answer 1

1

Please refer to Deploying the Greeter contract via the geth CLI is not registering in my private blockchain for a step-by-step guide for running the greeter example in your local dev blockchain.

The commands and the expected outputs in the Window #2 sections in the link above should be very similar in the live network.

And the undefined messages are expected and does not signal an error condition as stated in the comments by Tjaden Hess above.

You should see the Contract transaction send message with a transaction hash

var greeter = greeterContract.new(_greeting,{from: eth.accounts[0], data: greeterCompiled.greeter.code, gas: 4000000}, 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);     }    } })
Contract transaction send: TransactionHash: 0x90d201388971770036898a7a22ab252cb0bf3c556f988a7b87583315cdaf58bc waiting to be mined...
undefined

If you don't see the following Contract mined! message, you may have to increase the gas value in your transaction sending message:

Contract mined! Address: 0x083628160c1cf218d14f2f0998c7a8dc72aec180
[object Object]
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.