1

I am using this tutorial to create a hello world contract. I am on solidity 0.4.9, and I am trying to deploy the contract after compiling it. However, the compiled version is different.

Here is the content of the variable that is output after I run

compiled = web3.eth.compile.solidity(code);


{
<stdin>:greeter: {
code: "0x6060604052341561000c57fe5b6040516102f03803806102f0833981016040528051015b5b60008054600160a060020a03191633600160a060020a03161790555b805161005390600190602084019061005b565b505b506100fb565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061009c57805160ff19168380011785556100c9565b828001600101855582156100c9579182015b828111156100c95782518255916020019190600101906100ae565b5b506100d69291506100da565b5090565b6100f891905b808211156100d657600081556001016100e0565b5090565b90565b6101e68061010a6000396000f300606060405263ffffffff60e060020a60003504166341c0e1b5811461002c578063cfae32171461003e575bfe5b341561003457fe5b61003c6100ce565b005b341561004657fe5b61004e610110565b604080516020808252835181830152835191928392908301918501908083838215610094575b80518252602083111561009457601f199092019160209182019101610074565b505050905090810190601f1680156100c05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000543373ffffffffffffffffffffffffffffffffffffffff9081169116141561010d5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b6101186101a8565b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561019d5780601f106101725761010080835404028352916020019161019d565b820191906000526020600020905b81548152906001019060200180831161018057829003601f168201915b505050505090505b90565b604080516020810190915260008152905600a165627a7a72305820185eef7bf7be0536efd43f004e773e64d2235c4693a805b3a10b37cba246b4920029",
info: {
  abiDefinition: [{...}, {...}, {...}],
  compilerOptions: "--combined-json bin,abi,userdoc,devdoc --add-std --optimize",
  compilerVersion: "0.4.9",
  developerDoc: {
    methods: {}
  },
  language: "Solidity",
  languageVersion: "0.4.9",
  source: "contract mortal {    /* Define variable owner of the type address*/    address owner;    /* this function is executed at initialization and sets the owner of the contract */    function mortal() { owner = msg.sender; }    /* Function to recover the funds on the contract */    function kill() { if (msg.sender == owner) selfdestruct(owner); }}contract greeter is mortal {    /* define variable greeting of the type string */    string greeting;    /* this runs when the contract is executed */    function greeter(string _greeting) public {        greeting = _greeting;    }    /* main function */    function greet() constant returns (string) {        return greeting;    }}",
  userDoc: {
    methods: {}
  }
}
},
<stdin>:mortal: {
code: "0x6060604052341561000c57fe5b5b60008054600160a060020a03191633600160a060020a03161790555b5b609c806100386000396000f300606060405263ffffffff60e060020a60003504166341c0e1b581146020575bfe5b3415602757fe5b602d602f565b005b6000543373ffffffffffffffffffffffffffffffffffffffff90811691161415606d5760005473ffffffffffffffffffffffffffffffffffffffff16ff5b5b5600a165627a7a72305820943259e888cd7687a7a232ef1f27f34e353449a6a3ce03d147297f7fe410d3580029",
info: {
  abiDefinition: [{...}, {...}],
  compilerOptions: "--combined-json bin,abi,userdoc,devdoc --add-std --optimize",
  compilerVersion: "0.4.9",
  developerDoc: {
    methods: {}
  },
  language: "Solidity",
  languageVersion: "0.4.9",
  source: "contract mortal {    /* Define variable owner of the type address*/    address owner;    /* this function is executed at initialization and sets the owner of the contract */    function mortal() { owner = msg.sender; }    /* Function to recover the funds on the contract */    function kill() { if (msg.sender == owner) selfdestruct(owner); }}contract greeter is mortal {    /* define variable greeting of the type string */    string greeting;    /* this runs when the contract is executed */    function greeter(string _greeting) public {        greeting = _greeting;    }    /* main function */    function greet() constant returns (string) {        return greeting;    }}",
  userDoc: {
    methods: {}
  }
}
}
}

Then when I run

var contract = web3.eth.contract(contract.greeter.info.abiDefinition);

I get an error

TypeError: Cannot access member 'info' of undefined

The error is understandable because the compiled object does not directly have a "greeter". It has "<stdin>:greeter".

What do I do?

marked as duplicate by Rob Hitchens - B9lab, Roland Kofler, Waqar Lim Feb 9 '17 at 11:35

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.