Skip to content
Integra Protocol
API

@integraledger/lcp/stellar

The exports of @integraledger/lcp/stellar.

Interfaces

StellarPayment

Properties

PropertyType
amountbigint
assetstring
authobject
auth.addressstring
auth.expirationnumber
auth.noncebigint
auth.preimageHash`0x${string}`
auth.v2boolean
fromstring
tostring
toBasestring
toIdbigint | null

StellarReader

Bounded, read-only calls against one network's RPC. Every failure rejects with ReaderError.

Properties

PropertyModifierType
networkreadonlyStellarNetwork

Methods

latestLedger()

latestLedger(): Promise<number>

getLatestLedger.

Returns

Promise<number>

transaction()

transaction(hash): Promise<{ envelopeXdr?: string; ledger?: number; oldestLedger: number; status: "SUCCESS" | "FAILED" | "NOT_FOUND"; }>

getTransaction.

Parameters
ParameterType
hashstring
Returns

Promise<{ envelopeXdr?: string; ledger?: number; oldestLedger: number; status: "SUCCESS" | "FAILED" | "NOT_FOUND"; }>

transfers()

transfers(f): Promise<{ complete: boolean; cursor?: string; events: readonly object[]; oldestLedger: number; }>

One page of SEP-41 transfer events of asset to toBase between two ledgers, with each event's to_muxed_id. cursor is present while more pages remain. complete is false when the RPC reports events disabled. oldestLedger is the oldest ledger the RPC still holds.

Parameters
ParameterType
f{ asset: string; cursor?: string; fromLedger: number; toBase: string; toLedger: number; }
f.assetstring
f.cursor?string
f.fromLedgernumber
f.toBasestring
f.toLedgernumber
Returns

Promise<{ complete: boolean; cursor?: string; events: readonly object[]; oldestLedger: number; }>


StellarRef

The read keys recorded at claim.

Properties

PropertyTypeDescription
assetstring-
authDigest`0x${string}`-
expirationnumber-
fromLedgernumber-
networkStellarNetwork-
toBasestring-
toIdstringThe muxed id, as a decimal string.
transaction?string-

StellarUnsigned

What the payer signs (the signer signs SHA-256 of preimage), and how the signature completes the transaction.

Properties

PropertyType
requestobject
request.kind"stellar-auth"
request.preimageUint8Array

Methods

complete()

complete(signature): string | Refusal

The base64 XDR of the transaction with the entry signed.

Parameters
ParameterType
signatureUint8Array
Returns

string | Refusal

Type Aliases

StellarNetwork

StellarNetwork = "stellar:pubnet" | "stellar:testnet"


StellarStatus

StellarStatus = { ledger: number; state: "settled"; } | { state: "pending"; why: "not-found" | "unreadable"; } | { state: "failed"; why: "failed" | "not-this-instrument"; }

Variables

PASSPHRASE

const PASSPHRASE: Readonly<Record<StellarNetwork, string>>

Stellar rail pieces: the payer-signed Soroban transfer, its muxed to whose 8-byte id is the ATR hash's first 8 bytes, the digest of the signed authorization entry, and settlement read through a bounded reader.


SCVAL_MAX_DEPTH

const SCVAL_MAX_DEPTH: 64 = 64

The deepest nesting of ScVal vectors and maps (a contract instance's storage counting as a map) within one ScVal, the outermost container being level 1, and of authorized invocations within one authorization entry.


SCVAL_MAX_ELEMENTS

const SCVAL_MAX_ELEMENTS: number

The most ScVal vector elements and map entries in one envelope. Each takes at least its 4-byte discriminant, so no envelope within MAX_XDR base64 characters holds more.

Functions

decodeStellarTx()

decodeStellarTx(xdrB64, network): Refusal | StellarPayment

Decodes a base64 TransactionEnvelope (v1, or a fee bump's inner v1) of at most 8 KiB holding exactly one invokeHostFunction operation that calls transfer(from, to, amount) on a contract, and the one authorization entry with address credentials (sorobanCredentialsAddress or sorobanCredentialsAddressV2) whose address is from. The entry's rootInvocation must be that same transfer, byte for byte, with no sub-invocations; the payment's contract, to and amount are the signed invocation's. The base64 is read strictly (RFC 4648 §4, zero padding bits), and the XDR must be consumed whole. preimageHash is SHA-256 of that entry's HashIDPreimage under the network's passphrase: the V1 form, or for V2 the form with the address.

Parameters

ParameterType
xdrB64string
networkStellarNetwork

Returns

Refusal | StellarPayment


muxedFor()

muxedFor(base, h): string

The M… strkey of a G… account and muxedId(h). Throws TypeError when base is not a G… strkey.

Parameters

ParameterType
basestring
h`0x${string}`

Returns

string


muxedId()

muxedId(h): bigint

The hash's first 8 bytes, big-endian, as a u64.

Parameters

ParameterType
h`0x${string}`

Returns

bigint


scValsWithinCaps()

scValsWithinCaps(wire): boolean

True when every ScVal in a decoded XDR value nests at most SCVAL_MAX_DEPTH vectors and maps, every authorized invocation at most SCVAL_MAX_DEPTH sub-invocations, and the value holds at most SCVAL_MAX_ELEMENTS vector elements and map entries. The walk keeps its own stack.

Parameters

ParameterType
wireunknown

Returns

boolean


stellarLocate()

stellarLocate(ref, reader): Promise<{ complete: boolean; found?: string; }>

Finds the instrument when no transaction was named: the asset's transfer events to toBase from fromLedger to the entry's expiration, keeping those whose muxed id is toId, each read as stellarStatus does. complete is true only when every page was read, the reader reported events enabled on each, the RPC still held fromLedger (oldestLedger ≤ fromLedger), and every candidate was read: a listed candidate whose transaction reads pending leaves the search incomplete. At most 10 pages and 50 candidates.

Parameters

ParameterType
refStellarRef
readerStellarReader

Returns

Promise<{ complete: boolean; found?: string; }>


stellarStatus()

stellarStatus(ref, reader): Promise<StellarStatus>

Reads a named transaction. Settled when it succeeded and its authorization entry's preimage digest and to id are the ones recorded at claim. A failed read, or a reader for another network, is pending. One call.

Parameters

ParameterType
refStellarRef & object
readerStellarReader

Returns

Promise<StellarStatus>


transferEventOf()

transferEventOf(topic, value): Refusal | { toBase: string; toMuxedId: bigint | null; }

A transfer event's recipient (the non-muxed to topic) and its to_muxed_id: the u64 in the event's data map, or null when the data carries none, or carries the string or bytes form.

Parameters

ParameterType
topicreadonly string[]
valuestring

Returns

Refusal | { toBase: string; toMuxedId: bigint | null; }


transferEventTopics()

transferEventTopics(toBase): readonly string[] | Refusal

The getEvents topic filter for SEP-41 transfer events to toBase, as base64 XDR segments: the symbol transfer, any from, toBase as an address, and any trailing topics (the Stellar Asset Contract adds its asset).

Parameters

ParameterType
toBasestring

Returns

readonly string[] | Refusal

Last updated on

On this page