ERC-721 的輸入規格檔案

Blockchain App Builder 初始化命令會讀取輸入規格檔案,並使用多種工具產生結構化專案,以協助鏈碼開發程序。

您可以定義以相同規格檔案中 ERC-721 標準為基礎的標準資產和記號資產。下列限制適用於包含 ERC-721 記號資產定義的規格檔案:
  • 您無法根據相同規格檔案中的多個標準來定義權杖資產。
  • 您無法在單一規格檔案中定義多個不可行的權杖資產。

權杖擁有者可以更新不可行權杖資產的自訂屬性值。

如需有關在規格檔案中包含標準資產的資訊,請參閱輸入規格檔案

Blockchain App Builder 套件中提供下列 ERC-721 權杖資產的範例規格檔案:
  • NFTArtCollectionMarketPlace with ERC-721-Typescript.yml

除了標準特性和區段之外,不可行記號資產還支援規格檔案中的 behavioranatomymetadata 區段。非功能權杖資產也支援 standardsymbol 特性。下列範例顯示 ERC-721 記號資產的規格檔案結構:

assets:
    - name: ArtCollection #Asset name
      type: token #Asset type
      symbol: ART # Token symbol
      standard: erc721+ # Token standard
      
      anatomy:
          type: nonfungible # Token type
          unit: whole #Token unit
      
      behavior:
        - indivisible
        - singleton
        - mintable:
            max_mint_quantity: 20000
        - transferable
        - burnable
        - lockable
        - roles:
            minter_role_name: minter
      
      properties: # Custom asset attributes for non-fungible tokens
          
          - name: price # Custom asset attribute to set the price of a non-fungible token in the marketplace
            type: number
          
          - name: on_sale_flag # Custom asset attribute maintains non-fungible token selling status in the marketplace
            type: boolean
      
      metadata: # Use this section to maintain the metadata on the blockchain. Only the user creating the non-fungible token can assign metadata attribute values, which cannot be updated later.
          
          - name: painting_name
            type: string
          
          - name: description
            type: string
          
          - name: image
            type: string
          
          - name: painter_name
            type: string

表格 7-6 ERC-721 記號規格檔案的參數描述與範例

進入 描述 範例
type:

您必須在 assets 區段中指定 type: token

assets:
    - name: ArtCollection #Asset name
      type: token #Asset type
symbol: symbol 特性代表識別記號合約的符號,例如 ART。符號的長度通常為 3 到 4 個字元。
symbol: ART # Token symbol
standard: standard 特性是不可行記號的必要特性。它代表產生鏈碼時要遵循的記號標準。在 Blockchain App Builder 中,非功能權杖遵循部分版本的 ERC-721 標準。如需詳細資訊,請參閱限制
standard: erc721+ # Token standard
anatomy:
anatomy 區段具有兩個不可行記號的必要參數:
  • type: nonfungible

    無法使用的記號是唯一的。

  • unit: whole

    整個記號無法細分為較小的分數單位。

anatomy:
          type: nonfungible # Token type
          unit: whole #Token unit
behavior: 本節說明記號的功能與限制。mintabletransferablesingletonindivisible 行為對於不可行記號是必要的。
  • singleton:此強制行為支援限制,因此類別中只能有一個無法分割的整個記號。
  • indivisible:此必要行為支援限制,因此整個記號無法細分為分數。
  • mintable:此必要行為支援微調新的記號執行處理。選擇性的 max_mint_quantity 參數會指定可被提示的記號總數。如果您未指定 max_mint_quantity 參數,則任意數目的記號都可以被提示。
  • transferable:此必要行為支援傳輸記號的所有權。
  • burnable:此選擇性行為支援停用或燒錄記號。燒錄並不會刪除記號,而是將記號置於無法使用的永久狀態。燒錄無法回復 。
  • lockable:此行為是選擇性的,只有非有趣的記號才支援。此行為可讓權杖擁有者鎖定不可行的權杖。鎖定的記號無法被任何其他使用者傳輸或燒錄。
  • roles:此選擇性行為會將記號行為限制為具有特定角色的使用者。目前有兩個可用的角色:minter_role_nameburner_role_name。如果您未指定角色,則任何使用者都可以作為較小或較燒錄者。例如,如果未指定 burner 角色,則任何帳戶使用者都具有 burner 角色。如果已指定工作人員角色,則在記號設定程序期間,Token Admin 使用者必須明確指派工作人員角色給其他使用者。
behavior:
        - indivisible
        - singleton
        - mintable:
            max_mint_quantity: 20000
        - transferable
        - burnable
        - lockable
        - roles:
            minter_role_name: minter
metadata:

metadata 特性是選擇性的,只有非有趣的記號才支援。此特性會為不可行記號指定儲存在區塊鏈中的描述資料資訊。描述資料屬性值只能由負責提示記號的記號擁有者指定,而且在記號被提示後便無法更新。

在範例中,name 是中繼資料屬性的名稱,而 type 是屬性具有的值類型。

metadata:
                                
                                - name: painting_name
                                type: string
                                
                                - name: description
                                type: string
                                
                                - name: image
                                type: string
                                
                                - name: painter_name
                                type: string

限制

Blockchain App Builder 為 ERC-721 標準提供部分支援。目前不支援下列 ERC-721 事件和方法。

事件:
  • event Transfer
  • event Approval
  • event ApprovalForAll
方法:
  • approve
  • getApproved
  • setApprovalForAll
  • isApprovedForAll