Input Specification File for ERC-721

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 token assets that are based on the ERC-721 standard in the same specification file. The following restrictions apply to a specification file that includes an ERC-721 token asset definition:
  • You cannot define token assets based on more than one standard in the same specification file.
  • You cannot define multiple non-fungible token assets in a single specification file.

Custom attribute values for non-fungible token assets can be updated by the token owner.

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

The following sample specification file for an ERC-721 token asset is available in the Blockchain App Builder package:
  • NFTArtCollectionMarketPlace with ERC-721-Typescript.yml

In addition to the standard properties and sections, non-fungible token assets support the behavior, anatomy and metadata sections in the specification file. Non-fungible token assets also support the standard and symbol properties. The following example shows the structure of a specification file for an ERC-721 token asset:

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

Table 7-6 Parameter Descriptions and Examples for an ERC-721 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
symbol: The symbol property represents the symbol that identifies the token contract, for example ART. Typically the symbol is 3 to 4 characters long.
symbol: ART # Token symbol
standard: The standard property is mandatory for non-fungible tokens. It represents the token standard to follow during chaincode generation. In Blockchain App Builder, non-fungible tokens follow a partial version of the ERC-721 standard. For more information, see Limitations.
standard: erc721+ # Token standard
anatomy:
The anatomy section has two mandatory parameters for non-fungible tokens:
  • type: nonfungible

    A non-fungible token is unique.

  • unit: whole

    A whole token cannot be subdivided into smaller fractional units.

anatomy:
          type: nonfungible # Token type
          unit: whole #Token unit
behavior: This section describes the capabilities and restrictions of the token. The mintable, transferable, singleton, and indivisible behaviors are mandatory for non-fungible tokens.
  • singleton: This mandatory behavior supports a restriction so that there can be only one whole token in the class, which cannot be divided.
  • indivisible: This mandatory behavior supports a restriction so that whole tokens cannot be subdivided into fractions.
  • 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 optional 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 optional 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
        - singleton
        - 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-721 standard. Currently, the following ERC-721 events and methods are not supported.

Events:
  • event Transfer
  • event Approval
  • event ApprovalForAll
Methods:
  • approve
  • getApproved
  • setApprovalForAll
  • isApprovedForAll