Asset

Asset

Asset class represents an asset, either the native asset (XLM) or an asset code / issuer account ID pair.

An asset code describes an asset code and issuer pair. In the case of the native asset XLM, the issuer will be null.

Constructor

new Asset(code, issuer)

Source:
Parameters:
Name Type Description
code string

The asset code.

issuer string

The account ID of the issuer.

Classes

Asset

Methods

(static) compare(assetA, assetB) → {number}

Compares if assetA < assetB according with the criteria:

  1. First compare the type (eg. native before alphanum4 before alphanum12).
  2. If the types are equal, compare the assets codes.
  3. If the asset codes are equal, compare the issuers.
Source:
Parameters:
Name Type Description
assetA Asset

The first asset in the lexicographic order.

assetB Asset

The second asset in the lexicographic order.

Returns:
Type:
number

-1 if assetA < assetB, 0 if assetA == assetB, 1 if assetA > assetB.

(static) fromOperation(assetXdr) → {Asset}

Returns an asset object from its XDR object representation.

Source:
Parameters:
Name Type Description
assetXdr xdr.Asset

The asset xdr object.

Returns:
Type:
Asset

(static) native() → {Asset}

Returns an asset object for the native asset.

Source:
Returns:
Type:
Asset

_toXDRObject(xdrAsset) → {xdr.Asset|xdr.ChangeTrustAsset|xdr.TrustLineAsset}

Returns the xdr object for this asset.

Source:
Parameters:
Name Type Description
xdrAsset xdr.Asset | xdr.ChangeTrustAsset

The asset xdr object.

Returns:
Type:
xdr.Asset | xdr.ChangeTrustAsset | xdr.TrustLineAsset

XDR Asset object

equals(asset) → {boolean}

Source:
Parameters:
Name Type Description
asset Asset

Asset to compare

Returns:
Type:
boolean

true if this asset equals the given asset.

getAssetType() → {string}

Source:
See:
Returns:
Type:
string

Asset type. Can be one of following types:

  • native
  • credit_alphanum4
  • credit_alphanum12

getCode() → {string}

Source:
Returns:
Type:
string

Asset code

getIssuer() → {string}

Source:
Returns:
Type:
string

Asset issuer

isNative() → {boolean}

Source:
Returns:
Type:
boolean

true if this asset object is the native asset.

toChangeTrustXDRObject() → {xdr.ChangeTrustAsset}

Returns the xdr.ChangeTrustAsset object for this asset.

Source:
Returns:
Type:
xdr.ChangeTrustAsset

XDR asset object

toTrustLineXDRObject() → {xdr.TrustLineAsset}

Returns the xdr.TrustLineAsset object for this asset.

Source:
Returns:
Type:
xdr.TrustLineAsset

XDR asset object

toXDRObject() → {xdr.Asset}

Returns the xdr.Asset object for this asset.

Source:
Returns:
Type:
xdr.Asset

XDR asset object