Assets Management

Fetching Assets

Assets are items on Horizon Network. They are represented by the Asset type, defined in TypeScript:

 * Simple NFT asset spec
export interface Asset {
  // Information about the collection to which this asset belongs
  collection: collectionSchema,
  // Name of this asset
  name: string,
  // The asset's token ID
  token_id: string,
  // The asset's contract address
  token_address: string,
  // Address of the user who owns this asset
  owner: string,
  // Description of this asset
  description?: string,

The Asset is the minimal type you need for most marketplace actions. The following call will retrieve all Assets from a specific assetContract:

const opts = {
  'assetContract': "0x88Ef499ab1688DE727c21f1b72fAaEe1A3F455AD"
const asset: Assets = await client.getAssets(opts)

Fetching Asset Detail

The following call will retrieve an Asset from a specific tokenId and assetContract:

const asset: Assets = await client.getAsset(assetContract, tokenId)

Create an Asset

The apiKey was required for all creating and updating APIs, please follow to setup apiKey

The following all will create an Asset

const asset = {
  "collectionId" : "e304962a-b76a-11ed-afa1-0242ac120002",
  "owner" : "0x0dD768A47eA2395bbE5574E3252505fe1202C4A8",
  "animationUrl" : "",
  "metadata" : {"name":"Coo","image":"","animation_url":"","attributes":[{"trait_type":"hero","value":117333023},{"trait_type":"race","value":"Beast"},{"trait_type":"name","value":"Coo"},{"trait_type":"hp","value":2801},{"trait_type":"atk","value":194},{"trait_type":"def","value":204},{"trait_type":"speed","value":371},{"trait_type":"crit","value":10}]},
  "chainId" : 56,
  "imageUrl" : "",
  "name" : "Mirnana",
  "description" : "",
  "tokenAddress" : "0x88Ef499ab1688DE727c21f1b72fAaEe1A3F455AD",
  "externalLink" : ""

const result = await client.createAsset(asset);



Last updated