I'm trying to figure out how to deploy a contract with web3 in version 1.0.0-beta.11, and I don't know if I'm hitting a bug in web3, an incompatibility issue with the version of solc I'm using, or if I'm just doing something wrong.

I'm using the latest version of solc released on NPM: 0.4.13. I'm trying to deploy the following contract:

contract Greetings {
    string message;

    function Greetings() {
        message = "I am ready!";

    function setGreetings(string _message) public {
        message = _message;

    function getGreetings() constant returns (string) {
        return message;

with the following series of instructions run in a node console:

sourceCode = fs.readFileSync('Greetings.sol').toString()
compiledCode = solc.compile(sourceCode)
contractABI = JSON.parse(compiledCode.contracts[':Greetings'].interface)

[ { constant: false,
inputs: [ [Object] ],
name: ‘setGreetings’,
outputs: [],
payable: false,
type: ‘function’,
signature: ‘0x49da5de4’ },
{ constant: true,
inputs: [],
name: ‘getGreetings’,
outputs: [ [Object] ],
payable: false,
type: ‘function’,
signature: ‘0xca4c3a41’ },
{ inputs: [],
payable: false,
type: ‘constructor’,
signature: ‘constructor’ } ]

contract = new web3.eth.Contract(contractABI)
byteCode = compiledCode.contracts[':Greetings'].bytecode
contract.deploy({data: byteCode, arguments:[]}).send({from: '0x00D1AE0A6fC13B9ecdefA118B94cF95ac16D4ab0', gas: 4700000}).on('error', function(error){console.error(error);}).then(function(newContractInstance){console.log(newContractInstance.options.address)})

and there on the last one, I'm getting the following cryptic error:

TypeError: Cannot read property 'length' of undefined
    at /Users/jdoe/myproject/node_modules/web3/packages/web3-eth-contract/src/index.js:356:43

any idea what I'm doing wrong?

  • What is value of contractABI as of the fourth line? Commented Jul 25, 2017 at 21:25
  • Updated the question to show the contract ABI
    – Sebastien
    Commented Jul 26, 2017 at 7:07
  • Is there more to the stack trace than that, or just that one line? Commented Jul 26, 2017 at 22:16
  • I have an error while i am trying to deploy smart contract in my private blockchain using node server showing error cannot read property 'address' of undefined.
    – prasanna
    Commented Aug 10, 2017 at 19:33

1 Answer 1


Seems like you're being bitten by #948. Also see this other question. Should be resolved in -beta.12, apparently

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.