Pacote de Chaincode de Estrutura de Token Combinado

O framework de token combinado usa o padrão ERC-1155 estendido que é suportado pelo Blockchain App Builder.

A amostra do NFT Art Collection Marketplace ilustra o uso da estrutura genérica de token combinada. A amostra inclui um chaincode para representar um mercado para comprar e vender tokens não fungíveis (NFTs) associados a obras de arte. Nesta amostra, o provedor de plataforma NFT embarca em museus que podem cunhar (criar) NFTs para obras de arte na rede blockchain. Os consumidores podem então comprar NFTs dos museus usando moedas Eth ou moedas ERC-20. Quando os consumidores compram NFTs, os museus concedem tokens de fidelidade às suas contas de token fungíveis. Os consumidores também podem revender NFTs. O chaincode implementa os métodos necessários para gerenciar ciclos de vida de token, incluindo inicialização de token, operações de conta, atribuições de função, cunhagem, transferências e gravação. Ele também fornece contas de notário para aprovar operações de cunhagem, transferência e queima, e suporta a conformidade através de limites diários e procedimentos de auditoria. A amostra do NFT Art Collection Marketplace foi projetada para o desenvolvimento de chaincode em TypeScript.

O framework de token combinado pode ser baixado na console do Oracle Blockchain Platform e inclui os componentes a seguir.

  • NFTCollectiblesWithERC1155.zip, um arquivo compactado que contém o chaincode empacotado para implantação.
  • NFTCollectiblesWithERC1155-TypeScript.yaml, um arquivo de especificação que você pode usar com o Blockchain App Builder para organizar o chaincode NFTCollectiblesWithERC1155.
  • NFTCollectiblesWithERC1155_postman_collection.json, uma coleção Postman que permite testar as APIs no chaincode.
  • README.md, um guia passo a passo para trabalhar com o código da cadeia.

Para obter a estrutura de token fungível, na console Ativos Digitais do Oracle Blockchain Platform, clique na guia Ativos Digitais e selecione Estrutura de Token Combinado.

Para obter mais detalhes sobre o uso de coleções Postman, consulte os tópicos a seguir no Blockchain App Builder para Oracle Blockchain Platform.

Arquivo de Especificação

O arquivo de especificação usado para gerar o chaincode do marketplace de coleções de arte inclui o atributo events. A função de eventos chaincode suporta callbacks de eventos em chaincodes gerados para ativar notificações em tempo real e acionar workflows. Para obter mais informações sobre arquivos de especificação e os parâmetros usados em arquivos de especificação, consulte Arquivo de Especificação de Entrada para Tokens Combinados no Blockchain App Builder for Oracle Blockchain Platform.

O chaincode do mercado da coleção da arte é baseado no padrão estendido ERC-1155, como mostrado no seguinte arquivo de especificação.
#
# Copyright (c) 2026, 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