Invalid request: unknown variant `eth_subscribe`, expected one of `SUBSCRIBE`, `UNSUBSCRIBE`, etc

358 views Asked by At

When trying to subscribe to events through websocket connection against binance smart chain testnet, I'm getting the following error:

{
  "error": {
    "code": 2,
    "msg": "Invalid request: unknown variant `eth_subscribe`, expected one of `SUBSCRIBE`, `UNSUBSCRIBE`, `LIST_SUBSCRIPTIONS`, `SET_PROPERTY`, `GET_PROPERTY` at line 1 column 49"
  },
  "id": 16
}

This is a simplified version of my code:

  const web3Socket = new Web3("wss://testnet.binance.vision/ws");
  const socketInstance = new web3Socket.eth.Contract(
    correct_abi,
    "correct_address"
  );
  web3Socket.eth.subscribe("logs", {}, (error, result) => {
    if (error) throw error;
    console.log(result);
  });

I'm using web3js 1.7.x and Metamask 10.11.1 on Brave (chromium based browser).

0

There are 0 answers