權杖分類架構的輸入規格檔案

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

您可以在相同的規格檔案中,定義以「記號分類架構」為基礎的標準資產和記號資產。您無法根據相同規格檔案中的多個標準來定義權杖資產。

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

Blockchain App Builder 套裝程式中提供下列有趣的權杖資產範例規格檔案:
  • FiatMoneyToken.yml
  • LoyaltyToken-Go.yml

除了標準特性和區段之外,有趣的記號資產還支援規格檔案中的 behavioranatomy 區段。有趣的記號資產也支援 standard 特性。下列範例顯示以「記號分類架構」為基礎之有趣記號資產的規格檔案結構:

assets:
    - name: OBPTOK # Asset name
      type: token  # Asset type

      anatomy: 
          type: fungible # Token type
          unit: fractional # Token unit

      behavior: # Token behaviors
          - divisible: 
                decimal: 2  
          - mintable: 
                max_mint_quantity: 1000 
          - transferable
          - burnable 
          - roles: 
                minter_role_name: minter 

      properties:
          - name: currency_name # Custom attribute to represent the token in certain currency. This attribute is helpful for exchanging the tokens with fiat currency.
            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

表格 7-5 有趣記號規格檔案的參數描述和範例

進入 描述 範例
type:

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

assets:
    - name: OBPTOK # Asset name
      type: token  # Asset type
standard: standard 特性代表產生鏈碼時要遵循的記號標準。有趣的記號只支援 ttf+ 值。如果未為有趣的記號指定 standard 特性,則會遵循「記號分類架構 (TTF)」標準。

      standard: ttf+ # Token standard
anatomy:
anatomy 區段有兩種可供有趣記號使用的必要參數:
  • type: fungible

    有趣的記號數量與相同類別記號的另一個相同數量值相同。

  • unit: fractional

    可根據指定的小數位數,將小數記號細分為較小的單位。

anatomy: 
          type: fungible # Token type
          unit: fractional # Token unit
behavior: 本節說明記號的功能與限制。有趣的記號必須要有 mintabletransferable 行為。
  • mintable:此必要行為支援微調新的記號執行處理。選擇性的 max_mint_quantity 參數會指定可被提示的記號總數。如果您未指定 max_mint_quantity 參數,則任意數目的記號都可以被提示。
  • transferable:此必要行為支援傳輸記號的所有權。
  • divisible:此選擇性行為描述如何細分記號。decimal 參數指定可使用的小數位數。小數位數可包含的最小小數位數是可擁有權杖的最小單位。如果未指定 decimal 參數,則預設值為零小數位數。
  • burnable:此選擇性行為支援停用或燒錄記號。燒錄並不會刪除記號,而是將記號置於無法使用的永久狀態。燒錄無法回復 。
  • holdable:此選擇性行為會指出記號餘額是否可以在付款人與受款人之間保留。
  • roles:此選擇性行為會將記號行為限制為具有特定角色的使用者。目前共有三個角色:minter_role_nameburner_role_namenotary_role_name。如果您未指定角色,則任何使用者都可作為較小、較燒錄者或公證人。例如,如果未指定 burner 角色,則任何帳戶使用者都具有 burner 角色。如果已指定工作人員角色,則在記號設定程序期間,Token Admin 使用者必須明確指派工作人員角色給其他使用者。
behavior:
  - mintable:
        max_mint_quantity: 20000
  - transferable
  - divisible:
        decimal: 1
  - burnable
  - holdable
  - roles:
        minter_role_name: minter
        burner_role_name: burner
        notary_role_name: notary

若要建立多個使用不同 max_mint_quantity 參數的有趣記號 ID,請為規格檔案中的每個記號 ID 建立個別的記號資產,並在記號資產與記號 ID 之間建立 1:1 關係。

若要建立多個使用相同 max_mint_quantity 參數或沒有 max_mint_quantity 參數的有趣記號 ID,請在規格檔案中建立要用於所有記號 ID 的單一記號資產。