Class

Asset

Asset(code, issuer)

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)

Parameters:
Name Type Description
code string

The asset code.

issuer string

The account ID of the issuer.

View Source js-stellar-base/src/asset.js, line 18

Classes

Asset

Methods

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

Returns the xdr object for this asset.

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

The asset xdr object.

View Source js-stellar-base/src/asset.js, line 130

XDR Asset object

xdr.Asset | xdr.ChangeTrustAsset | xdr.TrustLineAsset

# contractId(networkPassphrase) → {string}

Returns the would-be contract ID (C... format) for this asset on a given network.

Parameters:
Name Type Description
networkPassphrase string

indicates which network the contract ID should refer to, since every network will have a unique ID for the same contract (see Networks for options)

View Source js-stellar-base/src/asset.js, line 111

the strkey-encoded (C...) contract ID for this asset

string

# equals(asset) → {boolean}

Parameters:
Name Type Description
asset Asset

Asset to compare

View Source js-stellar-base/src/asset.js, line 226

true if this asset equals the given asset.

boolean

# getAssetType() → {string}

See:

View Source js-stellar-base/src/asset.js, line 187

Asset type. Can be one of following types:

  • native,
  • credit_alphanum4,
  • credit_alphanum12, or
  • unknown as the error case (which should never occur)
string

# getCode() → {string}

View Source js-stellar-base/src/asset.js, line 161

Asset code

string

# getIssuer() → {string}

View Source js-stellar-base/src/asset.js, line 171

Asset issuer

string

# getRawAssetType() → {xdr.AssetType}

View Source js-stellar-base/src/asset.js, line 203

the raw XDR representation of the asset type

xdr.AssetType

# isNative() → {boolean}

View Source js-stellar-base/src/asset.js, line 218

true if this asset object is the native asset.

boolean

# toChangeTrustXDRObject() → {xdr.ChangeTrustAsset}

Returns the xdr.ChangeTrustAsset object for this asset.

View Source js-stellar-base/src/asset.js, line 87

XDR asset object

xdr.ChangeTrustAsset

# toTrustLineXDRObject() → {xdr.TrustLineAsset}

Returns the xdr.TrustLineAsset object for this asset.

View Source js-stellar-base/src/asset.js, line 95

XDR asset object

xdr.TrustLineAsset

# toXDRObject() → {xdr.Asset}

Returns the xdr.Asset object for this asset.

View Source js-stellar-base/src/asset.js, line 79

XDR asset object

xdr.Asset

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

Compares two assets according to the criteria:

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

the first asset

assetB Asset

the second asset

View Source js-stellar-base/src/asset.js, line 252

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

number

# static fromOperation(assetXdr) → {Asset}

Returns an asset object from its XDR object representation.

Parameters:
Name Type Description
assetXdr xdr.Asset

The asset xdr object.

View Source js-stellar-base/src/asset.js, line 55

Asset

# static native() → {Asset}

Returns an asset object for the native asset.

View Source js-stellar-base/src/asset.js, line 46

Asset