CRYPTO NEWS

how to access ws connection in nodejs when truffle-config enables websockets

here is my truffle-config.js

    module.exports = {   networks: {     development: {       host: "127.0.0.1",       port: 9545,       network_id: "*",        websockets: true       },     develop: {       port: 8545     }   },   compilers: {     solc: {         version: "0.8.14"       } } }; 

then here is my app.js

var Web3 = require('web3'); var contract = require("truffle-contract");  var contractGreeter = require('../build/contracts/HelloWorld.json') var greeter = contract(contractGreeter);  var provider = new Web3.providers.WebsocketProvider("ws://127.0.0.1:9545");  greeter.setProvider(provider); 

when run node app.js, It says "Error: Invalid JSON RPC response: """

is there something wrong in my code?

how to access ws connection in nodejs when truffle-config enables websockets

Shopping cart
There are no products in the cart!
Continue shopping
0