Operation

Operation

Methods

(static) accountMerge(opts) → {xdr.Operation}

Transfers native balance to destination account.

Source:
Parameters:
Name Type Description
opts object

options object

Name Type Attributes Description
destination string

destination to merge the source account into

withMuxing bool <optional>

indicates that some parameters in the operation are M... addresses that should be interpreted fully as a muxed account. By default, this option is disabled until muxed accounts are mature.

source string <optional>

operation source account (defaults to transaction source)

Returns:
Type:
xdr.Operation

an Account Merge operation (xdr.AccountMergeOp)

(static) allowTrust(opts) → {xdr.AllowTrustOp}

Deprecated:
  • since v5.0 Returns an XDR AllowTrustOp. An "allow trust" operation authorizes another account to hold your account's credit for a given asset.
Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
trustor string

The trusting account (the one being authorized)

assetCode string

The asset code being authorized.

authorize 0 | 1 | 2

1 to authorize, 2 to authorize to maintain liabilities, and 0 to deauthorize.

source string <optional>

The source account (defaults to transaction source).

Returns:
Type:
xdr.AllowTrustOp

Allow Trust operation

(static) beginSponsoringFutureReserves(opts) → {xdr.Operation}

Create a "begin sponsoring future reserves" operation.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
sponsoredId string

The sponsored account id.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.beginSponsoringFutureReserves({
  sponsoredId: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
});

(static) bumpSequence(opts) → {xdr.BumpSequenceOp}

This operation bumps sequence number.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
bumpTo string

Sequence number to bump to.

source string <optional>

The optional source account.

Returns:
Type:
xdr.BumpSequenceOp

Operation

(static) changeTrust(opts) → {xdr.ChangeTrustOp}

Returns an XDR ChangeTrustOp. A "change trust" operation adds, removes, or updates a trust line for a given asset from the source account to another. The issuer being trusted and the asset code are in the given Asset object.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
asset Asset

The asset for the trust line.

limit string <optional>

The limit for the asset, defaults to max int64. If the limit is set to "0" it deletes the trustline.

source string <optional>

The source account (defaults to transaction source).

Returns:
Type:
xdr.ChangeTrustOp

Change Trust operation

(static) claimClaimableBalance(opts) → {xdr.Operation}

Create a new claim claimable balance operation.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
balanceId string

The claimable balance id to be claimed.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

Claim claimable balance operation

Example
const op = Operation.claimClaimableBalance({
  balanceId: '00000000da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be',
});

(static) clawback(opts) → {xdr.ClawbackOp}

Creates a clawback operation.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
asset Asset

The asset being clawed back.

amount string

The amount of the asset to claw back.

from string

The public key of the (muxed) account to claw back from.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.ClawbackOp

(static) clawbackClaimableBalance(opts) → {xdr.ClawbackClaimableBalanceOp}

Creates a clawback operation for a claimable balance.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
balanceId string

The claimable balance ID to be clawed back.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.ClawbackClaimableBalanceOp
Example
const op = Operation.clawbackClaimableBalance({
  balanceId: '00000000da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be',
});

(static) createAccount(opts) → {xdr.CreateAccountOp}

Create and fund a non existent account.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
destination string

Destination account ID to create an account for.

startingBalance string

Amount in XLM the account should be funded for. Must be greater than the reserve balance amount.

source string <optional>

The source account for the payment. Defaults to the transaction's source account.

Returns:
Type:
xdr.CreateAccountOp

Create account operation

(static) createClaimableBalance(opts) → {xdr.Operation}

Create a new claimable balance operation.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
asset Asset

The asset for the claimable balance.

amount string

Amount.

claimants Array.<Claimant>

An array of Claimants

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

Create claimable balance operation

Example
const asset = new Asset(
  'USD',
  'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
);
const amount = '100.0000000';
const claimants = [
  new Claimant(
    'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ',
     Claimant.predicateBeforeAbsoluteTime("4102444800000")
  )
];

const op = Operation.createClaimableBalance({
  asset,
  amount,
  claimants
});

(static) createPassiveSellOffer(opts) → {xdr.CreatePassiveSellOfferOp}

Returns a XDR CreatePasiveSellOfferOp. A "create passive offer" operation creates an offer that won't consume a counter offer that exactly matches this offer. This is useful for offers just used as 1:1 exchanges for path payments. Use manage offer to manage this offer after using this operation to create it.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
selling Asset

What you're selling.

buying Asset

What you're buying.

amount string

The total amount you're selling. If 0, deletes the offer.

price number | string | BigNumber | Object

Price of 1 unit of selling in terms of buying.

Name Type Description
n number

If opts.price is an object: the price numerator

d number

If opts.price is an object: the price denominator

source string <optional>

The source account (defaults to transaction source).

Throws:

Throws Error when the best rational approximation of price cannot be found.

Type
Error
Returns:
Type:
xdr.CreatePassiveSellOfferOp

Create Passive Sell Offer operation

(static) endSponsoringFutureReserves(opts) → {xdr.Operation}

Create an "end sponsoring future reserves" operation.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.endSponsoringFutureReserves();

(static) fromXDRObject(operation, withMuxingopt) → {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).

Source:
Parameters:
Name Type Attributes Description
operation xdr.Operation

An XDR Operation.

withMuxing boolean <optional>

Indicates that the operation contains M... addresses which should be interpreted fully as muxed accounts. By default, this option is disabled until muxed accounts are mature.

Returns:
Type:
Operation

(static) inflation(optsopt) → {xdr.InflationOp}

This operation generates the inflation.

Source:
Parameters:
Name Type Attributes Description
opts object <optional>

Options object

Name Type Attributes Description
source string <optional>

The optional source account.

Returns:
Type:
xdr.InflationOp

Inflation operation

(static) manageBuyOffer(opts) → {xdr.ManageBuyOfferOp}

Returns a XDR ManageBuyOfferOp. A "manage buy offer" operation creates, updates, or deletes a buy offer.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
selling Asset

What you're selling.

buying Asset

What you're buying.

buyAmount string

The total amount you're buying. If 0, deletes the offer.

price number | string | BigNumber | Object

Price of 1 unit of buying in terms of selling.

Name Type Description
n number

If opts.price is an object: the price numerator

d number

If opts.price is an object: the price denominator

offerId number | string <optional>

If 0, will create a new offer (default). Otherwise, edits an exisiting offer.

source string <optional>

The source account (defaults to transaction source).

Throws:

Throws Error when the best rational approximation of price cannot be found.

Type
Error
Returns:
Type:
xdr.ManageBuyOfferOp

Manage Buy Offer operation

(static) manageData(opts) → {xdr.ManageDataOp}

This operation adds data entry to the ledger.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
name string

The name of the data entry.

value string | Buffer

The value of the data entry.

source string <optional>

The optional source account.

Returns:
Type:
xdr.ManageDataOp

Manage Data operation

(static) manageSellOffer(opts) → {xdr.ManageSellOfferOp}

Returns a XDR ManageSellOfferOp. A "manage sell offer" operation creates, updates, or deletes an offer.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
selling Asset

What you're selling.

buying Asset

What you're buying.

amount string

The total amount you're selling. If 0, deletes the offer.

price number | string | BigNumber | Object

Price of 1 unit of selling in terms of buying.

Name Type Description
n number

If opts.price is an object: the price numerator

d number

If opts.price is an object: the price denominator

offerId number | string <optional>

If 0, will create a new offer (default). Otherwise, edits an exisiting offer.

source string <optional>

The source account (defaults to transaction source).

Throws:

Throws Error when the best rational approximation of price cannot be found.

Type
Error
Returns:
Type:
xdr.ManageSellOfferOp

Manage Sell Offer operation

(static) pathPaymentStrictReceive(opts) → {xdr.Operation}

Creates a PathPaymentStrictReceive operation.

A PathPaymentStrictReceive operation sends the specified amount to the destination account. It credits the destination with destAmount of destAsset, while debiting at most sendMax of sendAsset from the source. The transfer optionally occurs through a path. XLM payments create the destination account if it does not exist.

Source:
See:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
sendAsset Asset

asset to pay with

sendMax string

maximum amount of sendAsset to send

destination string

destination account to send to

destAsset Asset

asset the destination will receive

destAmount string

amount the destination receives

path Array.<Asset>

array of Asset objects to use as the path

withMuxing bool <optional>

indicates that some parameters in the operation are M... addresses that should be interpreted fully as a muxed account. By default, this option is disabled until muxed accounts are mature.

source string <optional>

The source account for the payment. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

the resulting path payment operation (xdr.PathPaymentStrictReceiveOp)

(static) pathPaymentStrictSend(opts) → {xdr.Operation}

Creates a PathPaymentStrictSend operation.

A PathPaymentStrictSend operation sends the specified amount to the destination account crediting at least destMin of destAsset, optionally through a path. XLM payments create the destination account if it does not exist.

Source:
See:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
sendAsset Asset

asset to pay with

sendAmount string

amount of sendAsset to send (excluding fees)

destination string

destination account to send to

destAsset Asset

asset the destination will receive

destMin string

minimum amount of destAsset to be receive

path Array.<Asset>

array of Asset objects to use as the path

withMuxing bool <optional>

indicates that some parameters in the operation are M... addresses that should be interpreted fully as a muxed account. By default, this option is disabled until muxed accounts are mature.

source string <optional>

The source account for the payment. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

the resulting path payment operation (xdr.PathPaymentStrictSendOp)

(static) payment(opts) → {xdr.Operation}

Create a payment operation.

Source:
See:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
destination string

The destination account ID.

asset Asset

The asset to send.

amount string

The amount to send.

withMuxing bool <optional>

Indicates that some parameters (either the destination or source, in this case) are M... addresses that should be interpreted fully as a muxed account. By default, this option is disabled until muxed accounts are mature.

source string <optional>

The source account for the payment. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

The resulting payment operation (xdr.PaymentOp)

(static) revokeAccountSponsorship(opts) → {xdr.Operation}

Create a "revoke sponsorship" operation for an account.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
account string

The sponsored account ID.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.revokeAccountSponsorship({
  account: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
});

(static) revokeClaimableBalanceSponsorship(opts) → {xdr.Operation}

Create a "revoke sponsorship" operation for a claimable balance.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
balanceId string

The sponsored claimable balance ID.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.revokeClaimableBalanceSponsorship({
  balanceId: '00000000da0d57da7d4850e7fc10d2a9d0ebc731f7afb40574c03395b17d49149b91f5be',
});

(static) revokeDataSponsorship(opts) → {xdr.Operation}

Create a "revoke sponsorship" operation for a data entry.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
account string

The account ID which owns the data entry.

name string

The name of the data entry

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.revokeDataSponsorship({
  account: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
  name: 'foo'
});

(static) revokeOfferSponsorship(opts) → {xdr.Operation}

Create a "revoke sponsorship" operation for an offer.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
seller string

The account ID which created the offer.

offerId string

The offer ID.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.revokeOfferSponsorship({
  seller: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
  offerId: '1234'
});

(static) revokeSignerSponsorship(opts) → {xdr.Operation}

Create a "revoke sponsorship" operation for a signer.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
account string

The account ID where the signer sponsorship is being removed from.

signer object

The signer whose sponsorship is being removed.

Name Type Attributes Description
ed25519PublicKey string <optional>

The ed25519 public key of the signer.

sha256Hash Buffer | string <optional>

sha256 hash (Buffer or hex string).

preAuthTx Buffer | string <optional>

Hash (Buffer or hex string) of transaction.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.revokeSignerSponsorship({
  account: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
  signer: {
    ed25519PublicKey: 'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ'
  }
})

(static) revokeTrustlineSponsorship(opts) → {xdr.Operation}

Create a "revoke sponsorship" operation for a trustline.

Source:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
account string

The account ID which owns the trustline.

asset Asset

The asset in the trustline.

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.Operation

xdr operation

Example
const op = Operation.revokeTrustlineSponsorship({
  account: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
  asset: new StellarBase.Asset(
    'USDUSD',
    'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7'
  )
});

(static) setOptions(opts) → {xdr.SetOptionsOp}

Returns an XDR SetOptionsOp. A "set options" operations set or clear account flags, set the account's inflation destination, and/or add new signers to the account. The flags used in opts.clearFlags and opts.setFlags can be the following:

It's possible to set/clear multiple flags at once using logical or.

Source:
See:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
inflationDest string <optional>

Set this account ID as the account's inflation destination.

clearFlags number | string <optional>

Bitmap integer for which account flags to clear.

setFlags number | string <optional>

Bitmap integer for which account flags to set.

masterWeight number | string <optional>

The master key weight.

lowThreshold number | string <optional>

The sum weight for the low threshold.

medThreshold number | string <optional>

The sum weight for the medium threshold.

highThreshold number | string <optional>

The sum weight for the high threshold.

signer object <optional>

Add or remove a signer from the account. The signer is deleted if the weight is 0. Only one of ed25519PublicKey, sha256Hash, preAuthTx should be defined.

Name Type Attributes Description
ed25519PublicKey string <optional>

The ed25519 public key of the signer.

sha256Hash Buffer | string <optional>

sha256 hash (Buffer or hex string) of preimage that will unlock funds. Preimage should be used as signature of future transaction.

preAuthTx Buffer | string <optional>

Hash (Buffer or hex string) of transaction that will unlock funds.

weight number | string <optional>

The weight of the new signer (0 to delete or 1-255)

homeDomain string <optional>

sets the home domain used for reverse federation lookup.

source string <optional>

The source account (defaults to transaction source).

Returns:
Type:
xdr.SetOptionsOp

XDR operation

(static) setTrustLineFlags(opts) → {xdr.SetTrustLineFlagsOp}

Creates a trustline flag configuring operation.

For the flags, set them to true to enable them and false to disable them. Any unmodified operations will be marked undefined in the result.

Note that you can only clear the clawbackEnabled flag set; it must be set account-wide via operations.SetOptions (setting xdr.AccountFlags.clawbackEnabled).

Source:
See:
Parameters:
Name Type Description
opts object

Options object

Name Type Attributes Description
trustor string

the account whose trustline this is

asset Asset

the asset on the trustline

flags object

the set of flags to modify

Name Type Attributes Description
authorized bool <optional>

authorize account to perform transactions with its credit

authorizedToMaintainLiabilities bool <optional>

authorize account to maintain and reduce liabilities for its credit

clawbackEnabled bool <optional>

stop claimable balances on this trustlines from having clawbacks enabled (this flag can only be set to false!)

source string <optional>

The source account for the operation. Defaults to the transaction's source account.

Returns:
Type:
xdr.SetTrustLineFlagsOp