Assets

Assets

When details about assets are returned, there is a status property that indicates its current location (L1 or L2) or state (depositing, withdrawable, etc.). Assets can have one of the following statuses:

Get list of assets

  • Typescript Core SDK

📚SDK REFERENCE

  • listAssets

Request

Get a list of assets at a particular collection address ordered by name:

const getListAssets = async (
  collectionAddress: string,
  orderBy: 'updated_at' | 'name'
) => {
  const response = await client.listAssets({
    collection: collectionAddress,
    orderBy: orderBy,
  });
  return response.result;
};
getListAssets('0x23db0e72bd7738da0d0afe7bccb4109f5f05edcf', 'name')
  .then((result) => {
    //print the result
    console.log(result);
  })
  .catch((e) => {
    console.log(e);
  });

Example response

{
  result: [
    {
      token_address: '0x23db0e72bd7738da0d0afe7bccb4109f5f05edcf', // Address of the ERC721 contract
      token_id: '1', // ERC721 Token ID of this asset
      user: '0xd5aefc1fed909da9a5409594d758e3bdd055634c', // Ethereum address of the user who owns this asset
      status: 'imx', // Status of this asset (where it is in the system)
      uri: null, // URI to access this asset externally to XpansionChain 
      name: '1st NFT', // Name of this asset
      description: 'This is your 1st nft', // Description of this asset
      image_url: 'https://gateway.pinata.cloud/ipfs/QmS7p34oVDHB3VBE2d9bMqrbNFxdmxtwJ8BYcuHa9yNQHz', // URL of the image which should be used for this asset
      metadata: { // Metadata of this asset
        name: 'Juju Mints',
        icon_url: 'https://media-exp1.licdn.com/dms/image/C4E03AQFB06seGq_MGA/profile-displayphoto-shrink_100_100/0/1597970079587?e=1669248000&v=beta&t=hd0P3T5102HzRvsSK4TBtjhLJLaivuh0u3Qlu57g7lk'
      },
      collection: { // Details of the collection
        name: '1st NFT',
        class: 'EnumValue1',
        attack: 123,
        image_url: 'https://gateway.pinata.cloud/ipfs/QmS7p34oVDHB3VBE2d9bMqrbNFxdmxtwJ8BYcuHa9yNQHz',
        collectable: true,
        description: 'This is your 1st nft'
      },
      created_at: '2022-09-23T14:32:59.876942Z' // Timestamp of when the asset was created
      updated_at: '2022-09-23T14:34:01.793638Z',  // Timestamp of when the asset was updated
  },
  // Other assets returned
  ...
  ],
  cursor: "eyJpZCI6IjB4OTkzNzQyNzhiMThjM2YyNTA5MTFhZjVjMWM2ZGE1OGIxZmMxZjVkZDk1ZjBhYzFkYjA3MTgwOWI2MWM0M2E0ZCIsIm5hbWUiOiIxc3QgTkZUIiwidXBkYXRlZF9hdCI6IjIwMjItMDktMjNUMTQ6MzQ6MDEuNzkzNjM4WiJ9",
  // Remaining results
  remaining: 1,
}

  • Kotlin (JVM) Core SDK

📚SDK REFERENCE

  • listAssets

  • Swift Core SDK

📚SDK REFERENCE

  • listAssets

  • Golang Core SDK

📚SDK REFERENCE

  • ListAssets

  • C# Core SDK

📚SDK REFERENCE

  • ListAssets

See also listAssets example in the Core SDK.

Get details about an asset

  • Typescript Core SDK

📚SDK REFERENCE

  • listAssets

Request

Get details of an asset from a particular collection with ID of 1:

const getAsset = async (
  tokenAddress: string,
  tokenId: string,
  includeFees: boolean
) => {
  const response = await client.getAsset({
    tokenAddress,
    tokenId,
    includeFees,
  });
  return response;
};
getAsset('0x23db0e72bd7738da0d0afe7bccb4109f5f05edcf', '1', true)
  .then((result) => {
    console.log(result);
  })
  .catch((e) => {
    console.log(e);
  });

Example response

{
      token_address: '0x23db0e72bd7738da0d0afe7bccb4109f5f05edcf', // Address of the ERC721 contract
      token_id: '1', // ERC721 Token ID of this asset
      user: '0xd5aefc1fed909da9a5409594d758e3bdd055634c', // Ethereum address of the user who owns this asset
      status: 'imx', // Status of this asset (where it is in the system)
      uri: null, // URI to access this asset externally to XpansionChain 
      name: '1st NFT', // Name of this asset
      description: 'This is your 1st nft', // Description of this asset
      image_url: 'https://gateway.pinata.cloud/ipfs/QmS7p34oVDHB3VBE2d9bMqrbNFxdmxtwJ8BYcuHa9yNQHz', // URL of the image which should be used for this asset
      metadata: { // Metadata of this asset
        name: 'Juju Mints',
        icon_url: 'https://media-exp1.licdn.com/dms/image/C4E03AQFB06seGq_MGA/profile-displayphoto-shrink_100_100/0/1597970079587?e=1669248000&v=beta&t=hd0P3T5102HzRvsSK4TBtjhLJLaivuh0u3Qlu57g7lk'
      },
      collection: { // Details of the collection
        name: '1st NFT',
        class: 'EnumValue1',
        attack: 123,
        image_url: 'https://gateway.pinata.cloud/ipfs/QmS7p34oVDHB3VBE2d9bMqrbNFxdmxtwJ8BYcuHa9yNQHz',
        collectable: true,
        description: 'This is your 1st nft'
      },
      created_at: '2022-09-23T14:32:59.876942Z' // Timestamp of when the asset was created
      updated_at: '2022-09-23T14:34:01.793638Z',  // Timestamp of when the asset was updated
      fees: [  // Royalties to pay on this asset operations
        {
          type: 'protocol',
          address: '0xc8714f989ce817e5d21349888077aa5db4a9bcf6',
          percentage: 2
        }
      ]
  }

  • Kotlin (JVM) Core SDK

📚SDK REFERENCE

  • get-asset

  • Swift Core SDK

📚SDK REFERENCE

  • getasset

  • Golang Core SDK

📚SDK REFERENCE

  • GetAsset

  • C# Core SDK

📚SDK REFERENCE

  • GetAsset

See also listAssets example in the Core SDK.

Last updated