Class: AccountAsset

Represents an implementation of the specific asset with regards to the parent account

Note

Retrieved from the account by calling account.assets.{assetName}

Properties

accountAsset.address

string

The public address of the account asset

accountAsset.keys

Object

Key set corresponding to the derived accountAsset.

Methods

accountAsset.fetchBalance()

Fetches and returns the account balance with respect to the underlying asset infrastructure.

Returns:Promise<number> resolves with an updated account balance result
accountAsset.fetchTransferHistory()

Fetches historical transfers with respect to the underlying asset.

Returns:Promise<Array<Transfer>> Promise that resolves with the updated transfers history.
accountAsset.getFullyQualifiedAddress()

Constructs and returns the globally unique fully-qualified address of the account asset.

Returns:string the fully qualified address
accountAsset.send(transferArgs)

Sends a balance transfer from the parent account with respect to the underlying asset.

Returns:Promise<Transfer> Promise that resolves with the submitted Transfer instance.
Arguments
Name Type Required Description
transferArgs.to string Yes The recievers address
transferArgs.amount number Yes The amount to send in the lowest denomination available
transferArgs.data string No Extra data to be added to the transaction where applicable

Examples

Transfer balance from an account with respect to the underlying asset

1
2
3
4
5
6
// Send 1 CENNZ to an adderss from an initialized Pl^g account
const transfer = myPlugAccount.assets.CENNZ.send({
   to: '1Fy8xwtT8csbVwVCw2NMkpTjXx7AURY7fp',
   amount: 1e18,
   data: "Student loan repayment #372"
})

Configuration

Many assets allow configuration which provides a way to tweak the interactions with the underlying platforms. Configuration requirements for each asset can be found on the reference page of its underlying asset class (see below).

When creating an asset it is possible to pass in optional configuration. This can be done as follows:

1
2
3
4
5
6
7
8
9
const assetConfiguration = {
    contractAddress: '0xf969aab32642a5344c15a30739909cade04c40c4',
    name: 'MOOSE',
    chain: 'ropsten',
    configKey1: value,
    configKey2: value,
    ...
}
wallet.accounts[0].addAsset(assetConfiguration)

It is also possible to configure the asset after it has been created

1
2
3
4
5
wallet.accounts[0].assets.MOOSE._data.configure({
    configKey1: value,
    configKey2: value,
    ...
})

Note

Configuration cascades, so if the wallet or account has been set up with additional configuration this will modify the defaults given to new assets (under that account or wallet).

One use for this is to create a test ethereum account on the ropsten network so all assets in that account are automatically pointing to the ropsten network.

Another common use case would be to set the gasprice or limit used for all transactions.

However, this only modifies the defaults and still allows configuration to override it at creation time or explicitly, through configure.