1

in the browser (I use nodejs with web3 and testrpc), I have:

var contract = new web3.eth.Contract(abi);

I have the following error:

TypeError: web3.eth.Contract is not a constructor

if I use a non capitalized "c"

var contract = new web3.eth.contract(abi);

I have:

contract: {
  "eth": {},
  "abi": [
    {
      "constant": true,
      "inputs": [],
      "name": "displayMessage",
      "outputs": [
        {
          "name": "",
          "type": "string"
        }
      ],
      "payable": false,
      "type": "function"
    },
    {
      "inputs": [],
      "payable": true,
      "type": "constructor"
    }
  ]
}

but later in my script:

var deployed = contract.new({
      from: account1,
      value: web3.toWei(3, 'ether'),
      data: bytecode,
      gas: gasEstimate,
      gasPrice: web3.eth.gasPrice
    }, (error, result) => { });

I have another error:

TypeError: this.eth.sendTransaction is not a function

Any idea of what is my problem ?

  • I do not see the line that creates the error this.eth.sendTransaction, did you paste all of your script? – Validity Labs - Sebastian May 3 '17 at 20:08
  • Have you tried var contract = web3.eth.contract(abi); (no new) ? – eth May 4 '17 at 5:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.