Fichier de spécification d'entrée pour ERC-1155
La commande d'initialisation du générateur d'applications de chaîne de blocs lit le fichier de spécification d'entrée et génère le projet échafaudé avec plusieurs outils pour faciliter le processus de développement de code de chaîne.
Vous pouvez définir des immobilisations standard et des immobilisations jetons fongibles et non fongibles qui sont basées sur la norme ERC-1155 dans le même fichier de spécification. Vous ne pouvez pas définir des ressources de jeton en fonction de plusieurs normes dans le même fichier de spécification.
Pour plus d'informations sur l'inclusion de ressources standard dans le fichier de spécification, voir Fichier de spécification d'entrée.
NFTArtCollectionMarketplacewithERC1155-TypeScript.yml
FractionalNFTinRealEstate-TypeScript.yml
En plus des propriétés et sections standard, les ressources de jeton prennent en charge les sections behavior
et anatomy
dans le fichier de spécification. En outre, les ressources de jeton non fongibles prennent en charge la section metadata
. L'exemple suivant montre la structure d'un fichier de spécification pour deux actifs de jeton ERC-1155, un jeton non fongible entier et un jeton fongible fractionnaire :
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
L'exemple suivant montre la structure d'un fichier de spécification pour un jeton fractionnaire non fongible :
- 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
Tableau 7-7 Descriptions et exemples de paramètres pour un fichier de spécification de jeton ERC-1155
Entrée | Description | Exemples |
---|---|---|
type: |
Vous devez spécifier |
|
standard: |
La propriété standard est obligatoire pour les jetons ERC-1155. Il représente la norme de jeton à suivre lors de la génération du code de chaîne.
|
|
anatomy: |
La section
anatomy comporte deux paramètres obligatoires :
|
|
behavior: |
Cette section décrit les capacités et les restrictions du jeton. Les comportements mintable et transferable sont obligatoires pour tous les jetons. Le comportement indivisible est obligatoire pour les jetons non fongibles entiers.
|
|
metadata: |
La propriété Dans l'exemple, |
|
Limitations
Blockchain App Builder fournit une prise en charge partielle de la norme ERC-1155. Actuellement, les événements et méthodes ERC-1155 suivants ne sont pas pris en charge.
TransferSingle
TransferBatch
ApprovalForAll
URI
safeTransferFrom
balanceOf
setApprovalForAll
isApprovedForAll