不適用的權杖架構鏈碼套件

不可行的權杖架構使用區塊鏈 App 產生器支援的擴充 ERC-721 標準。

NFT Art Collection Marketplace 範例說明使用非可行記號一般架構,此架構以 Blockchain App Builder 支援的延伸 ERC-721 標準為基礎。此範例包含一個鏈碼,代表用於購買和銷售與藝術作品相關的不可行變數替代字 (NFT)。在此範例中,博物館可以為區塊鏈網路中的圖稿染 (建立) NFT。消費者之後可以從博物館購買 NFT,再經銷。該鏈碼實行了管理不可行記號生命週期所需的方法,包括記號初始化、帳戶作業、角色指派、挖掘、轉移和燒錄。它也提供核准採礦、移轉及燃燒作業的公證帳戶,並透過每日限制與稽核程序來支援規範。NFT Art Collection Marketplace 範例是針對 TypeScript 中的鏈碼開發所設計。

無法執行的權杖架構鏈碼套件可從 Oracle Blockchain Platform 主控台下載,並包含下列元件。
  • NFTCollectiblesWithERC721.zip,包含用於部署之封裝鏈碼的封存檔案。
  • NFTCollectiblesWithERC721-TypeScript.yaml,您可以搭配 Blockchain App Builder 使用以編排 NFTCollectiblesWithERC721 鏈碼的規格檔案。
  • NFTCollectiblesWithERC721_postman_collection.json - Postman 集合,可讓您測試鏈碼中的 API。
  • README.md - 使用鏈碼的逐步指南。

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

規格檔案

用來產生藝術集合市集鏈碼的規格檔案包含 events 屬性。鏈碼事件功能支援所產生鏈碼中的事件回呼,以啟用即時通知並觸發工作流程。如需有關規格檔案與規格檔案中所使用參數的詳細資訊,請參閱使用 Oracle Blockchain Platform 中的非真品替代字的輸入規格檔案

藝術收藏市場鏈碼是以延伸的 ERC-721 標準為基礎,如下列規格檔案所示。
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
#
 
# This specification file is an example how to build any whole non-fungible token application.
# For a whole non-fungible token application, art collection marketplace has been used as an example.
# Art collection marketplace is a digital marketplace that uses NFTs to enable the buying, selling, and showcasing of unique art pieces, providing secure ownership, provenance tracking, and exclusive rights for artists and collectors.
 
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
 
customMethods:
    - executeQuery
    - "post(token_id: string, selling_price: number)" # Post the non-fungible token for selling in the marketplace.
    - "buy(from_org_id: string, from_user_id: string, to_org_id: string, to_user_id: string, nonfungible_token_id: string, amount_paid: number)"  # Buy the non-fungible token after paying the amount using any payment gateways.

鏈碼方法中的背書人明細

Oracle Blockchain Platform Digital Assets Edition 會為所有 setter 方法的要求有效負載新增背書參數。參數的值為 endorserssameOrgEndorser。如果 sameOrgEndorser 參數為 true,則交易背書必須來自與要求者相同的組織。endorsers 參數指定必須為交易背書的對等項目清單。如需詳細資訊,請參閱 Postman Collections 中的背書支援。下表顯示每個方法的背書人類型。

方法 背書人類型
activateAccount endorsers
addTokenAdmin sameOrgEndorser
addRole endorsers
addTokenSysRole endorsers
balanceOf endorsers
buy endorsers
createAccount endorsers
createArtCollectionToken sameOrgEndorser
deleteAccount endorsers
getAccountByUser endorsers
getAccountHistory endorsers
getAccountsByRole endorsers
getAccountsByTokenSysRole endorsers
getAccountStatus endorsers
getAccountStatusHistory endorsers
getAccountTransactionHistory endorsers
getAccountTransactionHistoryWithFilters endorsers
getAllAccounts endorsers
getAllLockedNFTs endorsers
getAllTokenAdmins endorsers
getAllTokens endorsers
getAllTokensByUser endorsers
getLockedNFTsByOrg endorsers
getTokenById endorsers
getTokenHistory endorsers
getTransactionById endorsers
getUserByAccountId endorsers
getUsersByRole endorsers
getUsersByTokenSysRole endorsers
init endorsers
isInRole endorsers
isInTokenSysRole endorsers
isNFTLocked endorsers
isTokenAdmin endorsers
lockNFT sameOrgEndorser
name endorsers
ownerOf endorsers
post endorsers
removeRole endorsers
removeTokenAdmin sameOrgEndorser
removeTokenSysRole endorsers
safeTransferFrom endorsers
suspendAccount endorsers
symbol endorsers
tokenURI endorsers
totalNetSupply endorsers
totalSupply endorsers
transferFrom endorsers
transferTokenSysRole endorsers
updateArtCollectionToken sameOrgEndorser