NFT Deep Dive

This section explains how to initiate an NFT transaction. A good understanding of NFT and RAC is expected before diving deep into this section.

1. Enabling NFT

For an existing or new user to be able to create and transfer NFTs they should first see if the Rubix node is enabled/compatible for NFT transactions. To enable NFT wallet for a new or existing user of Rubix, execute the below curl command:

$ curl localhost:1898/enableNFT

2. Creating Private Key - Public Key pair

Once the NFT wallet has been enabled, next step is to create a Private Key-Public Key pair ( different from Private - Public Share). For the ECDSA key pair creations, execute the below command:

$ curl --header "Content-Type: application/json" --request POST 'http://localhost:1898/generateEcDSAKeys' --data '{ "pvtKeyPass" : "<password>" , "returnKey" : 0}'

In the above curl command, the required parameters are as follows:

ParameterDescription
pvtKeyPassValue of password supplied by the user to create their ECDSA Key pair
returnKeyFlag value to determine if keys should be saved in node or returned as string. This flag when set to ‘0’ creates the ECDSA Key pair and the ipfs hash of the generated public key and saves then in the path Rubix/DATA

3. Minting an NFT token

Once the ECDSA keys are generated it is time to execute the command to mint NFTs for the particular asset/assets. Now to mint an NFT token for any asset that user might have, the below curl script has to be executed which takes in certain parameters.

$ curl --location --request POST 'localhost:1898/generateRac' --header 'Content-Type: application/json' --data '{ "type": 2,"totalSupply": <long value>, "contentHash":"", "url": "", "pvtKeyPass": "", "creatorInput": { }}'

In the above curl command, the required parameters are as follows:

ParameterDescription
typeType of token being generated. Since in this case NFT the value of type is 1
totalSupplyIt is the total number of unique NFT tokens being created for the asset.
contentHashIt is a simple hash generated from the asset using MD5.
urlThis is the field where links to the asset can be shared. The field is optional and the usage is dependent on the NFT creator.
pvtKeyPassThis field is to provide the password of the private key that the user provided to generate the same.
creatorInputThis field takes a JSON object as input. The Object can have any number of fields with data ranging from NFT details and attributes to creator details and description.

4. Creating NFT Sales Contract

Once the NFT tokens are generated the next stage is where a sale contract has to be generated by the creator (In case of freshly minted NFT) / current owner here known as seller of the NFT. This sale contract is created to link the NFT token and its value in RBT tokens so that during an NFT transaction the txn can be validated in the Rubix blockchain by its own validators.

To create an NFT sale contract the below command should be executed along with a few parameters:

$ curl --header "Content-Type: application/json" --request POST http://localhost:1898/createNftSaleContract --data '{"sellerDid" : "","nftToken" : "", "amount":, "pvtKeyPass" : ""}'

In the above curl command, the required parameters are as follows:

ParameterDescription
sellerDidIt is the DID of the creator(for freshly minted NFT token) or DID of the current owner of the NFT.
nftTokenIt is the NFT token itself for which the contract is being created.
amountThe field is the value of NFT in RBT.
pvtKeyPassThis field is to provide the password of the private key that the user provided to generate the same.

5. Initiating NFT transaction

Rubix Blockchain Platform offers both Peer-to-Peer transfer of NFTs and transfer of NFT’s in marketplaces. Below given are the API endpoints and their parameter list for each type of NFT transfer.

After creation of a sale contract, an NFT transaction can be initiated. The NFT transaction is being initiated from the NFT Buyer node who also has the corresponding RBT for the NFT. Below given command is the API to initiate an NFT transaction, which needs to be executed from the NFT Buyer Node:

  • API used by Marketplace to transfer/transact NFT :
$ curl --header "Content-Type: application/json" --request POST http://localhost:1898/initiateNftTransfer --data '{ "sellerDid": "", "nftToken": "", "comment":"", "type":2,"saleContractIpfsHash":"", "amount":,"p2pFlag" : 0, "pvtKeyPass":"<Buyer Private Key Password Here>"}'

In the above curl command, the required parameters are as follows:

ParameterDescription
sellerDidIt is the DID of the creator (for freshly minted NFT token) or DID of the current owner of the NFT.
nftTokenIt is the NFT token itself for which the contract is being created.
amountThe field is the value of NFT in RBT.
typeThis value of this field is used to select the quorum type. Value 1 for open network and 2 for subnet (predefined quorum).
commentAny comment to identify the transaction.
saleContractIpfsHashThis is the hash of the sale contract created in the previous step which links the NFT value to RBT.
p2pFlagInteger value (0/1) that denotes if the transfer is P2P / C2W. Flag value 0 denotes transfer is C2W. Flag value 1 denotes transfer is P2P.
pvtKeyPassThis is the password for the private key of the NFT buyer.

In this way, an NFT transaction can be initiated.

If you have questions or feedback, please DM us at @rubixchain.