Websocket
Connect to SEDA Fast
const WebSocket = require("ws");
const ws = new WebSocket("wss://fast-ws.mainnet.seda.xyz/ws/v1", {
headers: { Authorization: `Bearer ${process.env.SEDA_FAST_API_KEY}` },
});
ws.on("open", () => console.log("π Connected"));
ws.on("message", (data) => {
const msg = JSON.parse(data.toString());
// Uncomment this line to see the full message
// console.log("π¨", JSON.stringify(msg, null, 2));
if (msg.method === "authorized") {
console.log("β
Authorized");
// Close the connection after receiving the authorized notification
ws.close(1000, "closed by client");
}
if (msg.error) {
console.error("β", msg.error.code, msg.error.message);
}
});
ws.on("error", (e) => console.error("β", e));
ws.on("close", (code, reason) => {
console.log("π Disconnected", code ? `(${code}${reason ? `: ${reason}` : ""})` : "");
});Executing a Single Request
Understanding the Response
Last updated
Was this helpful?
