Non-Fungible Token Framework Chaincode Package

The non-fungible token framework uses the extended ERC-721 standard that is supported by Blockchain App Builder.

The NFT Art Collection Marketplace sample illustrates the use of the non-fungible token generic framework, which is based on the extended ERC-721 standard supported by Blockchain App Builder. The sample includes a chaincode to represent a marketplace for buying and selling non-fungible tokens (NFTs) associated with works of art. In this sample, museums can mint (create) NFTs for artworks in the blockchain network. Consumers can then buy and then resell NFTs from the museums. The chaincode implements the methods that are required for managing the non-fungible token life cycle, including token initialization, account operations, role assignments, minting, transfers, and burning. It also provides notary accounts for approving minting, transfer, and burning operations, and supports compliance through daily limits and auditing procedures. The NFT Art Collection Marketplace sample is designed for chaincode development in TypeScript.

The non-fungible token framework chaincode package is downloadable from the Oracle Blockchain Platform console, and includes the following components.
  • NFTCollectiblesWithERC721.zip, an archive file that contains the packaged chaincode for deployment.
  • NFTCollectiblesWithERC721-TypeScript.yaml, a specification file that you can use with Blockchain App Builder to scaffold the NFTCollectiblesWithERC721 chaincode.
  • NFTCollectiblesWithERC721_postman_collection.json, a Postman collection that enables you to test the APIs in the chaincode.
  • README.md, a step-by-step guide for working with the chaincode.

To get the fungible token framework, in the Oracle Blockchain Platform Digital Assets console click the Digital Assets tab and then select Non-Fungible Token Framework.

Specification File

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.

The art collection marketplace chaincode is based on the extended ERC-721 standard, as shown in the following specification file.
#
# 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.

Endorser Details in Chaincode Methods

Oracle Blockchain Platform Digital Assets Edition adds an endorsement parameter to the request payload for all setter methods. The value of the parameter is either endorsers or sameOrgEndorser. If the sameOrgEndorser parameter is true, transaction endorsements must be from the same organization as the requester. The endorsers parameter specifies a list of peers that must endorse the transaction. For more information, see Endorsement Support in Postman Collections. The following table shows the endorser type for each method.

Method Endorser Type
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