accountSubscribe
Last updated:
accountSubscribe registers a live watch on one account, identified by its
base-58 public key. Whenever the runtime commits a change to that account —
its lamport balance moves, its data bytes are rewritten, or its owner changes —
the server pushes an accountNotification frame over the same WebSocket
connection. Between changes the stream is silent, so a quiet account costs
nothing beyond the open subscription.
The optional config object mirrors getAccountInfo: commitment decides how
settled a change must be before you hear about it (processed for lowest
latency, confirmed — the default — for the usual balance of speed and
safety, finalized when rollbacks are unacceptable), and encoding controls
the shape of value.data (base58, base64, base64+zstd, or jsonParsed
for well-known programs such as SPL Token). The notification payload is the
same context/value envelope getAccountInfo returns, so parsing code can
be shared between the polling and streaming paths.
Typical uses: tracking a hot wallet's SOL balance without polling, watching a
token account for incoming deposits, following a program-derived address (PDA)
that a program mutates, or reacting to an oracle price account the moment it
updates. One WebSocket connection can carry many account subscriptions side by
side — route incoming frames by params.subscription.
Two lifecycle rules catch people out. First, a subscription lives only as long
as the WebSocket session: if the socket drops and you reconnect, you must send
accountSubscribe again — subscription ids are not portable across
connections. Second, notifications fire once per committed change of state,
not once per transaction: several writes landing in one slot can collapse into
a single notification carrying the final state. Stop the stream with
accountUnsubscribe, passing the integer id from
the subscribe ack.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/sol \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"accountSubscribe","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/sol", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "accountSubscribe",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/sol",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"accountSubscribe","params":[],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: WebSocket.
- Networks: mainnet, devnet, testnet.
- Credit cost: 1 per call.
FAQ
- What does accountSubscribe do?
- Subscribes to a single Solana account by public key and streams a notification every time that account's lamports or data change.
- How many credits does accountSubscribe cost?
- accountSubscribe costs 1 credit(s) per call on Triport by default.
- Is accountSubscribe available over WebSocket?
- Yes, accountSubscribe supports WebSocket.