Skip to main content

GetAccount

Retrieves a specific account by its resource identifier.

Provides access to account metadata and optionally fetches live balance data from the ledger when populate_ledger_data is true.

Method Options​

Authorisation specification of the GetAccount 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: GetAccountRequest Message​

FieldTypeRequiredDescription
Name

string

False

The resource name of the account to retrieve. Format: accounts/{ULIDv2}.

PopulateLedgerData

bool

False

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

Returns: Account Message​

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

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.GetAccountRequest{
Name: "accounts/01HQ3K5M8XYZ2NFVJT9BKR7P4C", // Account resource name
PopulateLedgerData: true, // Fetch live blockchain data
}

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

// Display account information
log.Printf("Account retrieved successfully:")
log.Printf(" Name: %s", account.Name)
log.Printf(" Number: %s", account.Number)
log.Printf(" Display Name: %s", account.DisplayName)
log.Printf(" Ledger: %s", account.Ledger)
log.Printf(" State: %s", account.State)

// Display balances if live data was populated
if request.PopulateLedgerData && len(account.Balances) > 0 {
log.Printf(" Balances:")
for _, balance := range account.Balances {
log.Printf(" %s: %s",
balance.InstrumentMetadata.Name,
balance.Amount.Value)
}
}
}

Advanced Configuration​

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

Other Methods​