Kombiniertes Token Framework - Chaincode-Package

Das kombinierte Token-Framework verwendet den erweiterten ERC-1155-Standard, der von Blockchain App Builder unterstützt wird.

Das Beispiel des NFT Art Collection Marketplace veranschaulicht die Verwendung des kombinierten generischen Token-Frameworks. Das Beispiel enthält einen Chaincode, der einen Marktplatz für den Kauf und Verkauf von nicht fungiblen Token (NFTs) im Zusammenhang mit Kunstwerken darstellt. In diesem Beispiel integriert der NFT-Plattformanbieter Museen, die NFTs für Kunstwerke im Blockchain-Netzwerk prägen (erstellen) können. Verbraucher können dann NFTs aus den Museen mit Eth-Münzen oder ERC-20-Münzen kaufen. Wenn Verbraucher NFTs kaufen, vergeben Museen Treue-Token an ihre fungiblen Token-Konten. Verbraucher können auch NFTs weiterverkaufen. Der Chaincode implementiert die Methoden, die für die Verwaltung von Tokenlebenszyklen erforderlich sind, einschließlich Tokeninitialisierung, Kontovorgängen, Rollenzuweisungen, Minting, Übertragungen und Brennen. Es bietet auch Notarkonten für die Genehmigung von Präge-, Transfer- und Brennvorgängen und unterstützt die Compliance durch tägliche Grenzwerte und Auditingverfahren. Das NFT Art Collection Marketplace-Beispiel wurde für die Chaincode-Entwicklung in TypeScript entwickelt.

Das kombinierte Token Framework kann von der Oracle Blockchain Platform-Konsole heruntergeladen werden und umfasst die folgenden Komponenten.

  • NFTCollectiblesWithERC1155.zip, eine Archivdatei, die den in einem Package integrierten Chaincode für das Deployment enthält.
  • NFTCollectiblesWithERC1155-TypeScript.yaml, eine Spezifikationsdatei, die Sie mit Blockchain App Builder verwenden können, um den NFTCollectiblesWithERC1155-Kettencode zu erstellen.
  • NFTCollectiblesWithERC1155_postman_collection.json, eine Postman-Sammlung, mit der Sie die APIs im Chaincode testen können.
  • README.md, eine schrittweise Anleitung für die Arbeit mit dem Chaincode.

Um das fungible Token Framework abzurufen, klicken Sie in der Oracle Blockchain Platform Digital Assets-Konsole auf die Registerkarte Digitale Assets, und wählen Sie Kombiniertes Token Framework aus.

Weitere Informationen zur Verwendung von Postman-Sammlungen finden Sie in den folgenden Themen.

Spezifikationsdatei

Die Spezifikationsdatei, mit der der Chaincode des Art Collection Marketplace generiert wird, enthält das Attribut events. Die Chaincode-Ereignisfunktion unterstützt Ereignis-Callbacks in generierten Chaincodes, um Echtzeitbenachrichtigungen zu ermöglichen und Workflows auszulösen. Weitere Informationen zu Spezifikationsdateien und den in Spezifikationsdateien verwendeten Parametern finden Sie unter Eingabespezifikationsdatei für kombinierte Token in Oracle Blockchain Platform verwenden.

Der Marktplatz für Kunstsammlungen basiert auf dem erweiterten ERC-1155-Standard, wie in der folgenden Spezifikationsdatei dargestellt.
#
# 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