Links

Websocket Example

An example for streaming Solana data via websockets.
Here's an example of how to setup a simple websocket connection that listens for account changes on the Jump Crypto account (5yv..ZtE).
Make sure to first quickly generate an API key at https://dev.helius.xyz
const solanaWeb3 = require('@solana/web3.js')
const connection = new solanaWeb3.Connection("https://rpc.helius.xyz?api-key=<YOUR API KEY HERE>");
(async () => {
connection.onAccountChange(
new solanaWeb3.PublicKey("5yv6Vh8FNx93TXeSS94xy8VLZMbTqx4vXp7Zg5bDLZtE"),
(updatedAccountInfo, context) =>
console.log("Updated account info: ", updatedAccountInfo),
"confirmed"
);
})();