× Error: Alchemy URL protocol must be one of http, https, ws, or wss. Recieved: undefined React.js

Solution 1:

According to the Alchemy documentation,

using websockets with the web3-alchemy sdk requires setting up your web3 object with a websocket URL, like this:

const { createAlchemyWeb3 } = require("@alch/alchemy-web3");

const web3 = createAlchemyWeb3("wss://eth-mainnet.ws.alchemyapi.io/ws/<api-key>");

when it is set up correctly, you should be able to make a call, for example:

web3.eth.getBlockNumber().then(console.log);  // -> 7946893

The error you are seeing is due to an incorrect argument undefined React.js being passed into the alchemy web3 instantiation, basically:

const web3 = createAlchemyWeb3( undefined React.js ); // the error is here

You need to figure out why there is an undefined React.js showing up, and once you fix that error, your app should be able to load!