suix_subscribeTransaction - Sui

Example code for the suix_subscribeTransaction JSON-RPC method. Complete guide on how to use suix_subscribeTransaction JSON-RPC in GetBlock Web3 documentation.

This method subscribes to a stream of transaction effects matching specified filter criteria via WebSocket. This enables real-time transaction monitoring for applications tracking specific addresses, objects, or transaction types.

This method requires a WebSocket connection, not HTTP.

Parameters

Parameter
Type
Required
Description

filter

TransactionFilter

Yes

Transaction filter criteria

TransactionFilter Options

  • Checkpoint - Match by checkpoint

  • MoveFunction - Match by Move function call

  • InputObject - Match by input object

  • ChangedObject - Match by modified object

  • FromAddress - Match by sender

  • ToAddress - Match by recipient

  • FromAndToAddress - Match by both sender and recipient

  • TransactionKind - Match by transaction type

Request Example

subscribe.js
const WebSocket = require('ws');

const ws = new WebSocket('wss://go.getblock.io/<ACCESS-TOKEN>/');

ws.on('open', () => {
  const subscribeRequest = {
    jsonrpc: '2.0',
    id: 1,
    method: 'suix_subscribeTransaction',
    params: [
      {
        FromAddress: '0x94f1a597b4e8f709a396f7f6b1482bdcd65a673d111e49286c527fab7c2d0961'
      }
    ]
  };
  ws.send(JSON.stringify(subscribeRequest));
});

ws.on('message', (data) => {
  const response = JSON.parse(data);
  console.log('Received:', response);
});

Response Example

Response Parameters

Parameter
Type
Description

subscription

number

Subscription ID

result

object

Transaction effects when transactions match

Use Cases

  • Monitor wallet activity in real-time

  • Track object modifications

  • Build payment notifications

  • Watch smart contract interactions

  • Create transaction alerts

Error Handling

Error Code
Description

-32602

Invalid filter format

-32603

Internal error

Connection closed

WebSocket disconnected

SDK Integration

Last updated

Was this helpful?