I'm trying to create a API fo my smart contract functions like following:
router.get('/',function (req,res) { var web3 = new Web3(new Web3.providers.HttpProvider('https://ropsten.infura.io/key')); var DataPassContract = web3.eth.contract(abi); var dataPass = DataPassContract.at('contract address'); dataPass.add('myaddress','a','a','a',{ from: 'other address' }, (err, result) => { if (err) throw err; if (result) { res.send('yes'); } }); });
When executed i want this function to open Mtamask and ask the client to confirm the transaction but when calling it I get this error:
if (err) throw err;
^
Error: Invalid JSON RPC response: ""
Any help would be appreciated.
web3.eth.defaultAccount