Whenever I try and make a contract, I get:
web3.eth.contract is not a function
I'm using this code:
const path = require('path');
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
// Compile the source code
let input = fs.readFileSync('./contracts/ProofOfExistence3.sol', 'utf8');
let output = solc.compile(input, 1);
let abi = JSON.parse(output.contracts[':ProofOfExistence3'].interface);
let bytecode = output.contracts[':ProofOfExistence3'].bytecode;
let gasEstimate = web3.eth.estimateGas({data: bytecode}).then(console.log);
// Contract object
let MyContract = web3.eth.contract(abi);
And if I only run this code below, I get undefined. The same code works in the browser but not in nodejs with the official web3 package.
const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
console.log(web3.eth.contract);
Returns undefined.
Any ideas? I'm running "testrpc" locally.
MyContract = web3.eth.contract(abi).at(contractAdress)