Skip to main content

CreateAccount

Creates a new account record in the system (off-chain).

The account is created in a pending state and must be explicitly opened on the ledger using OpenAccount before it can receive funds or execute transactions. Account ownership must match the executing context.

Method Options​

Authorisation specification of the CreateAccount method.

TypeMETHOD_TYPE_WRITE
Access LevelMETHOD_ACCESS_LEVEL_AUTHORISED
Roles
  • ROLE_WALLET_ADMIN
  • ROLE_WALLET_ACCOUNT_ADMIN

Parameters​

Request and response parameter message overview:

Input: CreateAccountRequest Message​

FieldTypeRequiredDescription
Account

meshtrade.wallet.account.v1.Account

True

The account configuration for creation. The name, number, ledger_id, and owners fields will be ignored and assigned by the system.

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"

typev1 "github.com/meshtrade/api/go/type/v1"
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.CreateAccountRequest{
Account: &accountv1.Account{
Owner: service.Group(), // Current group from service context
Ledger: typev1.Ledger_LEDGER_STELLAR, // Choose ledger network
DisplayName: "Primary Trading Account",
},
}

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

// The account is created but not yet open on-chain
log.Printf("Account created successfully:")
log.Printf(" Name: %s", account.Name)
log.Printf(" Number: %s", account.Number)
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​