Skip to main content

MonitorTransactionState

Monitor Transaction state changes by the unique identifier of the transaction. Server-side streaming method that sends state updates as the transaction progresses.

Server-Side Streaming Method

This method uses server-side streaming, meaning it returns multiple responses over time rather than a single response. The server sends a stream of responses to the client, and the client processes each response as it arrives.

Stream Lifecycle:

  • Initiation: Call the method to create a stream
  • Data Reception: Receive multiple responses over the stream
  • Completion: Stream ends normally (EOF/end event) or with an error
  • Resource Management: Streams should be fully consumed or explicitly closed

See the code examples below for language-specific streaming consumption patterns.

Method Options​

Authorisation specification of the MonitorTransactionState method.

TypeMETHOD_TYPE_READ
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_LEDGER_ADMIN
  • ROLE_LEDGER_VIEWER
  • ROLE_LEDGER_TRANSACTION_ADMIN
  • ROLE_LEDGER_TRANSACTION_VIEWER

Parameters​

Request and response parameter message overview:

Input: MonitorTransactionStateRequest Message​

FieldTypeRequiredDescription
Name

string

True

Name of the Transaction whose state is to be retrieved. Format: transactions/{ULIDv2}

Returns: MonitorTransactionStateResponse Message​

FieldTypeDescription
State

meshtrade.ledger.transaction.v1.TransactionState

Code Examples​

Select supported SDK in the language of your choice for a full example of how to invoke the this method:

package main

import (
"context"
"io"
"log"

transactionv1 "github.com/meshtrade/api/go/ledger/transaction/v1"
)

func main() {
ctx := context.Background()

// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
service, err := transactionv1.NewTransactionService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Create request with service-specific parameters
request := &transactionv1.MonitorTransactionStateRequest{
// FIXME: Populate service-specific request fields
}

// Call the MonitorTransactionState streaming method
stream, err := service.MonitorTransactionState(ctx, request)
if err != nil {
log.Fatalf("Failed to initiate stream: %v", err)
}

// Consume stream responses
for {
response, err := stream.Recv()
if err == io.EOF {
break // Stream completed normally
}
if err != nil {
log.Fatalf("Stream error: %v", err)
}

// Process each response as it arrives
log.Printf("Received: %+v", response)
}

log.Println("Stream completed successfully")
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​