I want to create new contract using cpp-ethereum (built from source) and ethconsole. I followed this guide: https://www.ethereum.org/greeter.

I modified the contract to contain only one class without functions to minimize the gas cost:

contract greeter{   

I'm doing this on test network and I have 5 ether on my account.

Here's the js code that I got after using online Solidity compiler:

 web3.eth.getAccounts(function(err, accounts){
    var account = accounts[3];
    console.log("Using account: " + account);
    var greeterContract = web3.eth.contract([]);
    var greeter = greeterContract.new(
        from: account, 
        data: '6060604052600a8060106000396000f360606040526008565b00', 
        gas: 3000000
    }, function(e, contract){
        if (typeof contract.address != 'undefined') {
            console.log('Contract mined! address: ' + contract.address + ' transactionHash: ' + contract.transactionHash);

This is the output that I get:


For some reason, contract is not deployed, function returns no error and contract.address is undefined.

Am I missing something?

1 Answer 1


The guide has a different function:

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


Indeed, this function will be called twice.

  • The first time, it will be with the transaction hash. Do console.log(contract); to convince yourself.
  • The second time, it will be with the contract itself. Provided there is a node mining.
  • For some reason, the cpp-ethereum binaries that I've built from source did not include solidity compiler. I've downloaded 1.2.1 build, mentioned in this question: ethereum.stackexchange.com/questions/1793/… and I was able to execute code from the guide that you mentioned. It worked! Thanks.
    – Ren
    Commented Sep 1, 2016 at 8:08

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.