AllowTrustOperation class

Updates the authorized flag of an existing trustline.

DEPRECATED: This operation is deprecated as of Protocol 17. Use SetTrustLineFlagsOperation instead, which provides more granular control over trustline flags and supports all current authorization states.

AllowTrustOperation allows an asset issuer to authorize or revoke another account's ability to hold their asset. This was the primary method for managing trustline authorization before Protocol 17.

Authorization States:

  • Authorized: Account can hold and transact with the asset (authorize=true)
  • Unauthorized: Account cannot hold or transact with the asset (authorize=false)
  • Authorized to Maintain Liabilities: Account can maintain existing positions but cannot receive new assets (authorizeToMaintainLiabilities=true)

Migration to SetTrustLineFlagsOperation:

Replace authorize=true:

// OLD (deprecated):
var oldOp = AllowTrustOperationBuilder(trustorId, assetCode, 1)
  .setSourceAccount(issuerAccountId)
  .build();

// NEW (recommended):
var newOp = SetTrustLineFlagsOperationBuilder(
  trustorId,
  asset,
  0,  // clearFlags: none
  1   // setFlags: AUTHORIZED_FLAG
).setSourceAccount(issuerAccountId).build();

Replace authorize=false:

// OLD (deprecated):
var oldOp = AllowTrustOperationBuilder(trustorId, assetCode, 0)
  .setSourceAccount(issuerAccountId)
  .build();

// NEW (recommended):
var newOp = SetTrustLineFlagsOperationBuilder(
  trustorId,
  asset,
  1,  // clearFlags: AUTHORIZED_FLAG
  0   // setFlags: none
).setSourceAccount(issuerAccountId).build();

Replace authorizeToMaintainLiabilities=true:

// OLD (deprecated):
var oldOp = AllowTrustOperationBuilder(trustorId, assetCode, 2)
  .setSourceAccount(issuerAccountId)
  .build();

// NEW (recommended):
var newOp = SetTrustLineFlagsOperationBuilder(
  trustorId,
  asset,
  1,  // clearFlags: AUTHORIZED_FLAG
  2   // setFlags: AUTHORIZED_TO_MAINTAIN_LIABILITIES_FLAG
).setSourceAccount(issuerAccountId).build();

Limitations Compared to SetTrustLineFlagsOperation:

  • Only works with asset codes, not full Asset objects
  • Cannot set clawback flags
  • Cannot set and clear flags in same operation
  • Less explicit about which flags are being modified

See also:

Represents an AllowTrust operation. See Stellar developer docs

Inheritance
Annotations
  • @Deprecated('Use SetTrustLineFlagsOperation instead. This operation is deprecated as of Protocol 17.')

Constructors

AllowTrustOperation(String _trustor, String _assetCode, bool _authorize, bool _authorizeToMaintainLiabilities)
Creates an AllowTrustOperation.

Properties

assetCode String
The asset of the trustline the source account is authorizing. For example, if a gateway wants to allow another account to hold its USD credit, the type is USD.
no setter
authorize bool
Flag indicating whether the trustline is authorized.
no setter
authorizeToMaintainLiabilities bool
Flag indicating whether the trustline is authorized to maintain liabilities.
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
trustor String
The account id of the recipient of the trustline.
no setter

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(XdrAllowTrustOp op) AllowTrustOperationBuilder
Builds AllowTrust operation from XDR operation.