ERC-1155 的输入规范文件
Blockchain App Builder 初始化命令读取输入规范文件,并使用多个工具生成脚手架项目,以协助链代码开发过程。
您可以在同一规范文件中定义基于 ERC-1155 标准的标准资产以及可替换和非可替换标记资产。无法根据同一规范文件中的多个标准定义标记资产。
有关在规范文件中包括标准资产的信息,请参阅输入规范文件。
区块链应用程序构建器程序包中提供了 ERC-1155 令牌资产的以下示例规范文件:
NFTArtCollectionMarketplacewithERC1155-TypeScript.yml
FractionalNFTinRealEstate-TypeScript.yml
除了标准属性和节之外,令牌资产还支持规范文件中的 behavior
和 anatomy
节。此外,不可替代的令牌资产支持 metadata
部分。以下示例显示了两个 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
以下示例显示了小数非可替换标记的规范文件的结构:
- 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: |
必须在 |
|
standard: |
对于 ERC-1155 令牌,standard 属性是必需的。它表示链代码生成期间要遵循的标记标准。
|
|
anatomy: |
anatomy 部分有两个必需参数:
|
|
behavior: |
本节介绍令牌的功能和限制。对于所有令牌,mintable 和 transferable 行为都是必需的。对于整个不可替换令牌,indivisible 行为是必需的。
|
|
metadata: |
在示例中, |
|
限制
Blockchain App Builder 为 ERC-1155 标准提供了部分支持。目前,不支持以下 ERC-1155 事件和方法。
事件:
TransferSingle
TransferBatch
ApprovalForAll
URI
方法:
safeTransferFrom
balanceOf
setApprovalForAll
isApprovedForAll