Websocket fx chain not able to integrate with web3js or ethersjs

websocket fx chain not able to integrate with web3js or ethersjs

testnet fx chain

@indra @SCENE

hello iā€™m trying to integrate ws on fx chain with web3js, base on the doc to integrate with ws use wss://testnet-fx-json.functionx.io:26657/websocket, but looks issue on the network.
here my codes :

const Web3 = require('web3');
const web3 = new Web3(new Web3.providers.WebsocketProvider("wss://testnet-fx-json.functionx.io:26657/websocket"))
web3.eth.getTransactionCount("0x79280d9DDb2753f1fdB85924c81ECB831AB9C8c5").then(console.log)

web3.eth.getBalance("0x79280d9DDb2753f1fdB85924c81ECB831AB9C8c5", function(err, result) {
    if (err) {
        console.log(err)
    } else {
        console.log(web3.utils.fromWei(result, "ether") + " ETH")
    }
})

getGasPrice().then(console.log)
var options = {
    address: '0xd529e302f5A3AacC214A17f54e4821aBaB02FD97',
};

var subscription = web3.eth.subscribe('logs', options, function(error, result){
    if (!error) console.log('got result');
    else console.log(error);
}).on("data", function(log){
    console.log('got data', log);
}).on("changed", function(log){
    console.log('changed');
});

function getGasPrice() {
    return (async () => await web3.eth.getGasPrice())();
}

ERROR :
Error: Returned error: Method not found
at Object.ErrorResponse (/Users/argan/project/pundi-sale/node-event-be/node_modules/web3-core-helpers/lib/errors.js:28:19)
at Object.callback (/Users/argan/project/pundi-sale/node-event-be/node_modules/web3-core-requestmanager/lib/index.js:300:36)
at /Users/argan/project/pundi-sale/node-event-be/node_modules/web3-providers-ws/lib/index.js:114:45
at Array.forEach ()
at WebsocketProvider._onMessage (/Users/argan/project/pundi-sale/node-event-be/node_modules/web3-providers-ws/lib/index.js:102:69)
at W3CWebSocket._dispatchEvent [as dispatchEvent] (/Users/argan/project/pundi-sale/node-event-be/node_modules/yaeti/lib/EventTarget.js:115:12)
at W3CWebSocket.onMessage (/Users/argan/project/pundi-sale/node-event-be/node_modules/websocket/lib/W3CWebSocket.js:234:14)
at WebSocketConnection. (/Users/argan/project/pundi-sale/node-event-be/node_modules/websocket/lib/W3CWebSocket.js:205:19)
at WebSocketConnection.emit (node:events:520:28)
at WebSocketConnection.processFrame (/Users/argan/project/pundi-sale/node-event-be/node_modules/websocket/lib/WebSocketConnection.js:554:26)
at /Users/argan/project/pundi-sale/node-event-be/node_modules/websocket/lib/WebSocketConnection.js:323:40
at processTicksAndRejections (node:internal/process/task_queues:78:11) {
data: null
}

any idea to solve this problem?
cc om @IvanFunctionX @indra @SCENE

Web3 should use this instead

1 Like

looks everythings is work, thank you @lancelai