development environment : C#, Windows

Connecting to solana-mainnet web server using wss address.

        wss = new WebSocketSharp.WebSocket(this.Address);
        wss.SslConfiguration.EnabledSslProtocols = System.Security.Authentication.SslProtocols.Tls12;

        wss.OnMessage += (sender, e) =>
            if (e.IsBinary)
                HandleMessage(Opcode.Binary, e.RawData);
            else if(e.IsText)
                HandleMessage(Opcode.Text, e.RawData);
        wss.OnOpen += (sender, e) =>
        wss.OnError += (sender, e) =>
        wss.OnClose += (sender, e) =>
            HandleClose(e.Code, e.Reason);

OnMessage occurs when the solana balance changes. (At this time, I check solana balance.)

However, if there is a change in the spl-token balance, there is no event.

Therefore, I am periodically checking the spl-token.

This is very inefficient

how to detect spl-token balance change?

Best regards,


1 Answer 1


Solana JSON RPC API offers a way to subscribe to an account to receive notifications when the Lamports or data for a given account's public key changes.


This includes any type of account, a token account is basically a data account initialized with a specific standard.


Here's an example of subscribing to CM78CPUeXjn8o3yroDHxUtKsZZgoy4GPkPPXfouKNH12. It doesn't matter what type of account it is.

  "jsonrpc": "2.0",
  "id": 1,
  "method": "accountSubscribe",
  "params": [
      "encoding": "base64",
      "commitment": "finalized"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.