组合标记框架链代码程序包

组合令牌框架使用区块链应用程序构建器支持的扩展 ERC-1155 标准。

NFT Art Collection Marketplace 示例展示了组合令牌通用框架的使用。该样本包括一个链码,代表购买和销售与艺术品相关的非同质代币 (NFT) 的市场。在这个例子中,NFT 平台供应商在博物馆上,他们可以铸造(创建)区块链网络中艺术品的 NFT。然后,消费者可以使用 Eth 硬币或 ERC-20 硬币从博物馆购买 NFT。当消费者购买 NFT 时,博物馆将忠诚度代币授予其可替换代币账户。消费者还可以转售 NFT。链代码实现管理令牌生命周期所需的方法,包括令牌初始化、帐户操作、角色分配、铸造、传输和刻录。它还提供了用于批准铸造、转移和燃烧操作的公证账户,并通过日常限制和审计程序支持合规性。NFT Art Collection Marketplace 示例专为 TypeScript 中的链代码开发而设计。

组合令牌框架可从 Oracle Blockchain Platform 控制台下载,并包括以下组件。

  • NFTCollectiblesWithERC1155.zip,包含要部署的打包链代码的归档文件。
  • NFTCollectiblesWithERC1155-TypeScript.yaml,可与区块链应用程序构建器一起使用的规范文件,用于支持 NFTCollectiblesWithERC1155 链代码。
  • NFTCollectiblesWithERC1155_postman_collection.json,一个 Postman 集合,允许您测试链代码中的 API。
  • README.md,用于处理链代码的分步指南。

要获取可替换令牌框架,请在 Oracle Blockchain Platform Digital Assets 控制台中单击数字资产选项卡,然后选择组合令牌框架

有关使用 Postman 集合的更多详细信息,请参阅以下主题。

规范文件

用于生成艺术品集合市场链代码的规范文件包括 events 属性。链代码事件函数支持生成的链代码中的事件回调,以启用实时通知和触发工作流。有关规范文件和规范文件中使用的参数的详细信息,请参阅使用 Oracle Blockchain Platform 中的组合标记的输入规范文件

艺术品收藏市场链代码基于扩展的 ERC-1155 标准,如以下规范文件所示。
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
#
 
# This specification file is an example how to build any whole combined token application that includes fungible and non-fungible tokens together.
# For a combined token application, art collection marketplace with loyalty token has been used as an example.
# Art collection marketplace is a digital marketplace for buying and selling NFT art that rewards users with fungible loyalty tokens for their participation.
 
assets:
    - name: ArtCollection #Asset name
      type: token #Asset type
      symbol: ART         # Token symbol
      standard: erc721+   # Token standard
      events: true # Supports event code generation for non-GET methods
 
      anatomy:
          type: nonfungible # Token type
          unit: whole  #Token unit
       
      behavior:
        - indivisible
        - singleton                               
        - mintable:                  
            max_mint_quantity: 20000
        - transferable               
        - lockable
        - roles:
            minter_role_name: minter
       
      properties:  # Custom asset attributes for non-fungible token
           
          - name: Price # Custom asset attribute to set the price of a non-fungible token in the marketplace
            type: float
           
          - name: On_Sale_Flag # Custom asset attribute to maintain non-fungible token selling status in the marketplace
            type: boolean
       
      metadata: # To maintain the metadata on-chain, this tag will be used. Users won't be able to update the metadata attribute values after an NFT is minted.
           
          - name: Painting_Name # Custom asset attribute to represent the title given to a piece of artwork.
            type: string
           
          - name: Description # Custom asset attribute to represent a detailed explanation or interpretation of the painting's concept, style, or message.
            type: string
           
          - name: Painter_Name # Custom asset attribute to represent the name of the artist who created the painting.
            type: string

    - name: Loyalty #Asset name
      type: token #Asset type
      standard: erc1155+   # Token standard
      events: true # Supports event code generation for non-GET methods
 
      anatomy:
          type: fungible # Token type
          unit: fractional  #Token unit
       
      behavior: # Token behaviors
        - divisible:
              decimal: 2
        - mintable:                  
            max_mint_quantity: 100000
        - transferable               
        - burnable
        - roles:
            minter_role_name: minter

      properties:
          - name: Token_Name # Custom attribute to represent the token name.
            type: string
           
          - name: Token_to_Currency_Ratio # Custom attribute to specify the token to currency ratio. This attribute is helpful for exchanging the tokens with fiat currency.
            type: number

customMethods:
    - executeQuery
    - "post(token_id: string, selling_price: number)" # Post the non-fungible token for selling in the marketplace
    - "buyWithEthCoin(from_org_id: string, from_user_id: string, to_org_id: string, to_user_id: string, nft_id: string[], loyalty_id: string[], eth_qty: number[], loyalty_reward_quantity: number[])"  # Buy the non-fungible token after paying the amount using Eth Coin and receive loyalty points in return