OpenInfra.sh is now live - Solana infrastructure, included with every server. LEARN MORE HERE >

OpenInfra.shopeninfra.sh

accountSubscribe

Push a notification every time a specific account's lamports, data, or owner changes.

Parameters

ParamTypeDescription
pubkeystringBase58 account address to watch
encodingstringbase58 | base64 | base64+zstd | jsonParsed
commitmentstringprocessed | confirmed | finalized

Subscribe and receive

// Subscribews.send(JSON.stringify({  jsonrpc: "2.0",  id: 1,  method: "accountSubscribe",  params: [    "vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",    { encoding: "base64", commitment: "confirmed" }  ],})); // Confirmation response → subscription ID// { "jsonrpc": "2.0", "result": 23784, "id": 1 } // Notification arrives when account changes// { "jsonrpc": "2.0", "method": "accountNotification",//   "params": { "result": { "context": { "slot": 312449201 },//     "value": { "lamports": 1461600, "data": ["...", "base64"],//       "owner": "TokenkegQfe...", "executable": false, "rentEpoch": 361 }//   }, "subscription": 23784 }}

The value object has the same shape as getAccountInfo. The subscription field in each notification matches the ID returned by the subscribe call.

Unsubscribing

ws.send(JSON.stringify({  jsonrpc: "2.0",  id: 2,  method: "accountUnsubscribe",  params: [23784], // subscription ID from subscribe response}));