PaymentOperation class
Sends a payment of a specified asset to a destination account.
The Payment operation sends an amount of a specific asset to a destination account. This is the most common operation for transferring value on the Stellar network. The destination account must already exist and must have a trustline for the asset if it's not the native asset (XLM).
Use this operation when:
- Sending payments between user accounts
- Transferring assets in your application
- Making peer-to-peer transfers
- Implementing payment flows
Important notes:
- The destination account must already exist (use CreateAccountOperation for new accounts)
- For non-native assets, the destination must have a trustline
- The source account must have sufficient balance to cover the payment
- The payment amount must be positive
Example:
// Send 100 XLM to another account
var payment = PaymentOperationBuilder(
destinationAccountId,
Asset.native(),
"100.0"
).build();
// Send custom asset with specific source
var customAsset = AssetTypeCreditAlphaNum4("USD", issuerAccountId);
var paymentWithSource = PaymentOperationBuilder(
destinationAccountId,
customAsset,
"50.0"
).setSourceAccount(sourceAccountId).build();
// Add to transaction
var transaction = TransactionBuilder(sourceAccount)
.addOperation(payment)
.build();
See also:
- PathPaymentStrictReceiveOperation for path payments with exact receive amount
- PathPaymentStrictSendOperation for path payments with exact send amount
- CreateAccountOperation for creating and funding new accounts
- Operation for general operation documentation
Constructors
- PaymentOperation(MuxedAccount _destination, Asset _asset, String _amount)
- Creates a Payment operation.
Properties
- amount → String
-
Amount of the asset to send.
no setter
- asset → Asset
-
Asset to send to the destination account.
no setter
- destination → MuxedAccount
-
Account that receives the payment.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- sourceAccount ↔ MuxedAccount?
-
Optional source account for this operation.
getter/setter pairinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toOperationBody(
) → XdrOperationBody -
Converts this operation to its XDR OperationBody representation.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
toXdr(
) → XdrOperation -
Converts this operation to its XDR representation.
inherited
-
toXdrBase64(
) → String -
Returns base64-encoded Operation XDR object from this operation.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
builder(
XdrPaymentOp op) → PaymentOperationBuilder - Constructs a PaymentOperationBuilder from XDR.