Error Unexpected token o in JSON at position 1

0 votes
I have been working with Interacting a smart contract deployed on the local node. I was using `Web3.providers.HttpProvider` until i had to interact with events, as i have understood, i needed to use `Web3.providers.IpcProvider`. After transitioning to IpcProvider. I am receiving following error.

    /home/lubuntu/Desktop/Test/node_modules/oboe/dist/oboe-node.js:2325
              throw new Error(e.message);
              ^
    
    Error: Unexpected token o in JSON at position 1
        at Timeout._onTimeout (/home/lubuntu/Desktop/Test/node_modules/oboe/dist/oboe-node.js:2325:17)
        at ontimeout (timers.js:436:11)
        at tryOnTimeout (timers.js:300:5)
        at listOnTimeout (timers.js:263:5)
        at Timer.processTimers (timers.js:223:10)

Following is how i have written code for interaction with geth / local node.

    const express=require('express');
    const net = require('net');
    const Web3=require('web3');
    let app=express();
    const PORT=3000;

    let web3=new Web3(new Web3.providers.IpcProvider('/home/lubuntu/Project/data/geth.ipc',net));

    var abi=[ { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address" }, { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name": "", "type": "uint8" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_value", "type": "uint256" } ], "name": "burn", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_from", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "burnFrom", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "_to", "type": "address" }, { "name": "_value", "type": "uint256" } ], "name": "transfer", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [ { "name": "", "type": "address" } ], "name": "frozenAccount", "outputs": [ { "name": "", "type": "bool" } ], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [ { "name": "target", "type": "address" }, { "name": "freeze", "type": "bool" } ], "name": "freezeAccount", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "inputs": [ { "name": "initialSupply", "type": "uint256" }, { "name": "tokenName", "type": "string" }, { "name": "tokenSymbol", "type": "string" } ], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "from", "type": "address" }, { "indexed": true, "name": "to", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Transfer", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": false, "name": "target", "type": "address" }, { "indexed": false, "name": "frozen", "type": "bool" } ], "name": "FrozenFunds", "type": "event" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "from", "type": "address" }, { "indexed": false, "name": "value", "type": "uint256" } ], "name": "Burn", "type": "event" } ];
    const contract = new web3.eth.Contract(abi, '0x6621b0431ed6f533575380f2ba4788f44b5049b6');

    app.get('/', function(req, res){

        res.sendFile(__dirname + '/public/index.html');
    });
   

    app.get('/blockchain', function(req,res){   
        contract.methods.transferFrom("0x029285ee26b9da62f138133a9fe40cb8c2219c82","0xe149cb26b99f176367e32c4ce33bc3bcb455cec6","10000").send({from:'0x029285ee26b9da62f138133a9fe40cb8c2219c82'}, (error, result) => {
        if(result.status=='0x1')
        console.log("Success")
        else if(result.status=='0x0')
        console.log("Failed");
        });
        //Event Test

        contract.once('Transfer', {
            filter: {from: '0x029285ee26b9da62f138133a9fe40cb8c2219c82', to: '0xe149cb26b99f176367e32c4ce33bc3bcb455cec6'},
            fromBlock: 'latest'
        }, (error, event) => { console.log(event); });
     });
   

    app.get('/blockchain2', function(req,res){    

        //Working
        contract.methods.balanceOf("0xe149cb26b99f176367e32c4ce33bc3bcb455cec6").call({from: '0x029285ee26b9da62f138133a9fe40cb8c2219c82'}, (error, result) => {
         console.log(result)  
        });

        //Testing Account create
        //Address can be assigned to function calling it or added to database against specific users

        //web3.eth.personal.newAccount('abc',function(error,address){
        //if(!error){res.send(address);}});
       
           

    });

    app.get('/blockchain3',function(req,res){
        var f_account=req.query.id.toLowerCase();
        var s_account="alert";
        if(f_account=="true")
        s_account="true"
        else if(f_account=="false")
        s_account="";
   

        if(s_account!="alert")
        {contract.methods.freezeAccount("0xe149cb26b99f176367e32c4ce33bc3bcb455cec6",s_account).send({from:'0x029285ee26b9da62f138133a9fe40cb8c2219c82'}, (error, result) => {
        //if(f_account=="true" || f_account=="false")
        if(!error)
        console.log("True")

        //console.log('Account Frozen:'+' '+f_account);
        else
        //console.log("Error");
        console.log(error)
     })}
     else
     console.log("Wrong Input")
   

    });
   
   

    app.listen(PORT, function(){
        console.log('Server is started on port:',PORT);
    });
Mar 6, 2019 in Blockchain by saeedi
• 120 points

edited Mar 6, 2019 by Omkar 2,443 views

Hey @saeedi ! I think you have missed something in the code you shared. I can't find the line at which the error has occurred in the code you have posted. Error at: 

  /home/lubuntu/Desktop/Test/node_modules/oboe/dist/oboe-node.js:2325
              throw new Error(e.message);

But that line is missing in the code. 

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Blockchain

0 votes
1 answer
+2 votes
1 answer
+1 vote
2 answers
+1 vote
2 answers

Challenge while setting up Hyperledger Fabric 1.0 in Ubuntu 16.04

The rocksdb error you're seeing wouldn't be ...READ MORE

answered Mar 27, 2018 in Blockchain by ned_crew
• 1,610 points

edited Jun 8, 2020 by Sirajul 1,137 views
+1 vote
1 answer

Error while deploying chaincode in IBM Blockchain. Please help.

Try stripping out the 'tree/master' portion of ...READ MORE

answered Apr 26, 2018 in Blockchain by Christine
• 15,790 points
874 views
0 votes
1 answer

How to create a Genesis Block in a Private Network?

{     "nonce": "0x0000000000000042",     "difficulty": "0x000000100",     "alloc": {     },     "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",     "coinbase": "0x0000000000000000000000000000000000000000",     "timestamp": "0x00",     "parentHash": ...READ MORE

answered Jul 12, 2018 in Blockchain by digger
• 26,740 points
1,990 views
0 votes
1 answer

Solidity geth: Error encountered during contract execution [Bad instruction]

recipes is a dynamic storage array. You need ...READ MORE

answered Oct 15, 2018 in Blockchain by Omkar
• 69,220 points
1,444 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,903 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,432 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP