非易变令牌框架链码包
非实物代币框架使用区块链应用构建器支持的扩展 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 控制台中单击数字资产选项卡,然后选择非可变令牌框架。
规范文件
用于生成艺术收藏市场链代码的规范文件包括 events 属性。链代码事件函数支持在生成的链代码中执行事件回调,以启用实时通知并触发工作流。有关规范文件和规范文件中使用的参数的更多信息,请参见 Blockchain App Builder for Oracle Blockchain Platform 中的 Input Specification File for Non-Fungible Tokens 。
#
# Copyright (c) 2026, 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 参数指定必须对事务处理进行背书的对等节点列表。有关详细信息,请参阅 Blockchain App Builder for Oracle Blockchain Platform 中的 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 |