I am simplying trying to create a new contract on the testnet. I am using IFURA as a node and here is my code:
var createInvoice = function(){
unlockAccountsIfNeeded();
fs.readFile('./ethereum/contracts/invoice.sol', 'utf8', function(err, contractCode) {
if(err) console.log("error: " + err);
var contractCompiled = solc.compile(contractCode, 1); // 1 activates the optimiser
for (var contractName in contractCompiled.contracts) {
var greeterContract = web3.eth.contract(JSON.parse(contractCompiled.contracts[contractName].interface));
greeterContract.new({from:wallet, data: contractCompiled.contracts[contractName].bytecode, gas: 1000000}, function(e, contract){
if(!e) {
if(!contract.address) {
console.log("Contract transaction send: TransactionHash: " + contract.transactionHash + " waiting to be mined...");
} else {
console.log("Contract mined! Address: " + contract.address);
console.log(contract);
}
} else {
console.log("web3js error: " + e);
}
})
}
});
};
I keep getting the same error:
web3js error: Error: Invalid JSON RPC response: ""
I am not sure what could cause the error, it seems like my code works but the parameters that I parse to greeterContract.new are not correct but I am not sure which one.
Thanks for the help.