不可變權杖架構鏈碼套裝程式

不可行的權杖架構使用區塊鏈 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,您可以與區塊鏈應用程式建置器搭配使用的規格檔案,用來編排 NFTCollectiblesWithERC721 鏈碼。
  • NFTCollectiblesWithERC721_postman_collection.json 是一種 Postman 集合,可讓您測試鏈碼中的 API。
  • README.md,使用鏈碼的逐步指引。

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

如需有關使用 Postman 集合的詳細資訊,請參閱 Blockchain App Builder for Oracle Blockchain Platform 中的下列主題。

規格檔案

用來產生藝術收藏市集鏈碼的規格檔案包含 events 屬性。鏈碼事件函數支援所產生鏈碼中的事件回呼,以啟用即時通知並觸發工作流程。如需有關規格檔案與規格檔案中所使用參數的詳細資訊,請參閱 Blockchain App Builder for Oracle Blockchain Platform 中的 Input Specification File for Non-Fungible Tokens

藝術收藏市集鏈碼是以延伸的 ERC-721 標準為基礎,如下列規格檔案所示。
#
# Copyright (c) 2026, 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 參數會指定必須為交易背書的對等清單。如需詳細資訊,請參閱 Oracle Blockchain Platform 區塊鏈 App 產生器中的 Endorsement Support in 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