When running the following code within geth console, I am recieving the following error:

TypeError: 'deploy' is not a function

var storageContractAbi = storageOutput.contracts['contracts/29.sol:ethForAnswersBounty'].abi
var storageContract = new web3.eth.contract(JSON.parse(storageContractAbi))
var storageBinCode = "0x" + storageOutput.contracts['contracts/29.sol:ethForAnswersBounty'].bin

    data: storageBinCode,
    arguments: [29]
    from: eth.accounts[0],
    gas: 1000000

If I am reading the manual correctly, I am not sure what I am doing wrong here. https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#deploy

The contract is created fine if I call it this way:

var storageInstance = storageContract.new({
  from: eth.accounts[0],
  data: storageBinCode,
  gas: 1000000

Any help much appreciated as I would really like to use promises after the send().

  • Looks this is a typo, web3.eth.contract should have contract with capitcal C. Like this web3.eth.Contract.Try it and let me know if it is resolved. – Aniket Dec 28 '18 at 5:36
  • Thanks for the suggestion, this then causes "err: TypeError: 'Contract' is not a function". – craigmayhew Dec 28 '18 at 10:15
  • Geth version: 1.8.20 – craigmayhew Dec 28 '18 at 10:20
  • Have you used the complete new web3.eth.Contract? also is your web3 version 1.0.0.beta.** ? – Aniket Dec 28 '18 at 10:54
  • It appears geth 1.8.20 uses version "0.20.1" of web3. Unfortunately for me (if it's a geth issue) this web3 version appears to be baked into geth. I wasn't sure what you meant by "Have you used complete..." – craigmayhew Dec 28 '18 at 11:34

I think this might be a limitation in the current version of geth 1.8.20. I was using geth console and piping in the javascript from my original question.

I've now rewritten my deployment pipeline in nodejs so I can pull in web3@1.0.0-beta.37 and the exact same syntax is now working fine.

Hope this helps someone else out.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.