非实物标记框架链代码包
不可替代的令牌框架使用区块链应用程序构建器支持的扩展 ERC-721 标准。
NFT Art Collection Marketplace 示例展示了非实物代币通用框架的使用,该框架基于区块链应用程序构建器支持的扩展 ERC-721 标准。该样本包括一个链码,代表购买和销售与艺术品相关的非同质代币 (NFT) 的市场。在这个样本中,博物馆可以为区块链网络中的艺术品制造(创建)NFT。然后,消费者可以从博物馆购买并转售 NFT。链代码实现管理不可替代的令牌生命周期所需的方法,包括令牌初始化、帐户操作、角色分配、铸造、传输和刻录。它还提供了用于批准铸造、转移和燃烧操作的公证账户,并通过日常限制和审计程序支持合规性。NFT Art Collection Marketplace 示例专为 TypeScript 中的链代码开发而设计。
NFTCollectiblesWithERC721.zip
,包含要部署的打包链代码的归档文件。NFTCollectiblesWithERC721-TypeScript.yaml
,可与区块链应用程序构建器一起使用的规范文件,用于支持NFTCollectiblesWithERC721
链代码。NFTCollectiblesWithERC721_postman_collection.json
,一个 Postman 集合,允许您测试链代码中的 API。README.md
,用于处理链代码的分步指南。
要获取可替换令牌框架,请在 Oracle Blockchain Platform Digital Assets 控制台中单击 Digital Assets 选项卡,然后选择 Non-Fungible Token Framework 。
规范文件
The specification file that is used to generate the art collection marketplace chaincode includes the events
attribute. The chaincode events function supports event callbacks in generated chaincodes to enable real-time notifications and trigger workflows. For more information about specification files and the parameters used in specification files, see Input Specification File for Non-Fungible Tokens in Using Oracle Blockchain Platform.
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
#
# This specification file is an example how to build any whole non-fungible token application.
# For a whole non-fungible token application, art collection marketplace has been used as an example.
# Art collection marketplace is a digital marketplace that uses NFTs to enable the buying, selling, and showcasing of unique art pieces, providing secure ownership, provenance tracking, and exclusive rights for artists and collectors.
assets:
- name: ArtCollection #Asset name
type: token #Asset type
symbol: ART # Token symbol
standard: erc721+ # Token standard
events: true # Supports event code generation for non-GET methods
anatomy:
type: nonfungible # Token type
unit: whole #Token unit
behavior:
- indivisible
- singleton
- mintable:
max_mint_quantity: 20000
- transferable
- 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: float
- name: On_Sale_Flag # Custom asset attribute to maintain non-fungible token selling status in the marketplace
type: boolean
metadata: # To maintain the metadata on-chain, this tag will be used. Users won't be able to update the metadata attribute values after an NFT is minted.
- name: Painting_Name # Custom asset attribute to represent the title given to a piece of artwork.
type: string
- name: Description # Custom asset attribute to represent a detailed explanation or interpretation of the painting's concept, style, or message.
type: string
- name: Painter_Name # Custom asset attribute to represent the name of the artist who created the painting.
type: string
customMethods:
- executeQuery
- "post(token_id: string, selling_price: number)" # Post the non-fungible token for selling in the marketplace.
- "buy(from_org_id: string, from_user_id: string, to_org_id: string, to_user_id: string, nonfungible_token_id: string, amount_paid: number)" # Buy the non-fungible token after paying the amount using any payment gateways.
Chaincode 方法中的背书者详细信息
Oracle Blockchain Platform Digital Assets Edition 会为所有 setter 方法的请求有效负载添加一个背书参数。该参数的值为 endorsers
或 sameOrgEndorser
。如果 sameOrgEndorser
参数为 true,则事务处理背书必须来自与请求者相同的组织。endorsers
参数指定必须对事务处理背书的对等节点列表。有关更多信息,请参见 Endorsement Support in Postman Collections 。下表显示了每种方法的背书者类型。
方法 | 背书者类型 |
---|---|
activateAccount |
endorsers |
addTokenAdmin |
sameOrgEndorser |
addRole |
endorsers |
addTokenSysRole |
endorsers |
balanceOf |
endorsers |
buy |
endorsers |
createAccount |
endorsers |
createArtCollectionToken |
sameOrgEndorser |
deleteAccount |
endorsers |
getAccountByUser |
endorsers |
getAccountHistory |
endorsers |
getAccountsByRole |
endorsers |
getAccountsByTokenSysRole |
endorsers |
getAccountStatus |
endorsers |
getAccountStatusHistory |
endorsers |
getAccountTransactionHistory |
endorsers |
getAccountTransactionHistoryWithFilters |
endorsers |
getAllAccounts |
endorsers |
getAllLockedNFTs |
endorsers |
getAllTokenAdmins |
endorsers |
getAllTokens |
endorsers |
getAllTokensByUser |
endorsers |
getLockedNFTsByOrg |
endorsers |
getTokenById |
endorsers |
getTokenHistory |
endorsers |
getTransactionById |
endorsers |
getUserByAccountId |
endorsers |
getUsersByRole |
endorsers |
getUsersByTokenSysRole |
endorsers |
init |
endorsers |
isInRole |
endorsers |
isInTokenSysRole |
endorsers |
isNFTLocked |
endorsers |
isTokenAdmin |
endorsers |
lockNFT |
sameOrgEndorser |
name |
endorsers |
ownerOf |
endorsers |
post |
endorsers |
removeRole |
endorsers |
removeTokenAdmin |
sameOrgEndorser |
removeTokenSysRole |
endorsers |
safeTransferFrom |
endorsers |
suspendAccount |
endorsers |
symbol |
endorsers |
tokenURI |
endorsers |
totalNetSupply |
endorsers |
totalSupply |
endorsers |
transferFrom |
endorsers |
transferTokenSysRole |
endorsers |
updateArtCollectionToken |
sameOrgEndorser |