I've made a web3js script in a wordpress website, but when executing the following code, I get an invalid JSON RPC response.
var Web3 = require("web3");
var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("https://ropsten.infura.io/xxxxxxxxxxx"));
var accounts = web3.eth.accounts;
var abi=[{"constant":false,"inputs":[{"name":"document","type":"string"},{"name":"timestamp","type":"uint256"}],"name":"notarize2","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"document","type":"string"}],"name":"checkDocument","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"proof","type":"bytes32"},{"name":"timestamp","type":"uint256"}],"name":"storeProof","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"source","type":"string"}],"name":"stringToBytes32","outputs":[{"name":"result","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"proof","type":"bytes32"}],"name":"hasProof","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}];
web3.eth.defaultAccount="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
var poe = web3.eth.contract(abi).at("YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY");
console.log(poe.address);
result="test";
var today = new Date();
var todayI = today.getFullYear()*10000+ (today.getMonth()+1)*100+today.getDate();
console.log(todayI);
poe.notarize2(result,todayI,{gas:2000000});
The setup works perfect through testrpc (localhost) and through Remix / Metamask I could verify that the contract is correctly deployed on Ropsten and is working fine.
Any ideas? this is the first time I'm trying this.