Skip to content

Class: AssetsService

modules/assets.AssetsService

Service responsible for handling the asset creation and management. See more information about assets in IAM stack here.

const { connectToCacheServer } = await initWithPrivateKeySigner(privateKey, rpcUrl);
const { assetsService } = await connectToCacheServer();
assetsService.registerAsset();

Table of contents

Constructors

Methods

Constructors

constructor

new AssetsService(_signerService, _cacheClient)

Parameters

Name Type
_signerService SignerService
_cacheClient CacheClient

Methods

acceptAssetOffer

acceptAssetOffer(options): Promise<void>

Accept an offered asset.

assetsService.acceptAssetOffer({
    assetDID: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options AcceptAssetOfferOptions object containing options

Returns

Promise<void>


cancelAssetOffer

cancelAssetOffer(options): Promise<void>

Cancel an asset offer.

assetsService.cancelAssetOffer({
    assetDID: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options CancelAssetOfferOptions object containing options

Returns

Promise<void>


getAssetById

getAssetById(options): Promise<Asset>

Retrieve asset by id.

assetsService.getAssetById({
    id: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options GetAssetByIdOptions object containing options

Returns

Promise<Asset>

asset


getAssetHistory

getAssetHistory(options): Promise<AssetHistory[]>

Retrieve history of a given asset DID

assetsService.getAssetHistory({
    id: 'did:ethr:volta:0x000...1',
    order: Order.ASC,
    take: 5,
    skip: 0,
    type: AssetHistoryEventType.ASSET_OFFERED,
});

Parameters

Name Type Description
options GetAssetHistoryOptions object containing options

Returns

Promise<AssetHistory[]>

asset history


getAssetOwner

getAssetOwner(id): Promise<string>

Retrieve DID of the asset owner of the given asset DID.

assetsService.getAssetOwner('did:ethr:volta:0x000...1');

Parameters

Name Type Description
id string DID of the asset

Returns

Promise<string>

asset owner DID


getOfferedAssets

getOfferedAssets(options?): Promise<Asset[]>

Retrieve assets offered to the given user.

assetsService.getOfferedAssets({
    did: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options GetOfferedAssetsOptions object containing options

Returns

Promise<Asset[]>

offered assets


getOwnedAssets

getOwnedAssets(options?): Promise<Asset[]>

Retrieve owned assets of the given user.

assetsService.getOwnedAssets({
    did: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options GetOwnedAssetsOptions object containing options

Returns

Promise<Asset[]>

owned assets


getPreviouslyOwnedAssets

getPreviouslyOwnedAssets(options): Promise<Asset[]>

Retrieve previously owned assets of the given user.

assetsService.getPreviouslyOwnedAssets({
    owner: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options GetPreviouslyOwnedAssetsOptions object containing options

Returns

Promise<Asset[]>

previously owned assets


init

init(): Promise<void>

Returns

Promise<void>


offerAsset

offerAsset(options): Promise<void>

Send an asset offer transfer to a given address

assetsService.offerAsset({
    assetDID: 'did:ethr:volta:0x000...1',
    offerTo: '0x000...2',
});

Parameters

Name Type Description
options OfferAssetOptions object containing options

Returns

Promise<void>


registerAsset

registerAsset(): Promise<string>

Register a new asset to the user.

assetsService.registerAsset();

Returns

Promise<string>

asset address


rejectAssetOffer

rejectAssetOffer(options): Promise<void>

Reject an offered asset.

assetsService.rejectAssetOffer({
    assetDID: 'did:ethr:volta:0x000...1',
});

Parameters

Name Type Description
options RejectAssetOfferOptions object containing options

Returns

Promise<void>


create

Static create(signerService, cacheClient): Promise<AssetsService>

Parameters

Name Type
signerService SignerService
cacheClient CacheClient

Returns

Promise<AssetsService>