Account

Represents an account in the Stellar network with its sequence number.

An Account object is required to build a transaction. It contains the account ID and the current sequence number, which is needed to prevent transaction replay attacks.

Usage

// Create account from account ID (public key)
val account = Account("GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", 2908908335136768L)

// Create account from keypair
val keypair = KeyPair.fromSecretSeed("SCZANGBA5YHTNYVVV4C3U252E2B6P6F5T3U6MM63WBSBZATAQI3EBTQ4")
val account = Account(keypair, 2908908335136768L)

Sequence Numbers

The sequence number is crucial for transaction ordering:

  • It starts at 0 when an account is created

  • Each transaction increments the sequence number by 1

  • Transactions must use sequenceNumber + 1

  • Multiple transactions can be built by incrementing the sequence number

See also

Constructors

Link copied to clipboard
constructor(accountId: String, sequenceNumber: Long)

Creates a new account from an account ID and sequence number.

constructor(keypair: KeyPair, sequenceNumber: Long)

Creates a new account from a keypair and sequence number.

Properties

Link copied to clipboard
open override val accountId: String

The account ID (strkey encoded public key starting with 'G')

Link copied to clipboard
open override val keypair: KeyPair

Returns the keypair associated with this account.

Link copied to clipboard
open override val sequenceNumber: Long

The current sequence number of the account (mutable)

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun getIncrementedSequenceNumber(): Long

Returns the sequence number incremented by one, but does not modify the internal counter.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun incrementSequenceNumber()

Increments the sequence number in this object by one.

Link copied to clipboard
open override fun setSequenceNumber(seqNum: Long)

Sets the current sequence number on this account.

Link copied to clipboard
open override fun toString(): String