Input Specification File for ERC-1155

The Blockchain App Builder initialization command reads the input specification file and generates the scaffolded project with several tools to assist in the chaincode development process.

You can define standard assets and both fungible and non-fungible token assets that are based on the ERC-1155 standard in the same specification file. You cannot define token assets based on more than one standard in the same specification file.

For information on including standard assets in the specification file, see Input Specification File.

The following sample specification files for ERC-1155 token assets are available in the Blockchain App Builder package:
  • NFTArtCollectionMarketplacewithERC1155-TypeScript.yml
  • FractionalNFTinRealEstate-TypeScript.yml

In addition to the standard properties and sections, token assets support the behavior and anatomy sections in the specification file. In addition, non-fungible token assets support the metadata section. The following example shows the structure of a specification file for two ERC-1155 token assets, a whole non-fungible token and a fractional fungible token:

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

The following example shows the structure of a specification file for a fractional non-fungible token:

- 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

Table 7-7 Parameter Descriptions and Examples for an ERC-1155 Token Specification File

Entry Description Examples
type:

You must specify type: token in the assets section.

assets:
    - name: ArtCollection #Asset name
      type: token #Asset type
standard: The standard property is mandatory for ERC-1155 tokens. It represents the token standard to follow during chaincode generation.
standard: erc1155+ # Token standard
anatomy:
The anatomy section has two mandatory parameters:
  • type: nonfungible or type: fungible

    A non-fungible token is unique.

  • unit: whole or unit: fractional

    A whole token cannot be subdivided into smaller fractional units. A fractional token can be subdivided into smaller units, or shares, based on a specified number of decimal places.

anatomy:
          type: nonfungible # Token type
          unit: whole #Token unit
behavior: This section describes the capabilities and restrictions of the token. The mintable, transferable behaviors are mandatory for all tokens. The indivisible behavior is mandatory for whole non-fungible tokens.
  • indivisible: This behavior supports a restriction so that whole tokens cannot be subdivided into fractions.
  • divisible: This behavior describes how tokens can be subdivided. The decimal parameter specifies the number of decimal places that can be used. The smallest fraction possible with the number of decimal places is the smallest unit of the token that can be owned. If the decimal parameter is not specified, the default is zero decimal places.
  • mintable: This mandatory behavior supports minting new token instances. The optional max_mint_quantity parameter specifies the total number of tokens that can be minted. If you do not specify the max_mint_quantity parameter, any number of tokens can be minted.
  • transferable: This mandatory behavior supports transferring ownership of tokens.
  • burnable: This behavior supports deactivating, or burning, tokens. Burning does not delete a token but instead places it in a permanent state where it cannot be used. Burning is not reversible.
  • lockable: This behavior is optional and is supported only by non-fungible tokens. This behavior allows the token owner to lock a non-fungible token. A locked token cannot be transferred to or burned by any other users.
  • roles: This behavior restricts token behaviors to users with specific roles. Currently two roles are available: minter_role_name and burner_role_name. If you do not specify roles, then any user can act as a minter or burner. For example, if the burner role is not specified, any account user implicitly has the burner role. If the burner role is specified, then during the token setup process, the Token Admin user must assign the burner role to other users explicitly.
behavior:
        - indivisible
        - mintable:
            max_mint_quantity: 20000
        - transferable
        - burnable
        - lockable
        - roles:
            minter_role_name: minter
metadata:

The metadata property is optional and is supported only by non-fungible tokens. This property specifies metadata information, which is stored on the blockchain, for a non-fungible token. Metadata attribute values can be assigned only by the token owner who mints the token, and cannot be updated after the token is minted.

In the example, name is the name of the metadata attribute and type is the type of value that the attribute has.

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

Limitations

Blockchain App Builder provides partial support for the ERC-1155 standard. Currently, the following ERC-1155 events and methods are not supported.

Events:
  • TransferSingle
  • TransferBatch
  • ApprovalForAll
  • URI
Methods:
  • safeTransferFrom
  • balanceOf
  • setApprovalForAll
  • isApprovedForAll