10

For the past 7 days I've been trying to make the greeter contract, I've been through 4 different physical computers in 2 different locations and have tried multiple different ways on 3 different operating systems.

I've attempted all the tries above with both the geth and c++ eth client, I've also made attempts with the online web compiler and mix.

After 7 days, I have not been able to create any contract yet, I'm attempting to follow the https://www.ethereum.org/greeter page so I can move onto the other tutorial exercises to complete the exercises on the ethereum.org page.

I'm following the page instructions verbatim line-by-line and directly copying what it tells me to copy, and I've managed to get as far as compiling the contract and telling it to deploy. It asks me for my account password and I enter it which it then completes. My account does have ethereum in it.

But the problem is the instructions say the greeter variable is suppose to contain an address you can track on the network as its being mined or completed and it does contain an address but the address is undefined, it remains undefined indefinitely. Also my account is never deducted any currency, the account value remains the same. Of course this means

eth.getCode(greeter.address)

Also errors out as it can't get a code to an undefined address. This baffles me and so far I haven't been able to find any help anywhere on this. I just assumed it was a software bug and that probably not very many people have created contracts but then I saw a ethereum youtube video saying there were like 500,000 contracts and it seems the community is very vibrant with contract design so what could I possibly be missing thats causing this error.

In case your wondering, my latest attempt is on Mac OSX with the geth client but I have access to Windows and Linux as well as the c++ eth client if need be.

2
  • Are you sure it is your first account that has the ether? web3.fromWei(eth.getBalance(eth.accounts[0])) should return more than 0.002 or so. Feb 17, 2016 at 22:38
  • same problem here, but for testnet. but for testnet, i got 4 ether from faucet.
    – TMOTTM
    Jun 13, 2016 at 19:30

4 Answers 4

2

I think you meant to say that your account has ether in it, not ethereum.

My first guess is that you don't have enough ether. Try

web3.fromWei(eth.getBalance(eth.coinbase),'ether')

You might need something like 0.001 ether (just a guesstimate) to deploy your contract successfully.

When you deploy, you will get a transaction hash, which is a lot longer than a ethereum address. Take this hash and run

eth.getTransactionReceipt("0x00000.......")

Substituting the 0x00000........ with your transaction hash. Look for the contract address and gasUsed in the output. If there is no contract address, chances are that you did not have enough funds to deploy the contract.

Try this modified version of the example:

var _greeting = "Hello World!"
var greeterContract = web3.eth.contract(greeterCompiled.greeter.info.abiDefinition);

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);
        }

     } else {
          console.log("Error!!");
          console.log(e);
     }
})
1
  • Ah sorry didn't mean to leave those details out. I have 0.01 ether in my account and I receive no transaction hash, after the greeterContract.new step it asks for my password and then returns an object with one property, address which is undefined > greeter { address: undefined } Feb 5, 2016 at 15:13
1

Something during the greeterContract.new step is not working.

1) Make sure the units are looking at are actually Ether: web3.fromWei(eth.getBalance(eth.accounts[0]),'ether').

2) Also make sure that the account used in the contract is the one with the Ether ( eth.accounts[0] ).

3) Make sure you're typing in the correct password (and password of correct account).

Any of these mistakes would give the results you're experiencing.

3
  • I created a new account just to start over clean, transferred 0.005 ether into it. web3.fromWei(eth.getBalance(eth.accounts[1]),'ether') shows 0.005. I used personal.unlockAccount with the second account and password to double check correct password and returns true. I ensure greeterContract.new uses the second account from:web3.eth.accounts[1]. After all that it still returns an object with address: undefined. So far, after about 2 months, I'm still waiting to release my first contract. Do you have any other ideas? Feb 19, 2016 at 7:20
  • I'm having the same problem. Verified I have ether in account, followed the tutorial example steps, even tried the modified contract given above. The command line does return a txn hash saying 'waiting to be mined,' which appears in the blockchain explorer: 0x8a8abcb23e486558e21c1bb3e6e807494c01a948a03970989981ae94486ab224, but the function does not operate. In one attempt, I received back "Import Failure InvalidBlockFormat." No solution yet. Feb 29, 2016 at 12:55
  • @BillLaPrise if you are getting transaction hash, check that is this transaction pending to mine by using " eth.pendingTransactions". If there is one with the same txn hash, you need to mine using "miner.start()" in case of Geth.
    – Aniket
    Jul 28, 2016 at 5:48
1

Did you mine?

If you're running a private network, another thing some people forget to do as well is to actually mine on the network for the transaction to be processed.

So if you're on geth just miner.start()

1
  • I'm not on a private network or mining Feb 19, 2016 at 7:21
1

I have just added a step-by-step example of running the greeter example documented in Deploying the Greeter contract via the geth CLI is not registering in my private blockchain .

This guide provides you with the commands to run and shows you the expected outputs at each step so you can confirm that you are running the Greeter example correctly.

1
  • do you think you could add some hints on how to do the same thing with testnet?
    – TMOTTM
    Jun 13, 2016 at 19:30

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.