I have a private ethereum system with a couple of nodes. I'm trying to deploy a contract on one of them. To begin with, I am trying to just deploy a sample contract from the net. This is what I'm using:

pragma solidity ^0.4.24;
contract sample {
 string public name = "ZeonLab";
 function set(string _name) {
    name = _name;

 function get() constant returns (string) {
   return name;

I compile this with the solc compiler and get the ABI and bytecode by running solc --abi and solc --bin respectively. I then try to deploy the contract on geth as follows: geth console

> var test = eth.contract('abi text above')

It however gives me an undefined error. in fact, instead of the ABI text from above, if I just do: var test = eth.contract('test'), I still see an error.

I read somewhere that we need to do: var testTxt = JSON.parse('abi text above') However, that did not work either.

From the error, it looks like there may be an issue with recognizing eth.contract itself. When I type eth on the console, I see that contract is one of the options.

Any suggestions on what could b wrong.

thx - anand

  • i don't have the exact answer to your question. but i have alternative option but you can use truffle for deployment .
    – AVATAR
    Commented Sep 26, 2018 at 9:28

2 Answers 2


Thanks! I will try truffle.

In the meantime, I also figured out that this (so-called) error does not matter. In fact, when I type: var test = eth.contract('abi text above') and I type test after that, I see the desired result.


Following code should solve your problem.

var contract_name = new web3.eth.Contract('YOUR ABI', 'YOUR CONTRACT ADDRESS')

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.