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.
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 |
|
standard: |
The standard property is mandatory for
ERC-1155 tokens. It represents the token standard to follow during
chaincode generation.
|
|
anatomy: |
The
anatomy section has two mandatory
parameters:
|
|
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.
|
|
metadata: |
The In the example, |
|
Limitations
Blockchain App Builder provides partial support for the ERC-1155 standard. Currently, the following ERC-1155 events and methods are not supported.
TransferSingle
TransferBatch
ApprovalForAll
URI
safeTransferFrom
balanceOf
setApprovalForAll
isApprovedForAll