Skip to main content

ListAccounts

Lists all accounts within the authenticated group's hierarchical scope.

Returns the complete set of accounts accessible to the executing context, including accounts owned by the group and all descendant groups.

Method Options​

Authorisation specification of the ListAccounts method.

TypeMETHOD_TYPE_READ
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_WALLET_ADMIN
  • ROLE_WALLET_VIEWER
  • ROLE_WALLET_ACCOUNT_ADMIN
  • ROLE_WALLET_ACCOUNT_VIEWER

Parameters​

Request and response parameter message overview:

Input: ListAccountsRequest Message​

FieldTypeRequiredDescription
Sorting
FieldTypeRequiredDescription
FieldstringFalseField to sort by. Supported values: "number" or empty string for default ordering.
Ordermeshtrade.type.v1.SortingOrderFalseSort order for results.
False

Optional sorting configuration.

PopulateLedgerData

bool

False

When true, fetches current balances and state from the ledger. When false, returns only stored metadata without live data.

Returns: ListAccountsResponse Message​

FieldTypeDescription
Accounts

meshtrade.wallet.account.v1.Account[]

Collection of accounts in the hierarchy.

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"
"log"

accountv1 "github.com/meshtrade/api/go/wallet/account/v1"
typev1 "github.com/meshtrade/api/go/type/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 := accountv1.NewAccountService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Create request with service-specific parameters
request := &accountv1.ListAccountsRequest{
PopulateLedgerData: false, // Set to true to fetch live blockchain data
Sorting: &accountv1.ListAccountsRequest_Sorting{
Field: "number", // Sort by account number
Order: typev1.SortingOrder_SORTING_ORDER_ASC, // Ascending order
},
}

// Call the ListAccounts method
response, err := service.ListAccounts(ctx, request)
if err != nil {
log.Fatalf("ListAccounts failed: %v", err)
}

// Display all accounts in the hierarchy
log.Printf("Found %d accounts:", len(response.Accounts))
for _, account := range response.Accounts {
log.Printf(" Account %s:", account.Number)
log.Printf(" Name: %s", account.Name)
log.Printf(" Display Name: %s", account.DisplayName)
log.Printf(" Ledger: %s", account.Ledger)
log.Printf(" State: %s", account.State)
}
}

Advanced Configuration​

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

Other Methods​