I have been having series of errors and I have not been able to find a solution online. Please can anyone help me? I want to prompt users to connect wallet i.e when the connect button is clicked talisman, polkadotjs etc should pop up for confirmation.
This is the function:
async function handleConnect () {
const provider = new WsProvider(WS_SECOND_ENDPOINT);
const oneApi = await ApiPromise.create({ provider });
const [chain, nodeName, nodeVersion] = await Promise.all([
oneApi.rpc.system.chain(),
oneApi.rpc.system.name(),
oneApi.rpc.system.version()
]);
await oneApi.connect();
console.log(`You are connected to chain ${chain} using ${nodeName} v${nodeVersion}`);
}
When i remove await oneApi.connect();
I get the error below on the console:
caught (in promise) Error: WebSocket is already connected
at WsProvider.connect (index.js:314:19)
at RpcCore.connect (bundle.js:91:30)
at ApiPromise.connect (index.js:29:30)
at newTest (App.tsx:49:14)
Thanks