LogoLogo
  • Horizon Network
    • What is Horizon Network?
    • API Document
      • Horizon Network API
      • Quick Start
      • API Reference
        • Assets
        • Collections
        • Orders
        • Offers
        • Events
        • Statistics
        • Categories
        • Chains
        • Request an API key
    • SDKs Document
      • SDKs overview
      • NODE SDK
        • Installation
        • Initialization
        • Basic Example
          • Assets Management
          • Marketplace
        • Reference
          • Assets
          • Collections
          • Offers
          • Orders
          • Categories
          • Events
          • Statistics
          • Blockchain and Layer 2
      • JAVASCRIPT SDK
        • Overview
        • Installation
        • Quickstart
        • Reference
    • Launching NFT Collection
      • Launch A Collection
        • Overview
        • Part 1: Register as a user
        • Part 2: Deploy a smart contract
        • Part 3: Set creator earnings
        • Horizon Example Repository
      • Creating Your NFT Smart Contract
        • Overview
        • Getting Started
        • Setting a basic project
        • Minting from your new contract
        • Add your own NFT contract to Horizon Network
    • Horizon Network's Layer 2 Solution
      • Why Horizon Network?
      • Horizon Network's layer 2 Solutions
      • Basic Concepts
  • Horizon Land Metaverse
    • Feature
      • LAND in the metaverse
      • NFT Avatar
      • Horizon Center
      • Game Center
      • Shopping Center
      • Music Center
      • Play to Earn
      • Social Activities
      • Finance Center
      • Marketplace
      • Experience Mode
      • Zon Token
    • Stake Holder
      • Players
      • Creators
      • Land Owners
      • Partners
      • Investors
    • Economy
      • Revenue Stream
  • Technology
    • Blockchain
    • Product
    • System
    • Wallet
    • Security
    • Token
  • Tokenomic
  • Investor & Partner
  • Roadmap
  • Contact
  • Conclusion
  • Recommendation
  • FAQs
    • Policy
    • Terms of Use
Powered by GitBook
On this page
  • Fetching Assets
  • Fetching Asset Detail
  • Create an Asset
  • References
  1. Horizon Network
  2. SDKs Document
  3. NODE SDK
  4. Basic Example

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" : "https://static.heroarena.app/videos/Elite-Beast-7-Mage-Coo.mp4",
  "metadata" : {"name":"Coo","image":"https://static.heroarena.app/videos/Elite-Beast-7-Mage-Coo.png","animation_url":"https://static.heroarena.app/videos/Elite-Beast-7-Mage-Coo.mp4","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" : "https://static.heroarena.app/videos/Rare-Elf-1-Warrior-Mirnana.png",
  "name" : "Mirnana",
  "description" : "",
  "tokenAddress" : "0x88Ef499ab1688DE727c21f1b72fAaEe1A3F455AD",
  "externalLink" : "https://heroarena.app/"
}

const result = await client.createAsset(asset);

References

PreviousBasic ExampleNextMarketplace

Last updated 2 years ago

Assets