Stellar PHP SDK API Documentation

Account
in package
implements TransactionBuilderAccount

Represents a Stellar account with sequence number management

This class manages account state for transaction building, tracking the sequence number to ensure transactions are properly ordered. Each transaction from an account must use a sequence number exactly one greater than the last used sequence number.

The account can be a regular Ed25519 account or a multiplexed (muxed) account that includes an additional ID for virtual account separation.

Usage: // Create account with current sequence number $account = new Account("GABC...", new BigInteger("12345678"));

// Build transaction (sequence number auto-increments) $transaction = (new TransactionBuilder($account)) ->addOperation($operation) ->build();

// Create from muxed account ID $account = Account::fromAccountId("MABC...", new BigInteger("12345678"));

Tags
see
TransactionBuilderAccount

Interface this class implements

see
MuxedAccount

For multiplexed account support

see
https://developers.stellar.org

Stellar developer docs

since
1.0.0

Table of Contents

Interfaces

TransactionBuilderAccount
Interface for accounts used in transaction building.

Properties

$accountId  : string

Methods

__construct()  : mixed
Constructs a new Account instance
fromAccountId()  : Account
Creates an Account from an account ID (G-address or M-address)
getAccountId()  : string
Gets the Ed25519 account ID (G-address)
getIncrementedSequenceNumber()  : BigInteger
Gets the next sequence number without modifying the account state
getMuxedAccount()  : MuxedAccount
Gets the muxed account representation
getSequenceNumber()  : BigInteger
Gets the current sequence number
incrementSequenceNumber()  : void
Increments the account's sequence number

Properties

$accountId

protected string $accountId

Methods

__construct()

Constructs a new Account instance

public __construct(string $accountId, BigInteger $sequenceNumber[, int|null $muxedAccountMed25519Id = null ]) : mixed
Parameters
$accountId : string

The Ed25519 public key (G-address) of the account

$sequenceNumber : BigInteger

The current sequence number of the account

$muxedAccountMed25519Id : int|null = null

Optional muxed account ID for multiplexed accounts

fromAccountId()

Creates an Account from an account ID (G-address or M-address)

public static fromAccountId(string $accountId, BigInteger $sequenceNumber) : Account

This factory method accepts both regular Ed25519 account IDs (G-addresses) and multiplexed account IDs (M-addresses), automatically parsing the muxed account ID if present.

Parameters
$accountId : string

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

$sequenceNumber : BigInteger

The current sequence number of the account

Return values
Account

The created Account instance

getAccountId()

Gets the Ed25519 account ID (G-address)

public getAccountId() : string
Return values
string

The account ID

getIncrementedSequenceNumber()

Gets the next sequence number without modifying the account state

public getIncrementedSequenceNumber() : BigInteger

This method calculates what the next sequence number would be without actually incrementing the stored sequence number.

Tags
see
incrementSequenceNumber()

To actually increment the sequence number

Return values
BigInteger

The next sequence number

getSequenceNumber()

Gets the current sequence number

public getSequenceNumber() : BigInteger
Return values
BigInteger

The current sequence number

incrementSequenceNumber()

Increments the account's sequence number

public incrementSequenceNumber() : void

This method should be called after successfully submitting a transaction to keep the local sequence number synchronized with the network state.

Tags
see
getIncrementedSequenceNumber()

To preview the next sequence number


        
On this page

Search results