ERC-1155の入力仕様ファイル

ブロックチェーン・アプリケーション・ビルダーの初期化コマンドは、入力仕様ファイルを読み取り、チェーンコード開発プロセスを支援する複数のツールを使用してスキャフォールド済プロジェクトを生成します。

同じ仕様ファイルのERC-1155標準に基づく、標準資産および真菌可能トークン・アセットと非真菌トークン・アセットの両方を定義できます。同じ仕様ファイルの複数の標準に基づいてトークン・アセットを定義することはできません。

標準アセットを仕様ファイルに含める方法の詳細は、「入力仕様ファイル」を参照してください。

ブロックチェーン・アプリケーション・ビルダー・パッケージでは、ERC-1155トークン・アセットの次のサンプル仕様ファイルを使用できます。
  • NFTArtCollectionMarketplacewithERC1155-TypeScript.yml
  • FractionalNFTinRealEstate-TypeScript.yml

トークン・アセットでは、標準プロパティおよびセクションに加えて、仕様ファイルのbehaviorおよびanatomyセクションもサポートされます。また、非代替トークン・アセットはmetadataセクションをサポートしています。次の例は、2つのERC-1155トークンアセット(非代替トークン全体と部分真菌トークン)の仕様ファイルの構造を示しています。

assets:
    - name: ArtCollection #Asset name
      type: token #Asset type
      standard: erc1155+   # Token standard
      
      anatomy:
          type: nonfungible # Token type
          unit: whole  #Token unit
      
      behavior:
        - indivisible                
        - mintable:                   
            max_mint_quantity: 20000
        - transferable                
        - burnable
        - 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: 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

    - name: Loyalty # Asset name
      type: token  # Asset type
      standard: erc1155+   # Token standard

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

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

      properties:
          - name: currency_name # Custom attribute to represent the token in a specific currency.
            type: string

          - name: token_to_currency_ratio # Custom attribute to specify the token to currency ratio.
            type: number

次の例は、fractional non-fungibleトークンの仕様ファイルの構造を示しています。

- name: RealEstateProperty #Asset name
      type: token #Asset type
      standard: erc1155+ # Token standard
      
      anatomy:
          type: nonfungible # Token type
          unit: fractional #Token unit
      
      behavior:
        - divisible:
        - mintable:
        - transferable
        - roles:
            minter_role_name: minter
      
      properties: # Custom asset attributes for non-fungible token.
          
          - name: propertySellingPrice # Custom asset attribute to set the real estate property selling price
            type: number
 
          - name: propertyRentingPrice # Custom asset attribute maintains the renting amount for the real estate property
            type: number
            
      metadata: # To maintain the metadata on-chain, this tag will be used. Users won't be able to update the metadata attribute values.
          
          - name: propertyType
            type: string
 
          - name: propertyName
            type: string
 
          - name: propertyAddress
            type: string
          
          - name: propertyImage
            type: string

表7-7 ERC-1155トークン仕様ファイルのパラメータの説明と例

開始時 説明
type:

assetsセクションでtype: tokenを指定する必要があります。

assets:
    - name: ArtCollection #Asset name
      type: token #Asset type
standard: standardプロパティは、ERC-1155トークンに必須です。これは、チェーンコード生成時に従うトークン標準を表します。
standard: erc1155+ # Token standard
anatomy:
anatomyセクションには、次の2つの必須パラメータがあります。
  • type: nonfungibleまたはtype: fungible

    無効でないトークンは一意です。

  • unit: wholeまたはunit: fractional

    トークン全体を小数の単位に分割することはできません。小数点トークンは、指定した小数点以下の桁数に基づいて、小さい単位(シェア)に細分化できます。

anatomy:
          type: nonfungible # Token type
          unit: whole #Token unit
behavior: この項では、トークンの機能および制限について説明します。mintabletransferableの動作は、すべてのトークンに必須です。indivisibleの動作は、非代替トークン全体では必須です。
  • indivisible: この動作では、トークン全体を小数に分割できないように制限がサポートされます。
  • divisible: この動作では、トークンを分割する方法を説明します。decimalパラメータは、使用できる小数点以下の桁数を指定します。小数点以下の数で可能な最小の割合は、所有できるトークンの最小の単位です。decimalパラメータを指定しない場合、デフォルトは小数点以下0桁です。
  • mintable: この必須動作では、新しいトークン・インスタンスの作成がサポートされます。オプションのmax_mint_quantityパラメータは、ミント可能なトークンの合計数を指定します。max_mint_quantityパラメータを指定しない場合、任意の数のトークンをミントできます。
  • transferable: この必須動作では、トークンの所有権の転送がサポートされます。
  • burnable: この動作では、トークンの非アクティブ化または書込みがサポートされます。書き込みは、トークンを削除するのではなく、使用できない永続的な状態にします。燃焼は可逆的ではない。
  • lockable: この動作はオプションであり、非代替トークンでのみサポートされます。この動作により、トークン所有者は非代替トークンをロックできます。ロックされたトークンは、他のユーザーが転送または書き込みすることはできません。
  • roles: この動作は、トークン動作を特定のロールを持つユーザーに制限します。現在、minter_role_nameburner_role_nameの2つのロールが使用可能です。ロールを指定しない場合は、任意のユーザーがマイナーまたはバーナーとして動作できます。たとえば、バーナー役割が指定されていない場合、すべてのアカウントユーザーが暗黙的にバーナー役割を持ちます。バーナー・ロールが指定されている場合、トークン設定プロセス中に、Token Adminユーザーはバーナー・ロールを他のユーザーに明示的に割り当てる必要があります。
behavior:
        - indivisible
        - 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

制限事項

ブロックチェーン・アプリケーション・ビルダーは、ERC-1155標準を部分的にサポートします。現在、次のERC-1155イベントおよびメソッドはサポートされていません。

イベント:
  • TransferSingle
  • TransferBatch
  • ApprovalForAll
  • URI
メソッド:
  • safeTransferFrom
  • balanceOf
  • setApprovalForAll
  • isApprovedForAll