Skip to content

Core / Transactions

Account

Create a new Account object.

Account represents a single account in the Stellar network and its sequence number. Account tracks the sequence number as it is used by TransactionBuilder. See Accounts for more information about how accounts work in Stellar.

class Account {
constructor(accountId: string, sequence: string);
accountId(): string;
incrementSequenceNumber(): void;
sequenceNumber(): string;
}

Source: src/base/account.ts:15

new Account(accountId, sequence)

constructor(accountId: string, sequence: string);

Parameters

  • accountIdstring (required) — ID of the account (ex. GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA). If you provide a muxed account address, this will throw; use MuxedAccount instead.
  • sequencestring (required) — current sequence number of the account

Source: src/base/account.ts:26

account.accountId()

Returns Stellar account ID, ex. GB3KJPLFUYN5VL6R3GU3EGCGVCKFDSD7BEDX42HWG5BWFKB3KQGJJRMA.

accountId(): string;

Source: src/base/account.ts:57

account.incrementSequenceNumber()

Increments sequence number in this object by one.

incrementSequenceNumber(): void;

Source: src/base/account.ts:71

account.sequenceNumber()

Returns sequence number for the account as a string

sequenceNumber(): string;

Source: src/base/account.ts:64

AuthClawbackEnabledFlag

When set using Operation.setOptions option, then any trustlines created by this account can have a ClawbackOp operation submitted for the corresponding asset.

const AuthClawbackEnabledFlag: number

See also

Source: src/base/operation.ts:83

AuthFlag

type AuthFlag = unknown

Source: src/base/operations/types.ts:431

AuthFlag

type AuthFlag = typeof AuthFlag[keyof typeof AuthFlag]

Source: src/base/operations/types.ts:431

AuthImmutableFlag

When set using Operation.setOptions option, then none of the authorization flags can be set and the account can never be deleted.

const AuthImmutableFlag: number

See also

Source: src/base/operation.ts:74

AuthRequiredFlag

When set using Operation.setOptions option, requires the issuing account to give other accounts permission before they can hold the issuing account’s credit.

const AuthRequiredFlag: number

See also

Source: src/base/operation.ts:60

AuthRevocableFlag

When set using Operation.setOptions option, allows the issuing account to revoke its credit held by other accounts.

const AuthRevocableFlag: number

See also

Source: src/base/operation.ts:67

BASE_FEE

Minimum base fee for transactions. If this fee is below the network minimum, the transaction will fail. The more operations in the transaction, the greater the required fee. Use Horizon.Server.fetchBaseFee to get an accurate value of minimum transaction fee on the network.

const BASE_FEE: "100"

See also

Source: src/base/transaction_builder.ts:38

FeeBumpTransaction

Use TransactionBuilder.buildFeeBumpTransaction to build a FeeBumpTransaction object. If you have an object or base64-encoded string of the transaction envelope XDR use TransactionBuilder.fromXDR.

Once a FeeBumpTransaction has been created, its attributes and operations should not be changed. You should only add signatures (using FeeBumpTransaction.sign) before submitting to the network or forwarding on to additional signers.

class FeeBumpTransaction {
constructor(envelope: string | TransactionEnvelope, networkPassphrase: string);
fee: string;
readonly feeSource: string;
readonly innerTransaction: Transaction;
networkPassphrase: string;
readonly operations: OperationRecord[];
signatures: DecoratedSignature[];
tx: TTx;
addDecoratedSignature(signature: DecoratedSignature): void;
addSignature(publicKey: string = "", signature: string = ""): void;
getKeypairSignature(keypair: Keypair): string;
hash(): Buffer;
sign(...keypairs: Keypair[]): void;
signatureBase(): Buffer;
signHashX(preimage: string | Buffer<ArrayBufferLike>): void;
toEnvelope(): TransactionEnvelope;
toXDR(): string;
}

Source: src/base/fee_bump_transaction.ts:17

new FeeBumpTransaction(envelope, networkPassphrase)

constructor(envelope: string | TransactionEnvelope, networkPassphrase: string);

Parameters

  • envelopestring | TransactionEnvelope (required) — transaction envelope object or base64 encoded string.
  • networkPassphrasestring (required) — passphrase of the target Stellar network (e.g. “Public Global Stellar Network ; September 2015”).

Source: src/base/fee_bump_transaction.ts:26

feeBumpTransaction.fee

The total fee for this transaction, in stroops.

fee: string;

Source: src/base/transaction_base.ts:76

feeBumpTransaction.feeSource

The account paying the fee for this transaction.

readonly feeSource: string;

Source: src/base/fee_bump_transaction.ts:78

feeBumpTransaction.innerTransaction

The inner transaction that this fee bump wraps.

readonly innerTransaction: Transaction;

Source: src/base/fee_bump_transaction.ts:64

feeBumpTransaction.networkPassphrase

The network passphrase for this transaction.

networkPassphrase: string;

Source: src/base/transaction_base.ts:85

feeBumpTransaction.operations

The operations from the inner transaction.

readonly operations: OperationRecord[];

Source: src/base/fee_bump_transaction.ts:71

feeBumpTransaction.signatures

The list of signatures for this transaction.

signatures: DecoratedSignature[];

Source: src/base/transaction_base.ts:35

feeBumpTransaction.tx

The underlying XDR transaction object.

Returns a defensive copy so that external mutations cannot alter the transaction that will be signed or serialized.

tx: TTx;

Throws

  • if the internal transaction is not a recognized XDR type

Source: src/base/transaction_base.ts:51

feeBumpTransaction.addDecoratedSignature(signature)

Add a decorated signature directly to the transaction envelope.

addDecoratedSignature(signature: DecoratedSignature): void;

Parameters

  • signatureDecoratedSignature (required) — raw signature to add

See also

    • Keypair.signDecorated
  • Keypair.signPayloadDecorated

Source: src/base/transaction_base.ts:196

feeBumpTransaction.addSignature(publicKey, signature)

Add a signature to the transaction. Useful when a party wants to pre-sign a transaction but doesn’t want to give access to their secret keys. This will also verify whether the signature is valid.

Here’s how you would use this feature to solicit multiple signatures.

  • Use TransactionBuilder to build a new transaction.
  • Make sure to set a long enough timeout on that transaction to give your signers enough time to sign!
  • Once you build the transaction, use transaction.toXDR() to get the base64-encoded XDR string.
  • Warning! Once you’ve built this transaction, don’t submit any other transactions onto your account! Doing so will invalidate this pre-compiled transaction!
  • Send this XDR string to your other parties. They can use the instructions for getKeypairSignature to sign the transaction.
  • They should send you back their publicKey and the signature string from getKeypairSignature, both of which you pass to this function.
addSignature(publicKey: string = "", signature: string = ""): void;

Parameters

  • publicKeystring (optional) (default: "") — the public key of the signer
  • signaturestring (optional) (default: "") — the base64 value of the signature XDR

Source: src/base/transaction_base.ts:156

feeBumpTransaction.getKeypairSignature(keypair)

Signs a transaction with the given Keypair. Useful if someone sends you a transaction XDR for you to sign and return (see addSignature for more information).

When you get a transaction XDR to sign…

  • Instantiate a Transaction object with the XDR
  • Use Keypair to generate a keypair object for your Stellar seed.
  • Run getKeypairSignature with that keypair
  • Send back the signature along with your publicKey (not your secret seed!)

Example:

// `transactionXDR` is a string from the person generating the transaction
const transaction = new Transaction(transactionXDR, networkPassphrase);
const keypair = Keypair.fromSecret(myStellarSeed);
return transaction.getKeypairSignature(keypair);

Returns the base64-encoded signature string for the given keypair.

getKeypairSignature(keypair: Keypair): string;

Parameters

  • keypairKeypair (required) — Keypair of signer

Source: src/base/transaction_base.ts:129

feeBumpTransaction.hash()

Returns a hash for this transaction, suitable for signing.

hash(): Buffer;

Source: src/base/transaction_base.ts:222

feeBumpTransaction.sign(keypairs)

Signs the transaction with the given Keypair.

sign(...keypairs: Keypair[]): void;

Parameters

  • ...keypairsKeypair[] (required) — Keypairs of signers

Source: src/base/transaction_base.ts:97

feeBumpTransaction.signatureBase()

Returns the “signature base” of this transaction, which is the value that, when hashed, should be signed to create a signature that validators on the Stellar Network will accept.

It is composed of a 4 prefix bytes followed by the xdr-encoded form of this transaction.

signatureBase(): Buffer;

Source: src/base/fee_bump_transaction.ts:90

feeBumpTransaction.signHashX(preimage)

Add hashX signer preimage as signature.

signHashX(preimage: string | Buffer<ArrayBufferLike>): void;

Parameters

  • preimagestring | Buffer<ArrayBufferLike> (required) — preimage of hash used as signer

Source: src/base/transaction_base.ts:204

feeBumpTransaction.toEnvelope()

To envelope returns a xdr.TransactionEnvelope which can be submitted to the network.

toEnvelope(): TransactionEnvelope;

Source: src/base/fee_bump_transaction.ts:107

feeBumpTransaction.toXDR()

Returns the transaction envelope as a base64-encoded XDR string.

toXDR(): string;

Source: src/base/transaction_base.ts:239

Int128

class Int128 extends LargeInt {
constructor(...args: (string | number | bigint)[]);
static MAX_VALUE: LargeInt;
static MIN_VALUE: LargeInt;
static defineIntBoundaries(): void;
static fromString(value: string): LargeInt;
static isValid(value: unknown): boolean;
readonly size: number;
readonly unsigned: boolean;
slice(chunkSize: number): bigint[];
toBigInt(): bigint;
toString(): string;
}

Source: src/base/numbers/int128.ts:3

new Int128(args)

Construct a signed 128-bit integer that can be XDR-encoded.

constructor(...args: (string | number | bigint)[]);

Parameters

  • ...args(string | number | bigint)[] (required) — one or more slices to encode in big-endian format (i.e. earlier elements are higher bits)

Source: src/base/numbers/int128.ts:10

Int128.MAX_VALUE

static MAX_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:14

Int128.MIN_VALUE

static MIN_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:13

Int128.defineIntBoundaries()

static defineIntBoundaries(): void;

Source: types/stellar__js-xdr/index.d.ts:12

Int128.fromString(value)

static fromString(value: string): LargeInt;

Parameters

  • valuestring (required)

Source: types/stellar__js-xdr/index.d.ts:16

Int128.isValid(value)

static isValid(value: unknown): boolean;

Parameters

  • valueunknown (required)

Source: types/stellar__js-xdr/index.d.ts:15

int128.size

readonly size: number;

Source: src/base/numbers/int128.ts:18

int128.unsigned

readonly unsigned: boolean;

Source: src/base/numbers/int128.ts:14

int128.slice(chunkSize)

slice(chunkSize: number): bigint[];

Parameters

  • chunkSizenumber (required)

Source: types/stellar__js-xdr/index.d.ts:21

int128.toBigInt()

toBigInt(): bigint;

Source: types/stellar__js-xdr/index.d.ts:19

int128.toString()

toString(): string;

Source: types/stellar__js-xdr/index.d.ts:20

Int256

class Int256 extends LargeInt {
constructor(...args: (string | number | bigint)[]);
static MAX_VALUE: LargeInt;
static MIN_VALUE: LargeInt;
static defineIntBoundaries(): void;
static fromString(value: string): LargeInt;
static isValid(value: unknown): boolean;
readonly size: number;
readonly unsigned: boolean;
slice(chunkSize: number): bigint[];
toBigInt(): bigint;
toString(): string;
}

Source: src/base/numbers/int256.ts:3

new Int256(args)

Construct a signed 256-bit integer that can be XDR-encoded.

constructor(...args: (string | number | bigint)[]);

Parameters

  • ...args(string | number | bigint)[] (required) — one or more slices to encode in big-endian format (i.e. earlier elements are higher bits)

Source: src/base/numbers/int256.ts:10

Int256.MAX_VALUE

static MAX_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:14

Int256.MIN_VALUE

static MIN_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:13

Int256.defineIntBoundaries()

static defineIntBoundaries(): void;

Source: types/stellar__js-xdr/index.d.ts:12

Int256.fromString(value)

static fromString(value: string): LargeInt;

Parameters

  • valuestring (required)

Source: types/stellar__js-xdr/index.d.ts:16

Int256.isValid(value)

static isValid(value: unknown): boolean;

Parameters

  • valueunknown (required)

Source: types/stellar__js-xdr/index.d.ts:15

int256.size

readonly size: number;

Source: src/base/numbers/int256.ts:18

int256.unsigned

readonly unsigned: boolean;

Source: src/base/numbers/int256.ts:14

int256.slice(chunkSize)

slice(chunkSize: number): bigint[];

Parameters

  • chunkSizenumber (required)

Source: types/stellar__js-xdr/index.d.ts:21

int256.toBigInt()

toBigInt(): bigint;

Source: types/stellar__js-xdr/index.d.ts:19

int256.toString()

toString(): string;

Source: types/stellar__js-xdr/index.d.ts:20

Memo

Memo represents memos attached to transactions.

class Memo<T extends MemoType = MemoType> {
constructor(type: "none", value?: null);
static fromXDRObject(object: Memo): Memo;
static hash(hash: string | Buffer<ArrayBufferLike>): Memo<"hash">;
static id(id: string): Memo<"id">;
static none(): Memo<"none">;
static return(hash: string | Buffer<ArrayBufferLike>): Memo<"return">;
static text(text: string): Memo<"text">;
type: T;
value: MemoTypeToValue<T>;
toXDRObject(): Memo;
}

See also

Source: src/base/memo.ts:63

new Memo(type, value)

constructor(type: "none", value?: null);

Parameters

  • type"none" (required)
  • valuenull (optional)

Source: src/base/memo.ts:67

Memo.fromXDRObject(object)

Returns Memo from XDR memo object.

static fromXDRObject(object: Memo): Memo;

Parameters

  • objectMemo (required) — XDR memo object

Source: src/base/memo.ts:302

Memo.hash(hash)

Creates and returns a MemoHash memo.

static hash(hash: string | Buffer<ArrayBufferLike>): Memo<"hash">;

Parameters

  • hashstring | Buffer<ArrayBufferLike> (required) — 32 byte hash or hex encoded string

Source: src/base/memo.ts:260

Memo.id(id)

Creates and returns a MemoID memo.

static id(id: string): Memo<"id">;

Parameters

  • idstring (required) — 64-bit number represented as a string

Source: src/base/memo.ts:251

Memo.none()

Returns an empty memo (MemoNone).

static none(): Memo<"none">;

Source: src/base/memo.ts:233

Memo.return(hash)

Creates and returns a MemoReturn memo.

static return(hash: string | Buffer<ArrayBufferLike>): Memo<"return">;

Parameters

  • hashstring | Buffer<ArrayBufferLike> (required) — 32 byte hash or hex encoded string

Source: src/base/memo.ts:269

Memo.text(text)

Creates and returns a MemoText memo.

static text(text: string): Memo<"text">;

Parameters

  • textstring (required) — memo text

Source: src/base/memo.ts:242

memo.type

Contains memo type: MemoNone, MemoID, MemoText, MemoHash or MemoReturn

type: T;

Source: src/base/memo.ts:107

memo.value

Contains memo value:

  • null for MemoNone,
  • string for MemoID,
  • Buffer for MemoText after decoding using fromXDRObject, original value otherwise,
  • Buffer for MemoHash, MemoReturn.
value: MemoTypeToValue<T>;

Source: src/base/memo.ts:122

memo.toXDRObject()

Returns XDR memo object.

toXDRObject(): Memo;

Source: src/base/memo.ts:276

MemoHash

Type of Memo.

const MemoHash: "hash"

Source: src/base/memo.ts:21

MemoID

Type of Memo.

const MemoID: "id"

Source: src/base/memo.ts:13

MemoNone

Type of Memo.

const MemoNone: "none"

Source: src/base/memo.ts:9

MemoReturn

Type of Memo.

const MemoReturn: "return"

Source: src/base/memo.ts:25

MemoText

Type of Memo.

const MemoText: "text"

Source: src/base/memo.ts:17

MemoType

type MemoType = MemoTypeHash | MemoTypeID | MemoTypeNone | MemoTypeReturn | MemoTypeText

Source: src/base/memo.ts:33

MemoType.Hash

type Hash = MemoTypeHash

Source: src/base/memo.ts:37

MemoType.ID

type ID = MemoTypeID

Source: src/base/memo.ts:35

MemoType.None

type None = MemoTypeNone

Source: src/base/memo.ts:34

MemoType.Return

type Return = MemoTypeReturn

Source: src/base/memo.ts:38

MemoType.Text

type Text = MemoTypeText

Source: src/base/memo.ts:36

MemoTypeHash

type MemoTypeHash = typeof MemoHash

Source: src/base/memo.ts:30

MemoTypeID

type MemoTypeID = typeof MemoID

Source: src/base/memo.ts:28

MemoTypeNone

type MemoTypeNone = typeof MemoNone

Source: src/base/memo.ts:27

MemoTypeReturn

type MemoTypeReturn = typeof MemoReturn

Source: src/base/memo.ts:31

MemoTypeText

type MemoTypeText = typeof MemoText

Source: src/base/memo.ts:29

MemoValue

type MemoValue = Buffer | string | null

Source: src/base/memo.ts:47

MuxedAccount

Represents a muxed account for transactions and operations.

A muxed (or multiplexed) account (defined rigorously in CAP-27 and briefly in SEP-23) is one that resolves a single Stellar G... account to many different underlying IDs.

For example, you may have a single Stellar address for accounting purposes: GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ

Yet would like to use it for 4 different family members: 1: MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAAAGZFQ 2: MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAAALIWQ 3: MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAAAPYHQ 4: MA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJUAAAAAAAAAAAAQLQQ

This object makes it easy to create muxed accounts from regular accounts, duplicate them, get/set the underlying IDs, etc. without mucking around with the raw XDR.

Because muxed accounts are purely an off-chain convention, they all share the sequence number tied to their underlying G… account. Thus, this object requires an Account instance to be passed in, so that muxed instances of an account can collectively modify the sequence number whenever a muxed account is used as the source of a Transaction with TransactionBuilder.

class MuxedAccount {
constructor(baseAccount: Account, id: string);
static fromAddress(mAddress: string, sequenceNum: string): MuxedAccount;
accountId(): string;
baseAccount(): Account;
equals(otherMuxedAccount: MuxedAccount): boolean;
id(): string;
incrementSequenceNumber(): void;
sequenceNumber(): string;
setId(id: string): MuxedAccount;
toXDRObject(): MuxedAccount;
}

See also

Source: src/base/muxed_account.ts:59

new MuxedAccount(baseAccount, id)

constructor(baseAccount: Account, id: string);

Parameters

  • baseAccountAccount (required) — the Account instance representing the underlying G… address
  • idstring (required) — a stringified uint64 value that represents the ID of the muxed account

Source: src/base/muxed_account.ts:71

MuxedAccount.fromAddress(mAddress, sequenceNum)

Parses an M-address into a MuxedAccount object.

static fromAddress(mAddress: string, sequenceNum: string): MuxedAccount;

Parameters

  • mAddressstring (required) — an M-address to transform
  • sequenceNumstring (required) — the sequence number of the underlying Account, to use for the underlying base account MuxedAccount.baseAccount. If you’re using the SDK, you can use server.loadAccount to fetch this if you don’t know it.

Source: src/base/muxed_account.ts:95

muxedAccount.accountId()

Returns the M-address representing this account’s (G-address, ID).

accountId(): string;

Source: src/base/muxed_account.ts:114

muxedAccount.baseAccount()

Returns the underlying account object shared among all muxed accounts with this Stellar address.

baseAccount(): Account;

Source: src/base/muxed_account.ts:107

muxedAccount.equals(otherMuxedAccount)

Checks whether two muxed accounts are equal by comparing their M-addresses.

equals(otherMuxedAccount: MuxedAccount): boolean;

Parameters

  • otherMuxedAccountMuxedAccount (required) — the MuxedAccount to compare against

Source: src/base/muxed_account.ts:170

muxedAccount.id()

Returns the uint64 ID of this muxed account as a string.

id(): string;

Source: src/base/muxed_account.ts:121

muxedAccount.incrementSequenceNumber()

Increments the underlying account’s sequence number by one.

incrementSequenceNumber(): void;

Source: src/base/muxed_account.ts:153

muxedAccount.sequenceNumber()

Returns the stringified sequence number for the underlying account.

sequenceNumber(): string;

Source: src/base/muxed_account.ts:146

muxedAccount.setId(id)

Updates the muxed account’s ID, regenerating the M-address accordingly.

setId(id: string): MuxedAccount;

Parameters

  • idstring (required) — a stringified uint64 value to set as the new muxed account ID

Source: src/base/muxed_account.ts:130

muxedAccount.toXDRObject()

Returns the XDR object representing this muxed account’s G-address and uint64 ID.

toXDRObject(): MuxedAccount;

Source: src/base/muxed_account.ts:161

Networks

Contains passphrases for common networks:

  • Networks.PUBLIC: Public Global Stellar Network ; September 2015
  • Networks.TESTNET: Test SDF Network ; September 2015
  • Networks.FUTURENET: Test SDF Future Network ; October 2022
  • Networks.SANDBOX: Local Sandbox Stellar Network ; September 2022
  • Networks.STANDALONE: Standalone Network ; February 2017
enum Networks

Source: src/base/network.ts:9

Operation

Operation class represents operations in Stellar network.

Use one of static methods to create operations:

class Operation {
constructor();
static accountMerge: (opts: AccountMergeOpts) => Operation2<AccountMergeResult>;
static allowTrust: (opts: AllowTrustOpts) => Operation2<AllowTrustResult>;
static beginSponsoringFutureReserves: (opts: BeginSponsoringFutureReservesOpts) => Operation2<BeginSponsoringFutureReservesResult>;
static bumpSequence: (opts: BumpSequenceOpts) => Operation2<BumpSequenceResult>;
static changeTrust: (opts: ChangeTrustOpts) => Operation2<ChangeTrustResult>;
static claimClaimableBalance: (opts: ClaimClaimableBalanceOpts = ...) => Operation2<ClaimClaimableBalanceResult>;
static clawback: (opts: ClawbackOpts) => Operation2<ClawbackResult>;
static clawbackClaimableBalance: (opts: ClawbackClaimableBalanceOpts = ...) => Operation2<ClawbackClaimableBalanceResult>;
static createAccount: (opts: CreateAccountOpts) => Operation2<CreateAccountResult>;
static createClaimableBalance: (opts: CreateClaimableBalanceOpts) => Operation2<CreateClaimableBalanceResult>;
static createCustomContract: (opts: CreateCustomContractOpts) => Operation2<InvokeHostFunctionResult>;
static createPassiveSellOffer: (opts: CreatePassiveSellOfferOpts) => Operation2<CreatePassiveSellOfferResult>;
static createStellarAssetContract: (opts: CreateStellarAssetContractOpts) => Operation2<InvokeHostFunctionResult>;
static endSponsoringFutureReserves: (opts: EndSponsoringFutureReservesOpts = {}) => Operation2<EndSponsoringFutureReservesResult>;
static extendFootprintTtl: (opts: ExtendFootprintTtlOpts) => Operation2<ExtendFootprintTTLResult>;
static inflation: (opts: InflationOpts = {}) => Operation2<InflationResult>;
static invokeContractFunction: (opts: InvokeContractFunctionOpts) => Operation2<InvokeHostFunctionResult>;
static invokeHostFunction: (opts: InvokeHostFunctionOpts) => Operation2<InvokeHostFunctionResult>;
static liquidityPoolDeposit: (opts: LiquidityPoolDepositOpts = ...) => Operation2<LiquidityPoolDepositResult>;
static liquidityPoolWithdraw: (opts: LiquidityPoolWithdrawOpts = ...) => Operation2<LiquidityPoolWithdrawResult>;
static manageBuyOffer: (opts: ManageBuyOfferOpts) => Operation2<ManageBuyOfferResult>;
static manageData: (opts: ManageDataOpts) => Operation2<ManageDataResult>;
static manageSellOffer: (opts: ManageSellOfferOpts) => Operation2<ManageSellOfferResult>;
static pathPaymentStrictReceive: (opts: PathPaymentStrictReceiveOpts) => Operation2<PathPaymentStrictReceiveResult>;
static pathPaymentStrictSend: (opts: PathPaymentStrictSendOpts) => Operation2<PathPaymentStrictSendResult>;
static payment: (opts: PaymentOpts) => Operation2<PaymentResult>;
static restoreFootprint: (opts: RestoreFootprintOpts = {}) => Operation2<RestoreFootprintResult>;
static revokeAccountSponsorship: (opts: RevokeAccountSponsorshipOpts = ...) => Operation2<RevokeAccountSponsorshipResult>;
static revokeClaimableBalanceSponsorship: (opts: RevokeClaimableBalanceSponsorshipOpts = ...) => Operation2<RevokeClaimableBalanceSponsorshipResult>;
static revokeDataSponsorship: (opts: RevokeDataSponsorshipOpts = ...) => Operation2<RevokeDataSponsorshipResult>;
static revokeLiquidityPoolSponsorship: (opts: RevokeLiquidityPoolSponsorshipOpts = ...) => Operation2<RevokeLiquidityPoolSponsorshipResult>;
static revokeOfferSponsorship: (opts: RevokeOfferSponsorshipOpts = ...) => Operation2<RevokeOfferSponsorshipResult>;
static revokeSignerSponsorship: (opts: RevokeSignerSponsorshipOpts = ...) => Operation2<RevokeSignerSponsorshipResult>;
static revokeTrustlineSponsorship: (opts: RevokeTrustlineSponsorshipOpts = ...) => Operation2<RevokeTrustlineSponsorshipResult>;
static setOptions: <T extends SignerOpts = never>(opts: SetOptionsOpts<T>) => Operation2<SetOptionsResult<T>>;
static setTrustLineFlags: (opts: SetTrustLineFlagsOpts) => Operation2<SetTrustLineFlagsResult>;
static uploadContractWasm: (opts: UploadContractWasmOpts) => Operation2<InvokeHostFunctionResult>;
static fromXDRObject<T extends OperationRecord = OperationRecord>(operation: Operation2<T>): T;
}

Source: src/base/operation.ts:131

new Operation()

constructor();

Operation.accountMerge

static accountMerge: (opts: AccountMergeOpts) => Operation2<AccountMergeResult>;

Source: src/base/operation.ts:436

Operation.allowTrust

static allowTrust: (opts: AllowTrustOpts) => Operation2<AllowTrustResult>;

Source: src/base/operation.ts:437

Operation.beginSponsoringFutureReserves

static beginSponsoringFutureReserves: (opts: BeginSponsoringFutureReservesOpts) => Operation2<BeginSponsoringFutureReservesResult>;

Source: src/base/operation.ts:453

Operation.bumpSequence

static bumpSequence: (opts: BumpSequenceOpts) => Operation2<BumpSequenceResult>;

Source: src/base/operation.ts:438

Operation.changeTrust

static changeTrust: (opts: ChangeTrustOpts) => Operation2<ChangeTrustResult>;

Source: src/base/operation.ts:439

Operation.claimClaimableBalance

static claimClaimableBalance: (opts: ClaimClaimableBalanceOpts = ...) => Operation2<ClaimClaimableBalanceResult>;

Source: src/base/operation.ts:442

Operation.clawback

static clawback: (opts: ClawbackOpts) => Operation2<ClawbackResult>;

Source: src/base/operation.ts:463

Operation.clawbackClaimableBalance

static clawbackClaimableBalance: (opts: ClawbackClaimableBalanceOpts = ...) => Operation2<ClawbackClaimableBalanceResult>;

Source: src/base/operation.ts:443

Operation.createAccount

static createAccount: (opts: CreateAccountOpts) => Operation2<CreateAccountResult>;

Source: src/base/operation.ts:440

Operation.createClaimableBalance

static createClaimableBalance: (opts: CreateClaimableBalanceOpts) => Operation2<CreateClaimableBalanceResult>;

Source: src/base/operation.ts:441

Operation.createCustomContract

static createCustomContract: (opts: CreateCustomContractOpts) => Operation2<InvokeHostFunctionResult>;

Source: src/base/operation.ts:475

Operation.createPassiveSellOffer

static createPassiveSellOffer: (opts: CreatePassiveSellOfferOpts) => Operation2<CreatePassiveSellOfferResult>;

Source: src/base/operation.ts:444

Operation.createStellarAssetContract

static createStellarAssetContract: (opts: CreateStellarAssetContractOpts) => Operation2<InvokeHostFunctionResult>;

Source: src/base/operation.ts:473

Operation.endSponsoringFutureReserves

static endSponsoringFutureReserves: (opts: EndSponsoringFutureReservesOpts = {}) => Operation2<EndSponsoringFutureReservesResult>;

Source: src/base/operation.ts:454

Operation.extendFootprintTtl

static extendFootprintTtl: (opts: ExtendFootprintTtlOpts) => Operation2<ExtendFootprintTTLResult>;

Source: src/base/operation.ts:468

Operation.inflation

static inflation: (opts: InflationOpts = {}) => Operation2<InflationResult>;

Source: src/base/operation.ts:445

Operation.invokeContractFunction

static invokeContractFunction: (opts: InvokeContractFunctionOpts) => Operation2<InvokeHostFunctionResult>;

Source: src/base/operation.ts:474

Operation.invokeHostFunction

static invokeHostFunction: (opts: InvokeHostFunctionOpts) => Operation2<InvokeHostFunctionResult>;

Source: src/base/operation.ts:467

Operation.liquidityPoolDeposit

static liquidityPoolDeposit: (opts: LiquidityPoolDepositOpts = ...) => Operation2<LiquidityPoolDepositResult>;

Source: src/base/operation.ts:465

Operation.liquidityPoolWithdraw

static liquidityPoolWithdraw: (opts: LiquidityPoolWithdrawOpts = ...) => Operation2<LiquidityPoolWithdrawResult>;

Source: src/base/operation.ts:466

Operation.manageBuyOffer

static manageBuyOffer: (opts: ManageBuyOfferOpts) => Operation2<ManageBuyOfferResult>;

Source: src/base/operation.ts:448

Operation.manageData

static manageData: (opts: ManageDataOpts) => Operation2<ManageDataResult>;

Source: src/base/operation.ts:446

Operation.manageSellOffer

static manageSellOffer: (opts: ManageSellOfferOpts) => Operation2<ManageSellOfferResult>;

Source: src/base/operation.ts:447

Operation.pathPaymentStrictReceive

static pathPaymentStrictReceive: (opts: PathPaymentStrictReceiveOpts) => Operation2<PathPaymentStrictReceiveResult>;

Source: src/base/operation.ts:449

Operation.pathPaymentStrictSend

static pathPaymentStrictSend: (opts: PathPaymentStrictSendOpts) => Operation2<PathPaymentStrictSendResult>;

Source: src/base/operation.ts:450

Operation.payment

static payment: (opts: PaymentOpts) => Operation2<PaymentResult>;

Source: src/base/operation.ts:451

Operation.restoreFootprint

static restoreFootprint: (opts: RestoreFootprintOpts = {}) => Operation2<RestoreFootprintResult>;

Source: src/base/operation.ts:469

Operation.revokeAccountSponsorship

static revokeAccountSponsorship: (opts: RevokeAccountSponsorshipOpts = ...) => Operation2<RevokeAccountSponsorshipResult>;

Source: src/base/operation.ts:455

Operation.revokeClaimableBalanceSponsorship

static revokeClaimableBalanceSponsorship: (opts: RevokeClaimableBalanceSponsorshipOpts = ...) => Operation2<RevokeClaimableBalanceSponsorshipResult>;

Source: src/base/operation.ts:459

Operation.revokeDataSponsorship

static revokeDataSponsorship: (opts: RevokeDataSponsorshipOpts = ...) => Operation2<RevokeDataSponsorshipResult>;

Source: src/base/operation.ts:458

Operation.revokeLiquidityPoolSponsorship

static revokeLiquidityPoolSponsorship: (opts: RevokeLiquidityPoolSponsorshipOpts = ...) => Operation2<RevokeLiquidityPoolSponsorshipResult>;

Source: src/base/operation.ts:461

Operation.revokeOfferSponsorship

static revokeOfferSponsorship: (opts: RevokeOfferSponsorshipOpts = ...) => Operation2<RevokeOfferSponsorshipResult>;

Source: src/base/operation.ts:457

Operation.revokeSignerSponsorship

static revokeSignerSponsorship: (opts: RevokeSignerSponsorshipOpts = ...) => Operation2<RevokeSignerSponsorshipResult>;

Source: src/base/operation.ts:462

Operation.revokeTrustlineSponsorship

static revokeTrustlineSponsorship: (opts: RevokeTrustlineSponsorshipOpts = ...) => Operation2<RevokeTrustlineSponsorshipResult>;

Source: src/base/operation.ts:456

Operation.setOptions

static setOptions: <T extends SignerOpts = never>(opts: SetOptionsOpts<T>) => Operation2<SetOptionsResult<T>>;

Source: src/base/operation.ts:452

Operation.setTrustLineFlags

static setTrustLineFlags: (opts: SetTrustLineFlagsOpts) => Operation2<SetTrustLineFlagsResult>;

Source: src/base/operation.ts:464

Operation.uploadContractWasm

static uploadContractWasm: (opts: UploadContractWasmOpts) => Operation2<InvokeHostFunctionResult>;

Source: src/base/operation.ts:476

Operation.fromXDRObject(operation)

Deconstructs the raw XDR operation object into the structured object that was used to create the operation (i.e. the opts parameter to most ops).

static fromXDRObject<T extends OperationRecord = OperationRecord>(operation: Operation2<T>): T;

Parameters

  • operationOperation2<T> (required) — An XDR Operation.

Source: src/base/operation.ts:139

Operation.AccountMerge

type AccountMerge = AccountMergeResult

Source: src/base/operation.ts:613

Operation.AllowTrust

type AllowTrust = AllowTrustResult

Source: src/base/operation.ts:612

Operation.BaseOperation

type BaseOperation<T extends _OperationType = _OperationType> = _BaseOperation<T>

Source: src/base/operation.ts:601

Operation.BeginSponsoringFutureReserves

type BeginSponsoringFutureReserves = BeginSponsoringFutureReservesResult

Source: src/base/operation.ts:619

Operation.BumpSequence

type BumpSequence = BumpSequenceResult

Source: src/base/operation.ts:616

Operation.ChangeTrust

type ChangeTrust = ChangeTrustResult

Source: src/base/operation.ts:611

Operation.ClaimClaimableBalance

type ClaimClaimableBalance = ClaimClaimableBalanceResult

Source: src/base/operation.ts:618

Operation.Clawback

type Clawback = ClawbackResult

Source: src/base/operation.ts:631

Operation.ClawbackClaimableBalance

type ClawbackClaimableBalance = ClawbackClaimableBalanceResult

Source: src/base/operation.ts:632

Operation.CreateAccount

type CreateAccount = CreateAccountResult

Source: src/base/operation.ts:603

Operation.CreateClaimableBalance

type CreateClaimableBalance = CreateClaimableBalanceResult

Source: src/base/operation.ts:617

Operation.CreatePassiveSellOffer

type CreatePassiveSellOffer = CreatePassiveSellOfferResult

Source: src/base/operation.ts:607

Operation.EndSponsoringFutureReserves

type EndSponsoringFutureReserves = EndSponsoringFutureReservesResult

Source: src/base/operation.ts:621

Operation.ExtendFootprintTTL

type ExtendFootprintTTL = ExtendFootprintTTLResult

Source: src/base/operation.ts:637

Operation.Inflation

type Inflation = InflationResult

Source: src/base/operation.ts:614

Operation.InvokeHostFunction

type InvokeHostFunction = InvokeHostFunctionResult

Source: src/base/operation.ts:636

Operation.LiquidityPoolDeposit

type LiquidityPoolDeposit = LiquidityPoolDepositResult

Source: src/base/operation.ts:634

Operation.LiquidityPoolWithdraw

type LiquidityPoolWithdraw = LiquidityPoolWithdrawResult

Source: src/base/operation.ts:635

Operation.ManageBuyOffer

type ManageBuyOffer = ManageBuyOfferResult

Source: src/base/operation.ts:609

Operation.ManageData

type ManageData = ManageDataResult

Source: src/base/operation.ts:615

Operation.ManageSellOffer

type ManageSellOffer = ManageSellOfferResult

Source: src/base/operation.ts:608

Operation.PathPaymentStrictReceive

type PathPaymentStrictReceive = PathPaymentStrictReceiveResult

Source: src/base/operation.ts:605

Operation.PathPaymentStrictSend

type PathPaymentStrictSend = PathPaymentStrictSendResult

Source: src/base/operation.ts:606

Operation.Payment

type Payment = PaymentResult

Source: src/base/operation.ts:604

Operation.RestoreFootprint

type RestoreFootprint = RestoreFootprintResult

Source: src/base/operation.ts:638

Operation.RevokeAccountSponsorship

type RevokeAccountSponsorship = RevokeAccountSponsorshipResult

Source: src/base/operation.ts:622

Operation.RevokeClaimableBalanceSponsorship

type RevokeClaimableBalanceSponsorship = RevokeClaimableBalanceSponsorshipResult

Source: src/base/operation.ts:626

Operation.RevokeDataSponsorship

type RevokeDataSponsorship = RevokeDataSponsorshipResult

Source: src/base/operation.ts:625

Operation.RevokeLiquidityPoolSponsorship

type RevokeLiquidityPoolSponsorship = RevokeLiquidityPoolSponsorshipResult

Source: src/base/operation.ts:628

Operation.RevokeOfferSponsorship

type RevokeOfferSponsorship = RevokeOfferSponsorshipResult

Source: src/base/operation.ts:624

Operation.RevokeSignerSponsorship

type RevokeSignerSponsorship = RevokeSignerSponsorshipResult

Source: src/base/operation.ts:630

Operation.RevokeTrustlineSponsorship

type RevokeTrustlineSponsorship = RevokeTrustlineSponsorshipResult

Source: src/base/operation.ts:623

Operation.SetOptions

type SetOptions = SetOptionsResult<Signer>

Source: src/base/operation.ts:610

Operation.SetTrustLineFlags

type SetTrustLineFlags = SetTrustLineFlagsResult

Source: src/base/operation.ts:633

OperationOptions

type OperationOptions = AccountMergeOpts | AllowTrustOpts | BeginSponsoringFutureReservesOpts | BumpSequenceOpts | ChangeTrustOpts | ClaimClaimableBalanceOpts | ClawbackClaimableBalanceOpts | ClawbackOpts | CreateAccountOpts | CreateClaimableBalanceOpts | CreateCustomContractOpts | CreatePassiveSellOfferOpts | CreateStellarAssetContractOpts | EndSponsoringFutureReservesOpts | ExtendFootprintTtlOpts | InflationOpts | InvokeContractFunctionOpts | InvokeHostFunctionOpts | LiquidityPoolDepositOpts | LiquidityPoolWithdrawOpts | ManageBuyOfferOpts | ManageDataOpts | ManageSellOfferOpts | PathPaymentStrictReceiveOpts | PathPaymentStrictSendOpts | PaymentOpts | RestoreFootprintOpts | RevokeAccountSponsorshipOpts | RevokeClaimableBalanceSponsorshipOpts | RevokeDataSponsorshipOpts | RevokeLiquidityPoolSponsorshipOpts | RevokeOfferSponsorshipOpts | RevokeSignerSponsorshipOpts | RevokeTrustlineSponsorshipOpts | SetOptionsOpts | SetTrustLineFlagsOpts | UploadContractWasmOpts

Source: src/base/operations/types.ts:311

OperationRecord

Union of all possible operation objects returned by Operation.fromXDRObject.

type OperationRecord = AccountMergeResult | AllowTrustResult | BeginSponsoringFutureReservesResult | BumpSequenceResult | ChangeTrustResult | ClaimClaimableBalanceResult | ClawbackClaimableBalanceResult | ClawbackResult | CreateAccountResult | CreateClaimableBalanceResult | CreatePassiveSellOfferResult | EndSponsoringFutureReservesResult | ExtendFootprintTTLResult | InflationResult | InvokeHostFunctionResult | LiquidityPoolDepositResult | LiquidityPoolWithdrawResult | ManageBuyOfferResult | ManageDataResult | ManageSellOfferResult | PathPaymentStrictReceiveResult | PathPaymentStrictSendResult | PaymentResult | RestoreFootprintResult | RevokeAccountSponsorshipResult | RevokeClaimableBalanceSponsorshipResult | RevokeDataSponsorshipResult | RevokeLiquidityPoolSponsorshipResult | RevokeOfferSponsorshipResult | RevokeSignerSponsorshipResult | RevokeTrustlineSponsorshipResult | SetOptionsResult<SignerOpts> | SetTrustLineFlagsResult

Source: src/base/operations/types.ts:677

OperationType

type OperationType = OperationType.AccountMerge | OperationType.AllowTrust | OperationType.BeginSponsoringFutureReserves | OperationType.BumpSequence | OperationType.ChangeTrust | OperationType.ClaimClaimableBalance | OperationType.Clawback | OperationType.ClawbackClaimableBalance | OperationType.CreateAccount | OperationType.CreateClaimableBalance | OperationType.CreatePassiveSellOffer | OperationType.EndSponsoringFutureReserves | OperationType.ExtendFootprintTTL | OperationType.Inflation | OperationType.InvokeHostFunction | OperationType.LiquidityPoolDeposit | OperationType.LiquidityPoolWithdraw | OperationType.ManageBuyOffer | OperationType.ManageData | OperationType.ManageSellOffer | OperationType.PathPaymentStrictReceive | OperationType.PathPaymentStrictSend | OperationType.Payment | OperationType.RestoreFootprint | OperationType.RevokeAccountSponsorship | OperationType.RevokeClaimableBalanceSponsorship | OperationType.RevokeDataSponsorship | OperationType.RevokeLiquidityPoolSponsorship | OperationType.RevokeOfferSponsorship | OperationType.RevokeSignerSponsorship | OperationType.RevokeTrustlineSponsorship | OperationType.SetOptions | OperationType.SetTrustLineFlags

Source: src/base/operations/types.ts:354

OperationType.AccountMerge

type AccountMerge = "accountMerge"

Source: src/base/operations/types.ts:365

OperationType.AllowTrust

type AllowTrust = "allowTrust"

Source: src/base/operations/types.ts:364

OperationType.BeginSponsoringFutureReserves

type BeginSponsoringFutureReserves = "beginSponsoringFutureReserves"

Source: src/base/operations/types.ts:371

OperationType.BumpSequence

type BumpSequence = "bumpSequence"

Source: src/base/operations/types.ts:368

OperationType.ChangeTrust

type ChangeTrust = "changeTrust"

Source: src/base/operations/types.ts:363

OperationType.ClaimClaimableBalance

type ClaimClaimableBalance = "claimClaimableBalance"

Source: src/base/operations/types.ts:370

OperationType.Clawback

type Clawback = "clawback"

Source: src/base/operations/types.ts:383

OperationType.ClawbackClaimableBalance

type ClawbackClaimableBalance = "clawbackClaimableBalance"

Source: src/base/operations/types.ts:384

OperationType.CreateAccount

type CreateAccount = "createAccount"

Source: src/base/operations/types.ts:355

OperationType.CreateClaimableBalance

type CreateClaimableBalance = "createClaimableBalance"

Source: src/base/operations/types.ts:369

OperationType.CreatePassiveSellOffer

type CreatePassiveSellOffer = "createPassiveSellOffer"

Source: src/base/operations/types.ts:359

OperationType.EndSponsoringFutureReserves

type EndSponsoringFutureReserves = "endSponsoringFutureReserves"

Source: src/base/operations/types.ts:372

OperationType.ExtendFootprintTTL

type ExtendFootprintTTL = "extendFootprintTtl"

Source: src/base/operations/types.ts:389

OperationType.Inflation

type Inflation = "inflation"

Source: src/base/operations/types.ts:366

OperationType.InvokeHostFunction

type InvokeHostFunction = "invokeHostFunction"

Source: src/base/operations/types.ts:388

OperationType.LiquidityPoolDeposit

type LiquidityPoolDeposit = "liquidityPoolDeposit"

Source: src/base/operations/types.ts:386

OperationType.LiquidityPoolWithdraw

type LiquidityPoolWithdraw = "liquidityPoolWithdraw"

Source: src/base/operations/types.ts:387

OperationType.ManageBuyOffer

type ManageBuyOffer = "manageBuyOffer"

Source: src/base/operations/types.ts:361

OperationType.ManageData

type ManageData = "manageData"

Source: src/base/operations/types.ts:367

OperationType.ManageSellOffer

type ManageSellOffer = "manageSellOffer"

Source: src/base/operations/types.ts:360

OperationType.PathPaymentStrictReceive

type PathPaymentStrictReceive = "pathPaymentStrictReceive"

Source: src/base/operations/types.ts:357

OperationType.PathPaymentStrictSend

type PathPaymentStrictSend = "pathPaymentStrictSend"

Source: src/base/operations/types.ts:358

OperationType.Payment

type Payment = "payment"

Source: src/base/operations/types.ts:356

OperationType.RestoreFootprint

type RestoreFootprint = "restoreFootprint"

Source: src/base/operations/types.ts:390

OperationType.RevokeAccountSponsorship

type RevokeAccountSponsorship = "revokeAccountSponsorship"

Source: src/base/operations/types.ts:375

OperationType.RevokeClaimableBalanceSponsorship

type RevokeClaimableBalanceSponsorship = "revokeClaimableBalanceSponsorship"

Source: src/base/operations/types.ts:379

OperationType.RevokeDataSponsorship

type RevokeDataSponsorship = "revokeDataSponsorship"

Source: src/base/operations/types.ts:378

OperationType.RevokeLiquidityPoolSponsorship

type RevokeLiquidityPoolSponsorship = "revokeLiquidityPoolSponsorship"

Source: src/base/operations/types.ts:381

OperationType.RevokeOfferSponsorship

type RevokeOfferSponsorship = "revokeOfferSponsorship"

Source: src/base/operations/types.ts:377

OperationType.RevokeSignerSponsorship

type RevokeSignerSponsorship = "revokeSignerSponsorship"

Source: src/base/operations/types.ts:382

OperationType.RevokeSponsorship

Deprecated. Never emitted by fromXDRObject — use the specific Revoke* types instead.

type RevokeSponsorship = "revokeSponsorship"

Source: src/base/operations/types.ts:374

OperationType.RevokeTrustlineSponsorship

type RevokeTrustlineSponsorship = "revokeTrustlineSponsorship"

Source: src/base/operations/types.ts:376

OperationType.SetOptions

type SetOptions = "setOptions"

Source: src/base/operations/types.ts:362

OperationType.SetTrustLineFlags

type SetTrustLineFlags = "setTrustLineFlags"

Source: src/base/operations/types.ts:385

ScInt

Provides an easier way to manipulate large numbers for Stellar operations.

You can instantiate this “smart contract integer” value either from bigints, strings, or numbers (whole numbers, or this will throw).

If you need to create a native BigInt from a list of integer “parts” (for example, you have a series of encoded 32-bit integers that represent a larger value), you can use the lower level abstraction XdrLargeInt. For example, you could do new XdrLargeInt('u128', bytes...).toBigInt().

class ScInt extends XdrLargeInt {
constructor(value: string | number | bigint, opts?: { type?: ScIntType; [key: string]: unknown });
static getType(scvType: string): ScIntType | undefined;
static isType(type: string): type is ScIntType;
int: LargeInt;
type: ScIntType;
toBigInt(): bigint;
toDuration(): ScVal;
toI128(): ScVal;
toI256(): ScVal;
toI64(): ScVal;
toJSON(): { type: string; value: string };
toNumber(): number;
toScVal(): ScVal;
toString(): string;
toTimepoint(): ScVal;
toU128(): ScVal;
toU256(): ScVal;
toU64(): ScVal;
valueOf(): unknown;
}

Example

import { xdr, ScInt, scValToBigInt } from "@stellar/stellar-base";
// You have an ScVal from a contract and want to parse it into JS native.
const value = xdr.ScVal.fromXDR(someXdr, "base64");
const bigi = scValToBigInt(value); // grab it as a BigInt
let sci = new ScInt(bigi);
sci.toNumber(); // gives native JS type (w/ size check)
sci.toBigInt(); // gives the native BigInt value
sci.toU64(); // gives ScValType-specific XDR constructs (with size checks)
// You have a number and want to shove it into a contract.
sci = new ScInt(0xdeadcafebabe);
sci.toBigInt() // returns 244838016400062n
sci.toNumber() // throws: too large
// Pass any to e.g. a Contract.call(), conversion happens automatically
// regardless of the initial type.
const scValU128 = sci.toU128();
const scValI256 = sci.toI256();
const scValU64 = sci.toU64();
// Lots of ways to initialize:
new ScInt("123456789123456789")
new ScInt(123456789123456789n);
new ScInt(1n << 140n);
new ScInt(-42);
new ScInt(scValToBigInt(scValU128)); // from above
// If you know the type ahead of time (accessing `.raw` is faster than
// conversions), you can specify the type directly (otherwise, it's
// interpreted from the numbers you pass in):
const i = new ScInt(123456789n, { type: "u256" });
// For example, you can use the underlying `sdk.U256` and convert it to an
// `xdr.ScVal` directly like so:
const scv = new xdr.ScVal.scvU256(i.raw);
// Or reinterpret it as a different type (size permitting):
const scv = i.toI64();

Source: src/base/numbers/sc_int.ts:63

new ScInt(value, opts)

constructor(value: string | number | bigint, opts?: { type?: ScIntType; [key: string]: unknown });

Parameters

  • valuestring | number | bigint (required) — a single, integer-like value which will be interpreted in the smallest appropriate XDR type supported by Stellar (64, 128, or 256 bit integer values). signed values are supported, though they are sanity-checked against opts.type. if you need 32-bit values, you can construct them directly without needing this wrapper, e.g. xdr.ScVal.scvU32(1234).
  • opts{ type?: ScIntType; [key: string]: unknown } (optional) — an optional object controlling optional parameters
    • type: specify a type (‘i64’, ‘u64’, ‘i128’, ‘u128’, ‘i256’, or ‘u256’) to override the default type selection. If not specified, the smallest type that fits the value is used.

Source: src/base/numbers/sc_int.ts:76

ScInt.getType(scvType)

Convert the raw ScValType string (e.g. ‘scvI128’, generated by the XDR) to a type description for XdrLargeInt construction (e.g. ‘i128’)

static getType(scvType: string): ScIntType | undefined;

Parameters

  • scvTypestring (required) — the xdr.ScValType as a string

Returns

the corresponding ScIntType if it’s an integer type, or undefined if it’s not an integer type

Source: src/base/numbers/xdr_large_int.ts:322

ScInt.isType(type)

Returns true if the given string is a valid XDR large integer type name.

static isType(type: string): type is ScIntType;

Parameters

  • typestring (required)

Source: src/base/numbers/xdr_large_int.ts:298

scInt.int

int: LargeInt;

Source: src/base/numbers/xdr_large_int.ts:36

scInt.type

type: ScIntType;

Source: src/base/numbers/xdr_large_int.ts:37

scInt.toBigInt()

Converts to a native BigInt.

toBigInt(): bigint;

Source: src/base/numbers/xdr_large_int.ts:116

scInt.toDuration()

The integer encoded with ScValType = Duration

toDuration(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:152

scInt.toI128()

The integer encoded with ScValType = I128.

toI128(): ScVal;

Throws

  • if the value cannot fit in 128 bits

Source: src/base/numbers/xdr_large_int.ts:164

scInt.toI256()

The integer encoded with ScValType = I256

toI256(): ScVal;

Throws

  • if the value cannot fit in a signed 256-bit integer

Source: src/base/numbers/xdr_large_int.ts:204

scInt.toI64()

The integer encoded with ScValType = I64.

toI64(): ScVal;

Throws

  • if the value cannot fit in 64 bits

Source: src/base/numbers/xdr_large_int.ts:125

scInt.toJSON()

Returns a JSON-friendly representation with value and type fields.

toJSON(): { type: string; value: string };

Source: src/base/numbers/xdr_large_int.ts:284

scInt.toNumber()

Converts to a native JS number.

toNumber(): number;

Throws

  • if the value can’t fit into a Number

Source: src/base/numbers/xdr_large_int.ts:103

scInt.toScVal()

The smallest interpretation of the stored value

toScVal(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:247

scInt.toString()

Returns the string representation of this integer.

toString(): string;

Source: src/base/numbers/xdr_large_int.ts:279

scInt.toTimepoint()

The integer encoded with ScValType = Timepoint

toTimepoint(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:144

scInt.toU128()

The integer encoded with ScValType = U128.

toU128(): ScVal;

Throws

  • if the value cannot fit in 128 bits

Source: src/base/numbers/xdr_large_int.ts:187

scInt.toU256()

The integer encoded with ScValType = U256

Note: No size check needed - U256 is the largest unsigned type.

toU256(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:229

scInt.toU64()

The integer encoded with ScValType = U64

toU64(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:136

scInt.valueOf()

Returns the primitive value of this integer.

valueOf(): unknown;

Source: src/base/numbers/xdr_large_int.ts:274

ScIntType

type ScIntType = "duration" | "i64" | "i128" | "i256" | "timepoint" | "u64" | "u128" | "u256"

Source: src/base/numbers/xdr_large_int.ts:18

Signer

type Signer = Signer.Ed25519PublicKey | Signer.Ed25519SignedPayload | Signer.PreAuthTx | Signer.Sha256Hash

Source: src/base/operations/types.ts:453

Signer.Ed25519PublicKey

interface Ed25519PublicKey {
ed25519PublicKey: string;
weight?: number;
}

Source: src/base/operations/types.ts:454

ed25519PublicKey.ed25519PublicKey

ed25519PublicKey: string;

Source: src/base/operations/types.ts:455

ed25519PublicKey.weight

weight?: number;

Source: src/base/operations/types.ts:456

Signer.Ed25519SignedPayload

interface Ed25519SignedPayload {
ed25519SignedPayload: string;
weight?: number;
}

Source: src/base/operations/types.ts:466

ed25519SignedPayload.ed25519SignedPayload

ed25519SignedPayload: string;

Source: src/base/operations/types.ts:467

ed25519SignedPayload.weight

weight?: number;

Source: src/base/operations/types.ts:468

Signer.PreAuthTx

interface PreAuthTx {
preAuthTx: Buffer;
weight?: number;
}

Source: src/base/operations/types.ts:462

preAuthTx.preAuthTx

preAuthTx: Buffer;

Source: src/base/operations/types.ts:463

preAuthTx.weight

weight?: number;

Source: src/base/operations/types.ts:464

Signer.Sha256Hash

interface Sha256Hash {
sha256Hash: Buffer;
weight?: number;
}

Source: src/base/operations/types.ts:458

sha256Hash.sha256Hash

sha256Hash: Buffer;

Source: src/base/operations/types.ts:459

sha256Hash.weight

weight?: number;

Source: src/base/operations/types.ts:460

SorobanFees

Soroban fee parameters for resource-limited transactions.

interface SorobanFees {
instructions: number;
readBytes: number;
resourceFee: bigint;
writeBytes: number;
}

Source: src/base/transaction_builder.ts:49

sorobanFees.instructions

The number of instructions executed by the transaction.

instructions: number;

Source: src/base/transaction_builder.ts:51

sorobanFees.readBytes

The number of bytes read from the ledger by the transaction.

readBytes: number;

Source: src/base/transaction_builder.ts:53

sorobanFees.resourceFee

The fee to be paid for the transaction, in stroops.

resourceFee: bigint;

Source: src/base/transaction_builder.ts:57

sorobanFees.writeBytes

The number of bytes written to the ledger by the transaction.

writeBytes: number;

Source: src/base/transaction_builder.ts:55

TimeoutInfinite

const TimeoutInfinite: 0

See also

    • TransactionBuilder.setTimeout
  • Timeout

Source: src/base/transaction_builder.ts:44

Transaction

Use TransactionBuilder to build a transaction object. If you have an object or base64-encoded string of the transaction envelope XDR, use TransactionBuilder.fromXDR.

Once a Transaction has been created, its attributes and operations should not be changed. You should only add signatures (using Transaction.sign) to a Transaction object before submitting to the network or forwarding on to additional signers.

class Transaction {
constructor(envelope: string | TransactionEnvelope, networkPassphrase: string);
extraSigners: SignerKey[] | undefined;
fee: string;
ledgerBounds: { maxLedger: number; minLedger: number } | undefined;
memo: Memo<MemoType>;
minAccountSequence: string | undefined;
minAccountSequenceAge: bigint | undefined;
minAccountSequenceLedgerGap: number | undefined;
networkPassphrase: string;
operations: OperationRecord[];
sequence: string;
signatures: DecoratedSignature[];
source: string;
timeBounds: { maxTime: string; minTime: string } | undefined;
tx: TTx;
addDecoratedSignature(signature: DecoratedSignature): void;
addSignature(publicKey: string = "", signature: string = ""): void;
getClaimableBalanceId(opIndex: number): string;
getKeypairSignature(keypair: Keypair): string;
hash(): Buffer;
sign(...keypairs: Keypair[]): void;
signatureBase(): Buffer;
signHashX(preimage: string | Buffer<ArrayBufferLike>): void;
toEnvelope(): TransactionEnvelope;
toXDR(): string;
}

Source: src/base/transaction.ts:25

new Transaction(envelope, networkPassphrase)

constructor(envelope: string | TransactionEnvelope, networkPassphrase: string);

Parameters

  • envelopestring | TransactionEnvelope (required) — transaction envelope object or base64 encoded string
  • networkPassphrasestring (required) — passphrase of the target stellar network (e.g. “Public Global Stellar Network ; September 2015”)

Source: src/base/transaction.ts:45

transaction.extraSigners

Array of extra signers as XDR objects; use SignerKey.encodeSignerKey to convert to StrKey strings.

extraSigners: SignerKey[] | undefined;

Source: src/base/transaction.ts:199

transaction.fee

The total fee for this transaction, in stroops.

fee: string;

Source: src/base/transaction_base.ts:76

transaction.ledgerBounds

The ledger bounds for this transaction, with minLedger (uint32) and maxLedger (uint32, or 0 for no upper bound).

ledgerBounds: { maxLedger: number; minLedger: number } | undefined;

Source: src/base/transaction.ts:164

transaction.memo

The memo attached to this transaction.

memo: Memo<MemoType>;

Source: src/base/transaction.ts:231

transaction.minAccountSequence

The minimum account sequence (64-bit, as a string).

minAccountSequence: string | undefined;

Source: src/base/transaction.ts:172

transaction.minAccountSequenceAge

The minimum account sequence age (64-bit number of seconds).

minAccountSequenceAge: bigint | undefined;

Source: src/base/transaction.ts:180

transaction.minAccountSequenceLedgerGap

The minimum account sequence ledger gap (32-bit number of ledgers).

minAccountSequenceLedgerGap: number | undefined;

Source: src/base/transaction.ts:188

transaction.networkPassphrase

The network passphrase for this transaction.

networkPassphrase: string;

Source: src/base/transaction_base.ts:85

transaction.operations

The list of operations in this transaction.

operations: OperationRecord[];

Source: src/base/transaction.ts:223

transaction.sequence

The sequence number for this transaction.

sequence: string;

Source: src/base/transaction.ts:207

transaction.signatures

The list of signatures for this transaction.

signatures: DecoratedSignature[];

Source: src/base/transaction_base.ts:35

transaction.source

The source account for this transaction.

source: string;

Source: src/base/transaction.ts:215

transaction.timeBounds

The time bounds for this transaction, with minTime and maxTime as 64-bit unix timestamps (strings).

timeBounds: { maxTime: string; minTime: string } | undefined;

Source: src/base/transaction.ts:153

transaction.tx

The underlying XDR transaction object.

Returns a defensive copy so that external mutations cannot alter the transaction that will be signed or serialized.

tx: TTx;

Throws

  • if the internal transaction is not a recognized XDR type

Source: src/base/transaction_base.ts:51

transaction.addDecoratedSignature(signature)

Add a decorated signature directly to the transaction envelope.

addDecoratedSignature(signature: DecoratedSignature): void;

Parameters

  • signatureDecoratedSignature (required) — raw signature to add

See also

    • Keypair.signDecorated
  • Keypair.signPayloadDecorated

Source: src/base/transaction_base.ts:196

transaction.addSignature(publicKey, signature)

Add a signature to the transaction. Useful when a party wants to pre-sign a transaction but doesn’t want to give access to their secret keys. This will also verify whether the signature is valid.

Here’s how you would use this feature to solicit multiple signatures.

  • Use TransactionBuilder to build a new transaction.
  • Make sure to set a long enough timeout on that transaction to give your signers enough time to sign!
  • Once you build the transaction, use transaction.toXDR() to get the base64-encoded XDR string.
  • Warning! Once you’ve built this transaction, don’t submit any other transactions onto your account! Doing so will invalidate this pre-compiled transaction!
  • Send this XDR string to your other parties. They can use the instructions for getKeypairSignature to sign the transaction.
  • They should send you back their publicKey and the signature string from getKeypairSignature, both of which you pass to this function.
addSignature(publicKey: string = "", signature: string = ""): void;

Parameters

  • publicKeystring (optional) (default: "") — the public key of the signer
  • signaturestring (optional) (default: "") — the base64 value of the signature XDR

Source: src/base/transaction_base.ts:156

transaction.getClaimableBalanceId(opIndex)

Calculate the claimable balance ID for an operation within the transaction.

getClaimableBalanceId(opIndex: number): string;

Parameters

  • opIndexnumber (required) — the index of the CreateClaimableBalance op

Throws

  • for invalid opIndex value, if op at opIndex is not CreateClaimableBalance, or for general XDR un/marshalling failures

See also

Source: src/base/transaction.ts:321

transaction.getKeypairSignature(keypair)

Signs a transaction with the given Keypair. Useful if someone sends you a transaction XDR for you to sign and return (see addSignature for more information).

When you get a transaction XDR to sign…

  • Instantiate a Transaction object with the XDR
  • Use Keypair to generate a keypair object for your Stellar seed.
  • Run getKeypairSignature with that keypair
  • Send back the signature along with your publicKey (not your secret seed!)

Example:

// `transactionXDR` is a string from the person generating the transaction
const transaction = new Transaction(transactionXDR, networkPassphrase);
const keypair = Keypair.fromSecret(myStellarSeed);
return transaction.getKeypairSignature(keypair);

Returns the base64-encoded signature string for the given keypair.

getKeypairSignature(keypair: Keypair): string;

Parameters

  • keypairKeypair (required) — Keypair of signer

Source: src/base/transaction_base.ts:129

transaction.hash()

Returns a hash for this transaction, suitable for signing.

hash(): Buffer;

Source: src/base/transaction_base.ts:222

transaction.sign(keypairs)

Signs the transaction with the given Keypair.

sign(...keypairs: Keypair[]): void;

Parameters

  • ...keypairsKeypair[] (required) — Keypairs of signers

Source: src/base/transaction_base.ts:97

transaction.signatureBase()

Returns the “signature base” of this transaction, which is the value that, when hashed, should be signed to create a signature that validators on the Stellar Network will accept.

It is composed of a 4 prefix bytes followed by the xdr-encoded form of this transaction.

signatureBase(): Buffer;

Source: src/base/transaction.ts:246

transaction.signHashX(preimage)

Add hashX signer preimage as signature.

signHashX(preimage: string | Buffer<ArrayBufferLike>): void;

Parameters

  • preimagestring | Buffer<ArrayBufferLike> (required) — preimage of hash used as signer

Source: src/base/transaction_base.ts:204

transaction.toEnvelope()

To envelope returns a xdr.TransactionEnvelope which can be submitted to the network.

toEnvelope(): TransactionEnvelope;

Source: src/base/transaction.ts:279

transaction.toXDR()

Returns the transaction envelope as a base64-encoded XDR string.

toXDR(): string;

Source: src/base/transaction_base.ts:239

TransactionBuilder

Transaction builder helps constructs a new [`Transaction`](#transaction) using the given `Account` as the transaction's "source account". The transaction will use the current sequence number of the given account as its sequence number and increment the given account's sequence number by one. The given source account must include a private key for signing the transaction or an error will be thrown.

Operations can be added to the transaction via their corresponding builder methods, and each returns the TransactionBuilder object so they can be chained together. After adding the desired operations, call the `build()` method on the `TransactionBuilder` to return a fully constructed `Transaction` that can be signed. The returned transaction will contain the sequence number of the source account and include the signature from the source account.

Be careful about unsubmitted transactions! When you build a transaction, `stellar-sdk` automatically increments the source account's sequence number. If you end up not submitting this transaction and submitting another one instead, it'll fail due to the sequence number being wrong. So if you decide not to use a built transaction, make sure to update the source account's sequence number with [Server.loadAccount](https://stellar.github.io/js-stellar-sdk/Server.html#loadAccount) before creating another transaction.

The following code example creates a new transaction with `Operation.createAccount` and `Operation.payment` operations. The Transaction's source account first funds `destinationA`, then sends a payment to `destinationB`. The built transaction is then signed by `sourceKeypair`.

var transaction = new TransactionBuilder(source, { fee, networkPassphrase: Networks.TESTNET })
.addOperation(Operation.createAccount({
destination: destinationA,
startingBalance: "20"
})) // <- funds and creates destinationA
.addOperation(Operation.payment({
destination: destinationB,
amount: "100",
asset: Asset.native()
})) // <- sends 100 XLM to destinationB
.setTimeout(30)
.build();
transaction.sign(sourceKeypair);
class TransactionBuilder {
constructor(sourceAccount: Account | MuxedAccount, opts: TransactionBuilderOptions = ...);
static buildFeeBumpTransaction(feeSource: string | Keypair, baseFee: string, innerTx: Transaction, networkPassphrase: string): FeeBumpTransaction;
static cloneFrom(tx: Transaction, opts: Partial<TransactionBuilderOptions> = {}): TransactionBuilder;
static fromXDR(envelope: string | TransactionEnvelope, networkPassphrase: string): Transaction | FeeBumpTransaction;
baseFee: string;
extraSigners: string[] | null;
ledgerbounds: { maxLedger?: number; minLedger?: number } | null;
memo: Memo;
minAccountSequence: string | null;
minAccountSequenceAge: bigint | null;
minAccountSequenceLedgerGap: number | null;
networkPassphrase: string | null;
operations: Operation2<OperationRecord>[];
sorobanData: SorobanTransactionData | null;
source: Account | MuxedAccount;
timebounds: { maxTime?: string | number | Date; minTime?: string | number | Date } | null;
addMemo(memo: Memo): TransactionBuilder;
addOperation(operation: Operation2): TransactionBuilder;
addOperationAt(operation: Operation2, index: number): TransactionBuilder;
addSacTransferOperation(destination: string, asset: Asset, amount: string | bigint, sorobanFees?: SorobanFees): TransactionBuilder;
build(): Transaction;
clearOperationAt(index: number): TransactionBuilder;
clearOperations(): TransactionBuilder;
hasV2Preconditions(): boolean;
setExtraSigners(extraSigners: string[]): TransactionBuilder;
setLedgerbounds(minLedger: number, maxLedger: number): TransactionBuilder;
setMinAccountSequence(minAccountSequence: string): TransactionBuilder;
setMinAccountSequenceAge(durationInSeconds: bigint): TransactionBuilder;
setMinAccountSequenceLedgerGap(gap: number): TransactionBuilder;
setNetworkPassphrase(networkPassphrase: string): TransactionBuilder;
setSorobanData(sorobanData: string | SorobanTransactionData): TransactionBuilder;
setTimebounds(minEpochOrDate: number | Date, maxEpochOrDate: number | Date): TransactionBuilder;
setTimeout(timeoutSeconds: number): TransactionBuilder;
}

Source: src/base/transaction_builder.ts:152

new TransactionBuilder(sourceAccount, opts)

constructor(sourceAccount: Account | MuxedAccount, opts: TransactionBuilderOptions = ...);

Parameters

  • sourceAccountAccount | MuxedAccount (required) — source account for this transaction
  • optsTransactionBuilderOptions (optional) (default: ...) — options object (see TransactionBuilderOptions)

Source: src/base/transaction_builder.ts:173

TransactionBuilder.buildFeeBumpTransaction(feeSource, baseFee, innerTx, networkPassphrase)

Builds a FeeBumpTransaction, enabling you to resubmit an existing transaction with a higher fee.

static buildFeeBumpTransaction(feeSource: string | Keypair, baseFee: string, innerTx: Transaction, networkPassphrase: string): FeeBumpTransaction;

Parameters

  • feeSourcestring | Keypair (required) — account paying for the transaction, in the form of either a Keypair (only the public key is used) or an account ID (in G… or M… form, but refer to withMuxing)

  • baseFeestring (required) — max fee willing to pay per operation in inner transaction (in stroops)

  • innerTxTransaction (required) — Transaction to be bumped by the fee bump transaction

  • networkPassphrasestring (required) — passphrase of the target Stellar network (e.g. “Public Global Stellar Network ; September 2015”, see Networks)

    TODO: Alongside the next major version bump, this type signature can be changed to be less awkward: accept a MuxedAccount as the feeSource rather than a keypair or string.

    Your fee-bump amount should be >= 10x the original fee.

See also

Source: src/base/transaction_builder.ts:1091

TransactionBuilder.cloneFrom(tx, opts)

Creates a builder instance using an existing Transaction as a template, ignoring any existing envelope signatures.

Note that the sequence number WILL be cloned, so EITHER this transaction or the one it was cloned from will be valid. This is useful in situations where you are constructing a transaction in pieces and need to make adjustments as you go (for example, when filling out Soroban resource information).

static cloneFrom(tx: Transaction, opts: Partial<TransactionBuilderOptions> = {}): TransactionBuilder;

Parameters

  • txTransaction (required) — a “template” transaction to clone exactly

  • optsPartial<TransactionBuilderOptions> (optional) (default: {}) — additional options to override the clone, e.g. {fee: '1000'} will override the existing base fee derived from tx (see the TransactionBuilder constructor for detailed options)

    Warning: This does not clone the transaction’s xdr.SorobanTransactionData (if applicable), use SorobanDataBuilder and TransactionBuilder.setSorobanData as needed, instead.

    TODO: This cannot clone FeeBumpTransactions, yet.

Source: src/base/transaction_builder.ts:280

TransactionBuilder.fromXDR(envelope, networkPassphrase)

Build a Transaction or FeeBumpTransaction from an xdr.TransactionEnvelope.

static fromXDR(envelope: string | TransactionEnvelope, networkPassphrase: string): Transaction | FeeBumpTransaction;

Parameters

  • envelopestring | TransactionEnvelope (required) — The transaction envelope object or base64 encoded string.
  • networkPassphrasestring (required) — The network passphrase of the target Stellar network (e.g. “Public Global Stellar Network ; September 2015”), see Networks.

Source: src/base/transaction_builder.ts:1202

transactionBuilder.baseFee

baseFee: string;

Source: src/base/transaction_builder.ts:155

transactionBuilder.extraSigners

extraSigners: string[] | null;

Source: src/base/transaction_builder.ts:164

transactionBuilder.ledgerbounds

ledgerbounds: { maxLedger?: number; minLedger?: number } | null;

Source: src/base/transaction_builder.ts:160

transactionBuilder.memo

memo: Memo;

Source: src/base/transaction_builder.ts:165

transactionBuilder.minAccountSequence

minAccountSequence: string | null;

Source: src/base/transaction_builder.ts:161

transactionBuilder.minAccountSequenceAge

minAccountSequenceAge: bigint | null;

Source: src/base/transaction_builder.ts:162

transactionBuilder.minAccountSequenceLedgerGap

minAccountSequenceLedgerGap: number | null;

Source: src/base/transaction_builder.ts:163

transactionBuilder.networkPassphrase

networkPassphrase: string | null;

Source: src/base/transaction_builder.ts:166

transactionBuilder.operations

operations: Operation2<OperationRecord>[];

Source: src/base/transaction_builder.ts:154

transactionBuilder.sorobanData

sorobanData: SorobanTransactionData | null;

Source: src/base/transaction_builder.ts:167

transactionBuilder.source

source: Account | MuxedAccount;

Source: src/base/transaction_builder.ts:153

transactionBuilder.timebounds

timebounds: { maxTime?: string | number | Date; minTime?: string | number | Date } | null;

Source: src/base/transaction_builder.ts:156

transactionBuilder.addMemo(memo)

Adds a memo to the transaction.

addMemo(memo: Memo): TransactionBuilder;

Parameters

  • memoMemo (required) — Memo object

Source: src/base/transaction_builder.ts:393

transactionBuilder.addOperation(operation)

Adds an operation to the transaction.

addOperation(operation: Operation2): TransactionBuilder;

Parameters

  • operationOperation2 (required) — The xdr operation object, use Operation static methods.

Source: src/base/transaction_builder.ts:355

transactionBuilder.addOperationAt(operation, index)

Adds an operation to the transaction at a specific index.

addOperationAt(operation: Operation2, index: number): TransactionBuilder;

Parameters

  • operationOperation2 (required) — The xdr operation object to add, use Operation static methods.
  • indexnumber (required) — The index at which to insert the operation.

Source: src/base/transaction_builder.ts:366

transactionBuilder.addSacTransferOperation(destination, asset, amount, sorobanFees)

Creates and adds an invoke host function operation for transferring SAC tokens. This method removes the need for simulation by handling the creation of the appropriate authorization entries and ledger footprint for the transfer operation.

addSacTransferOperation(destination: string, asset: Asset, amount: string | bigint, sorobanFees?: SorobanFees): TransactionBuilder;

Parameters

  • destinationstring (required) — the address of the recipient of the SAC transfer (should be a valid Stellar address or contract ID)
  • assetAsset (required) — the SAC asset to be transferred
  • amountstring | bigint (required) — the amount of tokens to be transferred in 7 decimals. IE 1 token with 7 decimals of precision would be represented as “1_0000000”
  • sorobanFeesSorobanFees (optional) — optional Soroban fees for the transaction to override the default fees used

Source: src/base/transaction_builder.ts:700

transactionBuilder.build()

Builds the transaction and increments the source account’s sequence number by 1.

build(): Transaction;

Source: src/base/transaction_builder.ts:920

transactionBuilder.clearOperationAt(index)

Removes the operation at the specified index from the transaction.

clearOperationAt(index: number): TransactionBuilder;

Parameters

  • indexnumber (required) — The index of the operation to remove.

Source: src/base/transaction_builder.ts:384

transactionBuilder.clearOperations()

Removes the operations from the builder (useful when cloning).

clearOperations(): TransactionBuilder;

Source: src/base/transaction_builder.ts:374

transactionBuilder.hasV2Preconditions()

Checks whether any v2 preconditions have been set on this builder.

hasV2Preconditions(): boolean;

Source: src/base/transaction_builder.ts:1059

transactionBuilder.setExtraSigners(extraSigners)

For the transaction to be valid, there must be a signature corresponding to every Signer in this array, even if the signature is not otherwise required by the sourceAccount or operations. Internally this will set the extraSigners precondition.

setExtraSigners(extraSigners: string[]): TransactionBuilder;

Parameters

  • extraSignersstring[] (required) — required extra signers (as StrKeys)

Source: src/base/transaction_builder.ts:635

transactionBuilder.setLedgerbounds(minLedger, maxLedger)

If you want to prepare a transaction which will only be valid within some range of ledgers, you can set a ledgerbounds precondition. Internally this will set the minLedger and maxLedger preconditions.

setLedgerbounds(minLedger: number, maxLedger: number): TransactionBuilder;

Parameters

  • minLedgernumber (required) — The minimum ledger this transaction is valid at or after. Cannot be negative. If the value is 0 (the default), the transaction is valid immediately.
  • maxLedgernumber (required) — The maximum ledger this transaction is valid before. Cannot be negative. If the value is 0, the transaction is valid indefinitely.

Source: src/base/transaction_builder.ts:523

transactionBuilder.setMinAccountSequence(minAccountSequence)

If you want to prepare a transaction which will be valid only while the account sequence number is

`minAccountSequence <= sourceAccountSequence < tx.seqNum`

Note that after execution the account’s sequence number is always raised to tx.seqNum. Internally this will set the minAccountSequence precondition.

setMinAccountSequence(minAccountSequence: string): TransactionBuilder;

Parameters

  • minAccountSequencestring (required) — The minimum source account sequence number this transaction is valid for. If the value is 0 (the default), the transaction is valid when sourceAccount’s sequence number == tx.seqNum - 1.

Source: src/base/transaction_builder.ts:560

transactionBuilder.setMinAccountSequenceAge(durationInSeconds)

For the transaction to be valid, the current ledger time must be at least minAccountSequenceAge greater than sourceAccount’s sequenceTime. Internally this will set the minAccountSequenceAge precondition.

setMinAccountSequenceAge(durationInSeconds: bigint): TransactionBuilder;

Parameters

  • durationInSecondsbigint (required) — The minimum amount of time between source account sequence time and the ledger time when this transaction will become valid. If the value is 0, the transaction is unrestricted by the account sequence age. Cannot be negative.

Source: src/base/transaction_builder.ts:582

transactionBuilder.setMinAccountSequenceLedgerGap(gap)

For the transaction to be valid, the current ledger number must be at least minAccountSequenceLedgerGap greater than sourceAccount’s ledger sequence. Internally this will set the minAccountSequenceLedgerGap precondition.

setMinAccountSequenceLedgerGap(gap: number): TransactionBuilder;

Parameters

  • gapnumber (required) — The minimum number of ledgers between source account sequence and the ledger number when this transaction will become valid. If the value is 0, the transaction is unrestricted by the account sequence ledger. Cannot be negative.

Source: src/base/transaction_builder.ts:611

transactionBuilder.setNetworkPassphrase(networkPassphrase)

Set network passphrase for the Transaction that will be built.

setNetworkPassphrase(networkPassphrase: string): TransactionBuilder;

Parameters

  • networkPassphrasestring (required) — passphrase of the target Stellar network (e.g. “Public Global Stellar Network ; September 2015”).

Source: src/base/transaction_builder.ts:661

transactionBuilder.setSorobanData(sorobanData)

Sets the transaction’s internal Soroban transaction data (resources, footprint, etc.).

For non-contract(non-Soroban) transactions, this setting has no effect. In the case of Soroban transactions, this is either an instance of xdr.SorobanTransactionData or a base64-encoded string of said structure. This is usually obtained from the simulation response based on a transaction with a Soroban operation (e.g. Operation.invokeHostFunction, providing necessary resource and storage footprint estimations for contract invocation.

setSorobanData(sorobanData: string | SorobanTransactionData): TransactionBuilder;

Parameters

  • sorobanDatastring | SorobanTransactionData (required) — the xdr.SorobanTransactionData as a raw xdr object or a base64 string to be decoded

See also

  • SorobanDataBuilder

Source: src/base/transaction_builder.ts:683

transactionBuilder.setTimebounds(minEpochOrDate, maxEpochOrDate)

If you want to prepare a transaction which will become valid at some point in the future, or be invalid after some time, you can set a timebounds precondition. Internally this will set the minTime, and maxTime preconditions. Conflicts with setTimeout, so use one or the other.

setTimebounds(minEpochOrDate: number | Date, maxEpochOrDate: number | Date): TransactionBuilder;

Parameters

  • minEpochOrDatenumber | Date (required) — Either a JS Date object, or a number of UNIX epoch seconds. The transaction is valid after this timestamp. Can’t be negative. If the value is 0, the transaction is valid immediately.
  • maxEpochOrDatenumber | Date (required) — Either a JS Date object, or a number of UNIX epoch seconds. The transaction is valid until this timestamp. Can’t be negative. If the value is 0, the transaction is valid indefinitely.

Source: src/base/transaction_builder.ts:474

transactionBuilder.setTimeout(timeoutSeconds)

Sets a timeout precondition on the transaction.

Because of the distributed nature of the Stellar network it is possible that the status of your transaction will be determined after a long time if the network is highly congested. If you want to be sure to receive the status of the transaction within a given period you should set the time bounds with maxTime on the transaction (this is what setTimeout does internally; if there’s minTime set but no maxTime it will be added).

A call to TransactionBuilder.setTimeout is required if Transaction does not have max_time set. If you don’t want to set timeout, use TimeoutInfinite. In general you should set TimeoutInfinite only in smart contracts.

Please note that Horizon may still return 504 Gateway Timeout error, even for short timeouts. In such case you need to resubmit the same transaction again without making any changes to receive a status. This method is using the machine system time (UTC), make sure it is set correctly.

setTimeout(timeoutSeconds: number): TransactionBuilder;

Parameters

  • timeoutSecondsnumber (required) — Number of seconds the transaction is good. Can’t be negative. If the value is TimeoutInfinite, the transaction is good indefinitely.

See also

Source: src/base/transaction_builder.ts:427

TrustLineFlag

type TrustLineFlag = TrustLineFlag.authorize | TrustLineFlag.authorizeToMaintainLiabilities | TrustLineFlag.deauthorize

Source: src/base/operations/types.ts:442

TrustLineFlag.authorize

type authorize = 1

Source: src/base/operations/types.ts:444

TrustLineFlag.authorizeToMaintainLiabilities

type authorizeToMaintainLiabilities = 2

Source: src/base/operations/types.ts:445

TrustLineFlag.deauthorize

type deauthorize = 0

Source: src/base/operations/types.ts:443

Uint128

class Uint128 extends LargeInt {
constructor(...args: (string | number | bigint)[]);
static MAX_VALUE: LargeInt;
static MIN_VALUE: LargeInt;
static defineIntBoundaries(): void;
static fromString(value: string): LargeInt;
static isValid(value: unknown): boolean;
readonly size: number;
readonly unsigned: boolean;
slice(chunkSize: number): bigint[];
toBigInt(): bigint;
toString(): string;
}

Source: src/base/numbers/uint128.ts:3

new Uint128(args)

Construct an unsigned 128-bit integer that can be XDR-encoded.

constructor(...args: (string | number | bigint)[]);

Parameters

  • ...args(string | number | bigint)[] (required) — one or more slices to encode in big-endian format (i.e. earlier elements are higher bits)

Source: src/base/numbers/uint128.ts:10

Uint128.MAX_VALUE

static MAX_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:14

Uint128.MIN_VALUE

static MIN_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:13

Uint128.defineIntBoundaries()

static defineIntBoundaries(): void;

Source: types/stellar__js-xdr/index.d.ts:12

Uint128.fromString(value)

static fromString(value: string): LargeInt;

Parameters

  • valuestring (required)

Source: types/stellar__js-xdr/index.d.ts:16

Uint128.isValid(value)

static isValid(value: unknown): boolean;

Parameters

  • valueunknown (required)

Source: types/stellar__js-xdr/index.d.ts:15

uint128.size

readonly size: number;

Source: src/base/numbers/uint128.ts:18

uint128.unsigned

readonly unsigned: boolean;

Source: src/base/numbers/uint128.ts:14

uint128.slice(chunkSize)

slice(chunkSize: number): bigint[];

Parameters

  • chunkSizenumber (required)

Source: types/stellar__js-xdr/index.d.ts:21

uint128.toBigInt()

toBigInt(): bigint;

Source: types/stellar__js-xdr/index.d.ts:19

uint128.toString()

toString(): string;

Source: types/stellar__js-xdr/index.d.ts:20

Uint256

class Uint256 extends LargeInt {
constructor(...args: (string | number | bigint)[]);
static MAX_VALUE: LargeInt;
static MIN_VALUE: LargeInt;
static defineIntBoundaries(): void;
static fromString(value: string): LargeInt;
static isValid(value: unknown): boolean;
readonly size: number;
readonly unsigned: boolean;
slice(chunkSize: number): bigint[];
toBigInt(): bigint;
toString(): string;
}

Source: src/base/numbers/uint256.ts:3

new Uint256(args)

Construct an unsigned 256-bit integer that can be XDR-encoded.

constructor(...args: (string | number | bigint)[]);

Parameters

  • ...args(string | number | bigint)[] (required) — one or more slices to encode in big-endian format (i.e. earlier elements are higher bits)

Source: src/base/numbers/uint256.ts:10

Uint256.MAX_VALUE

static MAX_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:14

Uint256.MIN_VALUE

static MIN_VALUE: LargeInt;

Source: types/stellar__js-xdr/index.d.ts:13

Uint256.defineIntBoundaries()

static defineIntBoundaries(): void;

Source: types/stellar__js-xdr/index.d.ts:12

Uint256.fromString(value)

static fromString(value: string): LargeInt;

Parameters

  • valuestring (required)

Source: types/stellar__js-xdr/index.d.ts:16

Uint256.isValid(value)

static isValid(value: unknown): boolean;

Parameters

  • valueunknown (required)

Source: types/stellar__js-xdr/index.d.ts:15

uint256.size

readonly size: number;

Source: src/base/numbers/uint256.ts:18

uint256.unsigned

readonly unsigned: boolean;

Source: src/base/numbers/uint256.ts:14

uint256.slice(chunkSize)

slice(chunkSize: number): bigint[];

Parameters

  • chunkSizenumber (required)

Source: types/stellar__js-xdr/index.d.ts:21

uint256.toBigInt()

toBigInt(): bigint;

Source: types/stellar__js-xdr/index.d.ts:19

uint256.toString()

toString(): string;

Source: types/stellar__js-xdr/index.d.ts:20

XdrLargeInt

A wrapper class to represent large XDR-encodable integers.

This operates at a lower level than ScInt by forcing you to specify the type / width / size in bits of the integer you’re targeting, regardless of the input value(s) you provide.

class XdrLargeInt {
constructor(type: ScIntType, values: XdrLargeIntValues);
static getType(scvType: string): ScIntType | undefined;
static isType(type: string): type is ScIntType;
int: LargeInt;
type: ScIntType;
toBigInt(): bigint;
toDuration(): ScVal;
toI128(): ScVal;
toI256(): ScVal;
toI64(): ScVal;
toJSON(): { type: string; value: string };
toNumber(): number;
toScVal(): ScVal;
toString(): string;
toTimepoint(): ScVal;
toU128(): ScVal;
toU256(): ScVal;
toU64(): ScVal;
valueOf(): unknown;
}

Source: src/base/numbers/xdr_large_int.ts:35

new XdrLargeInt(type, values)

constructor(type: ScIntType, values: XdrLargeIntValues);

Parameters

  • typeScIntType (required) — specifies a data type to use to represent the integer, one of: ‘i64’, ‘u64’, ‘i128’, ‘u128’, ‘i256’, ‘u256’, ‘timepoint’, and ‘duration’ (see XdrLargeInt.isType)
  • valuesXdrLargeIntValues (required) — a list of integer-like values interpreted in big-endian order

Source: src/base/numbers/xdr_large_int.ts:45

XdrLargeInt.getType(scvType)

Convert the raw ScValType string (e.g. ‘scvI128’, generated by the XDR) to a type description for XdrLargeInt construction (e.g. ‘i128’)

static getType(scvType: string): ScIntType | undefined;

Parameters

  • scvTypestring (required) — the xdr.ScValType as a string

Returns

the corresponding ScIntType if it’s an integer type, or undefined if it’s not an integer type

Source: src/base/numbers/xdr_large_int.ts:322

XdrLargeInt.isType(type)

Returns true if the given string is a valid XDR large integer type name.

static isType(type: string): type is ScIntType;

Parameters

  • typestring (required)

Source: src/base/numbers/xdr_large_int.ts:298

xdrLargeInt.int

int: LargeInt;

Source: src/base/numbers/xdr_large_int.ts:36

xdrLargeInt.type

type: ScIntType;

Source: src/base/numbers/xdr_large_int.ts:37

xdrLargeInt.toBigInt()

Converts to a native BigInt.

toBigInt(): bigint;

Source: src/base/numbers/xdr_large_int.ts:116

xdrLargeInt.toDuration()

The integer encoded with ScValType = Duration

toDuration(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:152

xdrLargeInt.toI128()

The integer encoded with ScValType = I128.

toI128(): ScVal;

Throws

  • if the value cannot fit in 128 bits

Source: src/base/numbers/xdr_large_int.ts:164

xdrLargeInt.toI256()

The integer encoded with ScValType = I256

toI256(): ScVal;

Throws

  • if the value cannot fit in a signed 256-bit integer

Source: src/base/numbers/xdr_large_int.ts:204

xdrLargeInt.toI64()

The integer encoded with ScValType = I64.

toI64(): ScVal;

Throws

  • if the value cannot fit in 64 bits

Source: src/base/numbers/xdr_large_int.ts:125

xdrLargeInt.toJSON()

Returns a JSON-friendly representation with value and type fields.

toJSON(): { type: string; value: string };

Source: src/base/numbers/xdr_large_int.ts:284

xdrLargeInt.toNumber()

Converts to a native JS number.

toNumber(): number;

Throws

  • if the value can’t fit into a Number

Source: src/base/numbers/xdr_large_int.ts:103

xdrLargeInt.toScVal()

The smallest interpretation of the stored value

toScVal(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:247

xdrLargeInt.toString()

Returns the string representation of this integer.

toString(): string;

Source: src/base/numbers/xdr_large_int.ts:279

xdrLargeInt.toTimepoint()

The integer encoded with ScValType = Timepoint

toTimepoint(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:144

xdrLargeInt.toU128()

The integer encoded with ScValType = U128.

toU128(): ScVal;

Throws

  • if the value cannot fit in 128 bits

Source: src/base/numbers/xdr_large_int.ts:187

xdrLargeInt.toU256()

The integer encoded with ScValType = U256

Note: No size check needed - U256 is the largest unsigned type.

toU256(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:229

xdrLargeInt.toU64()

The integer encoded with ScValType = U64

toU64(): ScVal;

Source: src/base/numbers/xdr_large_int.ts:136

xdrLargeInt.valueOf()

Returns the primitive value of this integer.

valueOf(): unknown;

Source: src/base/numbers/xdr_large_int.ts:274

cereal

const cereal: { XdrReader: typeof XdrReader; XdrWriter: typeof XdrWriter }

Source: src/base/jsxdr.ts:7

decodeAddressToMuxedAccount

Converts a Stellar address (in G… or M… form) to an xdr.MuxedAccount structure, using the ed25519 representation when possible.

This supports full muxed accounts, where an M... address will resolve to both its underlying G... address and an integer ID.

decodeAddressToMuxedAccount(address: string): MuxedAccount

Parameters

  • addressstring (required) — G… or M… address to encode into XDR

Source: src/base/util/decode_encode_muxed_account.ts:13

encodeMuxedAccount

Transform a Stellar address (G…) and an ID into its XDR representation.

encodeMuxedAccount(address: string, id: string): MuxedAccount

Parameters

  • addressstring (required) — a Stellar G… address
  • idstring (required) — a Uint64 ID represented as a string

Source: src/base/util/decode_encode_muxed_account.ts:52

encodeMuxedAccountToAddress

Converts an xdr.MuxedAccount to its StrKey representation.

Returns the “M…” string representation if there is a muxing ID within the object, or the “G…” representation otherwise.

encodeMuxedAccountToAddress(muxedAccount: MuxedAccount): string

Parameters

  • muxedAccountMuxedAccount (required) — raw account to stringify

See also

Source: src/base/util/decode_encode_muxed_account.ts:33

extractBaseAddress

Extracts the underlying base (G…) address from an M-address.

extractBaseAddress(address: string): string

Parameters

  • addressstring (required) — an account address (either M… or G…)

Source: src/base/util/decode_encode_muxed_account.ts:74

scValToBigInt

Transforms an opaque xdr.ScVal into a native bigint, if possible.

If you then want to use this in the abstractions provided by this module, you can pass it to the constructor of XdrLargeInt.

scValToBigInt(scv: ScVal): bigint

Parameters

  • scvScVal (required) — the XDR smart contract value to convert

Throws

  • if the scv input value doesn’t represent an integer

Example

let scv = contract.call("add", x, y); // assume it returns an xdr.ScVal
let bigi = scValToBigInt(scv);
new ScInt(bigi); // if you don't care about types, and
new XdrLargeInt('i128', bigi); // if you do

Source: src/base/numbers/index.ts:31