new Operation()
Operation
class represents
operations in
Stellar network.
Use one of static methods to create operations:
Operation.createAccount
Operation.payment
Operation.pathPaymentStrictReceive
Operation.pathPaymentStrictSend
Operation.manageSellOffer
Operation.manageBuyOffer
Operation.createPassiveSellOffer
Operation.setOptions
Operation.changeTrust
Operation.allowTrust
Operation.accountMerge
Operation.inflation
Operation.manageData
Operation.bumpSequence
Operation.createClaimableBalance
Operation.claimClaimableBalance
Operation.beginSponsoringFutureReserves
Operation.endSponsoringFutureReserves
Operation.revokeAccountSponsorship
Operation.revokeTrustlineSponsorship
Operation.revokeOfferSponsorship
Operation.revokeDataSponsorship
Operation.revokeClaimableBalanceSponsorship
Operation.revokeLiquidityPoolSponsorship
Operation.revokeSignerSponsorship
Operation.clawback
Operation.clawbackClaimableBalance
Operation.setTrustLineFlags
Operation.liquidityPoolDeposit
Operation.liquidityPoolWithdraw
Operation.invokeHostFunction
, which has the following additional "pseudo-operations" that make building host functions easier:Operation.extendFootprintTtlOp
Operation.restoreFootprint
- Source:
Methods
(static) accountMerge(opts) → {xdr.Operation}
Transfers native balance to destination account.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
options object
|
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
|
Returns:
- Type:
-
xdr.AllowTrustOp
Allow Trust operation
(static) beginSponsoringFutureReserves(opts) → {xdr.Operation}
Create a "begin sponsoring future reserves" operation.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
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
|
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.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
Returns:
- Type:
-
xdr.ChangeTrustOp
Change Trust operation
(static) claimClaimableBalance(opts) → {xdr.Operation}
Create a new claim claimable balance operation.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
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:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
Returns:
- Type:
-
xdr.ClawbackOp
(static) clawbackClaimableBalance(opts) → {xdr.ClawbackClaimableBalanceOp}
Creates a clawback operation for a claimable balance.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
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
|
Returns:
- Type:
-
xdr.CreateAccountOp
Create account operation
(static) createClaimableBalance(opts) → {xdr.Operation}
Create a new claimable balance operation.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
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) createCustomContract(opts) → {xdr.Operation}
Returns an operation that creates a custom WASM contract and atomically invokes its constructor.
- Source:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
any
|
the set of parameters
|
Returns:
- Type:
-
xdr.Operation
an Invoke Host Function operation (xdr.InvokeHostFunctionOp)
(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.
Parameters:
Name | Type | Description | |||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
Throws:
-
Throws
Error
when the best rational approximation ofprice
cannot be found. - Type
-
Error
Returns:
- Type:
-
xdr.CreatePassiveSellOfferOp
Create Passive Sell Offer operation
(static) createStellarAssetContract(opts) → {xdr.Operation}
Returns an operation that wraps a Stellar asset into a token contract.
- Source:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
any
|
the set of parameters
|
Returns:
- Type:
-
xdr.Operation
an Invoke Host Function operation (xdr.InvokeHostFunctionOp)
(static) endSponsoringFutureReserves(opts) → {xdr.Operation}
Create an "end sponsoring future reserves" operation.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
Returns:
- Type:
-
xdr.Operation
xdr operation
Example
const op = Operation.endSponsoringFutureReserves();
(static) extendFootprintTtl(opts) → {xdr.Operation}
Builds an operation to bump the time-to-live (TTL) of the ledger keys. The keys for extension have to be provided in the read-only footprint of the transaction.
The only parameter of the operation itself is the new minimum TTL for all the provided entries. If an entry already has a higher TTL, then it will just be skipped.
TTL is the number of ledgers from the current ledger (exclusive) until the last ledger the entry is still considered alive (inclusive). Thus the exact ledger until the entries will live will only be determined when transaction has been applied.
The footprint has to be specified in the transaction. See
TransactionBuilder's opts.sorobanData
parameter, which is a
xdr.SorobanTransactionData instance that contains fee data & resource
usage as part of xdr.SorobanResources.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
object holding operation parameters
|
Returns:
- Type:
-
xdr.Operation
an Extend Footprint TTL operation (xdr.ExtendFootprintTTLOp)
(static) fromXDRObject(operation) → {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 | Description |
---|---|---|
operation |
xdr.Operation
|
An XDR Operation. |
Returns:
- Type:
-
Operation
(static) inflation(optsopt) → {xdr.InflationOp}
This operation generates the inflation.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
<optional> |
Options object
|
Returns:
- Type:
-
xdr.InflationOp
Inflation operation
(static) invokeContractFunction(opts) → {xdr.Operation}
Returns an operation that invokes a contract function.
- Source:
- See:
-
- Operation.invokeHostFunction
- Contract.call
- Address
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
any
|
the set of parameters
|
Returns:
- Type:
-
xdr.Operation
an Invoke Host Function operation (xdr.InvokeHostFunctionOp)
(static) invokeHostFunction(opts) → {xdr.Operation}
Invokes a single smart contract host function.
- Source:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
options object
|
Returns:
- Type:
-
xdr.Operation
an Invoke Host Function operation (xdr.InvokeHostFunctionOp)
(static) isValidAmount(value, allowZero) → {boolean}
Validates that a given amount is possible for a Stellar asset.
Specifically, this means that the amount is well, a valid number, but also that it is within the int64 range and has no more than 7 decimal levels of precision.
Note that while smart contracts allow larger amounts, this is oriented towards validating the standard Stellar operations.
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
value |
string
|
the amount to validate |
|
allowZero |
boolean
|
false |
optionally, whether or not zero is valid (default: no) |
Returns:
- Type:
-
boolean
(static) liquidityPoolDeposit(opts) → {xdr.Operation}
Creates a liquidity pool deposit operation.
- Source:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
Returns:
- Type:
-
xdr.Operation
The resulting operation (xdr.LiquidityPoolDepositOp).
(static) liquidityPoolWithdraw(opts) → {xdr.Operation}
Creates a liquidity pool withdraw operation.
- Source:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
Returns:
- Type:
-
xdr.Operation
The resulting operation (xdr.LiquidityPoolWithdrawOp).
(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
|
Throws:
-
Throws
Error
when the best rational approximation ofprice
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
|
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
|
Throws:
-
Throws
Error
when the best rational approximation ofprice
cannot be found. - Type
-
Error
Returns:
- Type:
-
xdr.ManageSellOfferOp
Manage Sell Offer operation
(static) pathPaymentStrictReceive(opts) → {xdr.PathPaymentStrictReceiveOp}
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
|
Returns:
- Type:
-
xdr.PathPaymentStrictReceiveOp
the resulting path payment op
(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
|
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
|
Returns:
- Type:
-
xdr.Operation
The resulting payment operation (xdr.PaymentOp)
(static) restoreFootprint(optsopt) → {xdr.Operation}
Builds an operation to restore the archived ledger entries specified by the ledger keys.
The ledger keys to restore are specified separately from the operation in read-write footprint of the transaction.
It takes no parameters because the relevant footprint is derived from the
transaction itself. See TransactionBuilder's opts.sorobanData
parameter (or TransactionBuilder.setSorobanData /
TransactionBuilder.setLedgerKeys), which is a
xdr.SorobanTransactionData instance that contains fee data & resource
usage as part of xdr.SorobanTransactionData.
- Source:
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
<optional> |
an optional set of parameters
|
Returns:
- Type:
-
xdr.Operation
a Bump Footprint Expiration operation (xdr.RestoreFootprintOp)
(static) revokeAccountSponsorship(opts) → {xdr.Operation}
Create a "revoke sponsorship" operation for an account.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
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
|
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
|
Returns:
- Type:
-
xdr.Operation
xdr operation
Example
const op = Operation.revokeDataSponsorship({
account: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
name: 'foo'
});
(static) revokeLiquidityPoolSponsorship(opts) → {xdr.Operation}
Creates a "revoke sponsorship" operation for a liquidity pool.
- Source:
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
– Options object.
|
Returns:
- Type:
-
xdr.Operation
xdr Operation.
Example
const op = Operation.revokeLiquidityPoolSponsorship({
liquidityPoolId: 'dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7',
});
(static) revokeOfferSponsorship(opts) → {xdr.Operation}
Create a "revoke sponsorship" operation for an offer.
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object
|
Options object
|
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
|
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
|
Returns:
- Type:
-
xdr.Operation
xdr operation
Example
const op = Operation.revokeTrustlineSponsorship({
account: 'GDGU5OAPHNPU5UCLE5RDJHG7PXZFQYWKCFOEXSXNMR6KRQRI5T6XXCD7
asset: new StellarBase.LiquidityPoolId(
'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
|
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
|
Returns:
- Type:
-
xdr.SetTrustLineFlagsOp
(static) uploadContractWasm(opts) → {xdr.Operation}
Returns an operation that uploads WASM for a contract.
- Source:
- See:
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
any
|
the set of parameters
|
Returns:
- Type:
-
xdr.Operation
an Invoke Host Function operation (xdr.InvokeHostFunctionOp)