Class

OnchainAssetManager

OnchainAssetManager(MyriaClient)

Constructor

# new OnchainAssetManager(MyriaClient)

Create OnchainAssetManager instance object

Parameters:
Name Type Description
MyriaClient MyriaClient

Interface of Myria Client

View Source modules/OnchainAssetManager.ts, line 6

Example

Constructor for OnchainAssetManager

 // Approach #1
  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const moduleFactory = ModuleFactory.getInstance(mClient);
  const onchainAssetManager = moduleFactory.getOnchainAssetManager();

  // Approach #2
  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

Methods

# async getAssetById(assetId) → {APIResponseType.<AssetDetailsResponse>}

Get NFTs asset details by ID

Parameters:
Name Type Description
assetId string

The ID of the asset/NFT

View Source modules/OnchainAssetManager.ts, line 565

Exception: AssetId is required

string

The full information of the NFTs/Assets

Example

Staging example code for getAssetById

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const requestAssetDetails = {
    assetId: 1, // Asset id number
  }
  const assetsData: AssetDetailsResponse = await onchainAssetManager.getAssetById(requestAssetDetails);

# async getAssetByStarkKey(starkKey, pagenullable, limitnullable) → {CommonPaginateDataTypes.<AssetStarkKeyResponse>|undefined}

Get all of NFTs/Assets belonging to the specific users (StarkKey)

Parameters:
Name Type Attributes Description
starkKey string

The stark key owner for the assets NFTs

page number <nullable>

The index of page (1,2,3,...etc)

limit number <nullable>

The total number of limited items per page

View Source modules/OnchainAssetManager.ts, line 651

Exception: Stark Key is required

string

The full information of NFTs/Assets list (Id, price, order, status...)

Example

Staging example code for getAssetByStarkKey()

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const starkKey = '0xfb...'; // User stark key
  const page = 1;
  const limit = 100;

  const listFilteredNfts = await onchainAssetManager.getAssetByStarkKey(starkKey, page, limit);

# async getAssetEqualMetadataById(payload) → {CommonPaginateDataTypes.<NftAssetEqualMetadataResponse>|undefined}

Get NFTs with same metadata

Parameters:
Name Type Description
payload QueryEqualMetadataNftAssetParams

The payload to request the same assets/NFTs

View Source modules/OnchainAssetManager.ts, line 710

Exception: AssetId is required

string

The list of same NFTs which have same metadata for the asset request

Example

Staging example code for getAssetEqualMetadataById({})

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const assetId = 100;
  const requestEqualMetadata = {
    assetId: 100,
  };

  const sameNftsWithMetadata = await onchainAssetManager.getAssetEqualMetadataById(requestEqualMetadata);

# async getAssets(dataopt) → {CommonPaginateDataTypes.<Array.<AssetDetailsResponse>>|undefined}

Get list of selling NFTs/assets

Parameters:
Name Type Attributes Description
data PagingDataParams <optional>

requested the list assets/NFTs in paging format

View Source modules/OnchainAssetManager.ts, line 540

The response data for list assets details

CommonPaginateDataTypes.<Array.<AssetDetailsResponse>> | undefined
Example

Staging example code for getAssets

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const queryAssets: PagingDataParams = {
    limit: 50,
    page: 1
  };

  const assetsData = await onchainAssetManager.getAssets(queryAssets);

# async getAssetsWithFilter(payload) → {APIResponseType.<CommonPaginateDataTypes.<AssetByCollectionIdResponse>>|undefined}

Query the assets / NFTs and apply filtering (mostly for NFTs querying based on metadata)

Parameters:
Name Type Description
payload CollectionByIdDetailsParams

Query the assets / NFTs request with collection IDs and filterField, filterValue

View Source modules/OnchainAssetManager.ts, line 623

Exception: Owner public key is required

string

Get list assets of NFTs

APIResponseType.<CommonPaginateDataTypes.<AssetByCollectionIdResponse>> | undefined
Example

Staging example code for getAssetsWithFilter

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const queryAssetsPayload: CollectionByIdDetailsParams = {
    sortingField: 'created_at',
    orderBy: AssetOrderBy.DESC, 
    filterField: 'metadata',
    filterValue: '{body: ["Mustard"]}',
    collectionId: 10,
  };

  const listFilteredNfts = await onchainAssetManager.getAssetsWithFilter(queryAssetsPayload);

# async getNftAssetsByStatus(payload) → {CommonPaginateDataTypes.<Array.<AssetHaveOrderResponse>>|undefined}

Function is to query the list of NFTs with a given order status along with the option to sort the data by specific fields

Parameters:
Name Type Description
payload QueryAssetParams

The requested for assets query

View Source modules/OnchainAssetManager.ts, line 739

Exception: Order status is required

string
CommonPaginateDataTypes.<Array.<AssetHaveOrderResponse>> | undefined
Example

Staging example code for getNftAssetsByStatus({})

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const queryNftParams: QueryAssetParams = {
    orderType: OrderType.SELL,
    status: OrderStatus.ACTIVE,
    sortingField: "amountSell",
    orderBy: AssetOrderBy.ASC; // increasement by the prices of NFT list
  };

  const sameNftsWithMetadata = await onchainAssetManager.getNftAssetsByStatus(queryNftParams);

# async queryAssetsByCollectionOwner(queryAssetParams) → {QueryAssetsWithCollectionResponse}

Query the assets list by the collection owner

Parameters:
Name Type Description
queryAssetParams QueryAssetParamsByOwner

View Source modules/OnchainAssetManager.ts, line 683

Exception: Collection IDs are required

string

Exception: Owner stark key is required

string

The assets list data includes collections / NFTs data of all and specific players

Example

Staging example code for queryAssetsByCollectionOwner({})

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const queryNftPayload: QueryAssetParamsByOwner = {
    starkKey: '0xfb...',
    ownerWalletAddress: '0xab....', // Owner of the nfts
    collectionIds: [1,2,3,5], // The list of collections ID that partners have in myria system
    walletAddress: '0xa9a......', // Example of user's wallet address - it's optional, if wallet address is not passed, it's default to return all of nft's data for different users wallet address
    page: 1,
    limit: 100,
  };

  const listFilteredNfts = await onchainAssetManager.queryAssetsByCollectionOwner(queryNftPayload);

# async recrawlBatchNftMetadata(payload) → {APIResponseType.<RecrawlBatchNftMetadataResponse>|undefined}

The function to recrawl the list of NFTs in range with start token id and end token id

Parameters:
Name Type Description
payload RecrawlBatchNftMetadataParams

The request payload to recraw the list of NFT's metadata

View Source modules/OnchainAssetManager.ts, line 774

Exception: CreatorStarkKey is required

string

Exception: StartTokenId is required

string

Exception: EndTokenId is required

string

Exception: TokenAddress is required

string

Exception: Start tokenId should be less than end tokenId.

string

Exception: Token address should be the valid ethereum address type

string

Http Status 500: Refresh metadata failed: ${INTERNAL_SERVER_ERROR}

string
Example

Staging example code for recrawlBatchNftMetadata({})

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const recrawlNftMetadata: RecrawlBatchNftMetadataParams = {
    creatorStarkKey: '0xfbc.....',
    startTokenId: '1',
    endTokenId: '100',
    tokenAddress: '0xfbc.....'
  };

  const recrawlBatchNfts = await onchainAssetManager.recrawlBatchNftMetadata(recrawlNftMetadata);

# async refreshAssetMetadata(assetId, starkKey) → {APIResponseType.<AssetDetailsResponse>|undefined}

Refresh metadata for the NFTs and sync up with latest off-chain data for specific NFTs

Parameters:
Name Type Description
assetId string

The ID of the asset/NFT

starkKey string

The stark key owner of the asset to request refresh

View Source modules/OnchainAssetManager.ts, line 592

Exception: Asset Id is required

string

Exception: Stark Key is required

string

The full information of the refreshed NFTs/Assets

Example

Staging example code for refreshAssetMetadata({})

  const mClient: IMyriaClient = {
      networkId: Network.SEPOLIA,
      provider: web3Instance.currentProvider,
      web3: web3Instance,
      env: EnvTypes.STAGING,
  };

  const myriaClient = new MyriaClient(mClient);
  const onchainAssetManager = new OnchainAssetManager(myriaClient);

  const assetId = 100;
  const starkKey = '0xfb....'; // Stark key of user;

  const refreshNftResponse: APIResponseType<AssetDetailsResponse> | undefined = await onchainAssetManager.refreshAssetMetadata(assetId, starkKey);