Stellar PHP SDK API Documentation

MuxedAccount
in package

Represents a multiplexed Stellar account

Multiplexed accounts (also known as muxed accounts) allow multiple virtual accounts to share a single Stellar account. This is useful for exchanges, payment processors, and other services that need to differentiate between multiple users or sub-accounts while using the same underlying Stellar account.

A muxed account consists of:

  • The underlying Ed25519 account ID (G-address)
  • An optional 64-bit ID that differentiates virtual accounts

When the ID is present, the account is encoded as an M-address. When absent, it's a regular G-address.

Usage: // Create a regular account (no ID) $muxed = new MuxedAccount("GABC...");

// Create a multiplexed account with ID $muxed = new MuxedAccount("GABC...", 12345);

// Get the account ID (M-address if ID present, G-address otherwise) $accountId = $muxed->getAccountId();

// Parse from account ID string $muxed = MuxedAccount::fromAccountId("MABC...");

Tags
see
Account

For account with sequence number management

see
https://developers.stellar.org

Stellar developer docs

since
1.0.0

Table of Contents

Methods

__construct()  : mixed
Constructs a new MuxedAccount instance
fromAccountId()  : MuxedAccount
Creates a MuxedAccount from an account ID string
fromMed25519AccountId()  : MuxedAccount
Creates a MuxedAccount from a MED25519 account ID (M-address)
fromXdr()  : MuxedAccount
Creates a MuxedAccount from XDR format
getAccountId()  : string
Gets the account ID as a string
getEd25519AccountId()  : string
Gets the underlying Ed25519 account ID
getId()  : int|null
Gets the muxed account ID
getXdr()  : XdrMuxedAccount
Gets the XDR representation of the muxed account
toXdr()  : XdrMuxedAccount
Converts the muxed account to XDR format

Methods

__construct()

Constructs a new MuxedAccount instance

public __construct(string $ed25519AccountId[, int|null $id = null ]) : mixed
Parameters
$ed25519AccountId : string

The Ed25519 account ID (G-address)

$id : int|null = null

Optional 64-bit ID for multiplexing (creates M-address when set)

Tags
throws
InvalidArgumentException

If the account ID does not start with 'G'

fromAccountId()

Creates a MuxedAccount from an account ID string

public static fromAccountId(string $accountId) : MuxedAccount

Accepts both G-addresses (regular accounts) and M-addresses (multiplexed accounts).

Parameters
$accountId : string

The account ID (G-address or M-address)

Tags
throws
InvalidArgumentException

If the account ID format is invalid

Return values
MuxedAccount

The created MuxedAccount instance

fromMed25519AccountId()

Creates a MuxedAccount from a MED25519 account ID (M-address)

public static fromMed25519AccountId(string $med25519AccountId) : MuxedAccount
Parameters
$med25519AccountId : string

The M-address to decode

Return values
MuxedAccount

The created MuxedAccount instance

getAccountId()

Gets the account ID as a string

public getAccountId() : string

Returns an M-address if the account has a muxed ID, otherwise returns the underlying G-address.

Return values
string

The account ID (M-address or G-address)

getEd25519AccountId()

Gets the underlying Ed25519 account ID

public getEd25519AccountId() : string
Return values
string

The Ed25519 account ID (G-address)

getId()

Gets the muxed account ID

public getId() : int|null
Return values
int|null

The 64-bit ID, or null if not a multiplexed account


        
On this page

Search results