> ## Documentation Index
> Fetch the complete documentation index at: https://goldrush.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# accountSubscribe on Solana

> accountSubscribe subscribes to changes to an account on Solana, via GoldRush JSON-RPC.

> [card] 0.01 credits per call

`accountSubscribe` on **Solana**: Subscribes to changes to an account.

## Endpoint

```
wss://rpc.goldrushdata.com/v1/solana-mainnet
```

`accountSubscribe` is a **WebSocket** subscription method.

Authenticate with `Authorization: Bearer <GOLDRUSH_API_KEY>`. See [authentication](https://goldrush.dev/docs/goldrush-json-rpc/authentication.md).

## Parameters

| Name | Type | Required | Description | Example |
| - | - | - | - | - |
| `address` | `string` | yes | Base-58 encoded account address to watch. | `"CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12"` |
| `config` | `object` | no | `{commitment?, encoding?}`. | `{"encoding":"jsonParsed","commitment":"finalized"}` |

## Returns

`number`: Subscription id (used with `accountUnsubscribe`). Notifications arrive as `accountNotification` messages.

```json theme={null}
23784
```

## Examples

```bash wscat theme={null}
# Connect (header auth works from Node/CLI clients):
wscat -c "wss://rpc.goldrushdata.com/v1/solana-mainnet" \
  -H "Authorization: Bearer $GOLDRUSH_API_KEY"

# Once connected, send:
{"jsonrpc":"2.0","id":1,"method":"accountSubscribe","params":["CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"encoding":"jsonParsed","commitment":"finalized"}]}
```

```typescript @solana/kit theme={null}
import { createSolanaRpcSubscriptions } from "@solana/kit";

// Authenticate with the Authorization: Bearer header on the WS handshake.
// See /goldrush-json-rpc/authentication.
const rpcSubscriptions = createSolanaRpcSubscriptions("wss://rpc.goldrushdata.com/v1/solana-mainnet");

const abortController = new AbortController();
const notifications = await rpcSubscriptions
  .accountSubscribe("CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12", {"encoding":"jsonParsed","commitment":"finalized"})
  .subscribe({ abortSignal: abortController.signal });

for await (const notification of notifications) {
  console.log(notification);
}
```

## Errors

Standard JSON-RPC errors: `-32600` invalid request, `-32601` method not found, `-32602` invalid params.

## Related Subscriptions methods on Solana

* [`accountUnsubscribe` on Solana](https://goldrush.dev/docs/api-reference/json-rpc/solana/accountunsubscribe)
* [`logsSubscribe` on Solana](https://goldrush.dev/docs/api-reference/json-rpc/solana/logssubscribe)
* [`logsUnsubscribe` on Solana](https://goldrush.dev/docs/api-reference/json-rpc/solana/logsunsubscribe)
* [`programSubscribe` on Solana](https://goldrush.dev/docs/api-reference/json-rpc/solana/programsubscribe)
* [`programUnsubscribe` on Solana](https://goldrush.dev/docs/api-reference/json-rpc/solana/programunsubscribe)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.