組合記號架構鏈碼套件

合併的權杖架構使用區塊鏈 App 產生器支援的延伸 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,您可以搭配 Blockchain App Builder 使用以編排 NFTCollectiblesWithERC1155 鏈碼的規格檔案。
  • NFTCollectiblesWithERC1155_postman_collection.json - Postman 集合,可讓您測試鏈碼中的 API。
  • README.md - 使用鏈碼的逐步指南。

若要取得有趣的權杖架構,請在 Oracle Blockchain Platform Digital Assets 主控台中,按一下數位資產頁籤,然後選取合併權杖架構

規格檔案

用來產生藝術集合市集鏈碼的規格檔案包含 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