Skip to main content

Create Private NFT

In this tutorial you will learn how to integrate your dApp with Arcana Storage SDK and allow dApp users to create a private NFT.

tip

Alternatively, to mint private NFTs, dApp users can also use Arcana NFT Minter dApp:

https://nft-minter.beta.arcana.network/

After minting private NFTs using Arcana NFT Minter, private NFT owners can view them using the Arcana NFT Viewer dApp:

https://nft-viewer.beta.arcana.network/

Prerequisites

note

Arcana private NFT minting process supports MetaMask Wallet in the beta release. Other wallets including Arcana wallet will be supported in a future release.

Steps

Before getting into the details, here is some context about the Arcana private NFT minting process.

  • To create a private NFT, a dApp must first upload the NFT data or file to the Arcana Store. This is required to make sure that the NFT data is encrypted and access controlled. After a successful upload, each NFT asset data file is associated with a unique identifier called the DID.

  • Next, the dApp needs to mint the NFT using the standard NFT minting process with some additional metadata. This involves two parts:

    • First, use the NFT asset DID, along with other details such as the title and a preview image, to invoke makeMetadataURL function of the Arcana Storage SDK. This will return a metadata URL.
    • Next, use the metadata URL and wallet address obtained from the provider to mint NFT. You can use any supported blockchain network for minting. After minting, you will receive a tokenID for the freshly minted NFT.
note

Only the preview image is minted and made accessible publicly as an NFT via the standard minting process. Your private NFT is secure in Arcana Store. The additional data used to mint NFT is utilized for ascertaining ownership and maintaining a one-to-one correspondence between the minted NFT and the actual private NFT data file secured in Arcana Store.

  • Finally, you need to link the tokenID obtained after minting with the DID of the private NFT residing in the Arcana Store. After linking, the NFT creation process is complete.

Anyone can view the minted NFT preview image but only the owner or those who have been explicitly allowed access by the file owner can download the actual private NFT from Arcana Store.

With that high-level context, refer to the steps listed below and enable your dApp to create private NFT via Arcana Network:

Step 1: Integrate Arcana Storage SDK

Make sure that you have addressed the prerequisite steps including MetaMask integration in your dApp. Also, you may need to deploy your own collection and mint NFTs. After addressing these prerequisites, integrate your dApp with Arcana Storage SDK.

Step 2: Choose Arcana Network

Do inform and prompt your dApp user to select "Arcana Network" in their MetaMask wallet settings. This is required to successfully execute the next step.

caution

For uploading the private NFT asset file to Arcana Store, the network selected in MetaMask wallet is set to "Arcana Network". Make sure the following details are specified correctly in the wallet network settings:

Field DescriptionValue
Network NameArcana Network
New RPC URL

https://blockchain001-testnet.arcana.network

ChainID

40405

Currency SymbolXAR
Block Explorer URL Optional

https://explorer.beta.arcana.network

note

The dApp developer can choose to take the user's consent and automate the network switching process programmatically in the MetaMask wallet settings.

See the MetaMask wallet configuration settings documentation to set up Arcana Network in the MetaMask wallet. In your dApp, specify the designated values for chain ID, RPC URL, Network name field. Once user confirms the switching action in the dApp UI, switch to Arcana Network settings via dApp.

Step 3: Upload the NFT asset to Arcana Store

After integrating your dApp with Arcana Storage SDK, call the file uploader function and upload the NFT asset data file to the Arcana Store. Save the DID assigned to this NFT asset.


// After integrating with Storage SDK initialize a Storage provider
storage = new StorageProvider({
appId: APP_ID,
gateway: GATEWAY_URL,
chainId: Number(BLOCKCHAIN_ID),
provider: window.ethereum,
})
// Use this Storage provider to upload your file

const uploader = await storage.getUploader()
//save DID
const did = await uploader.upload(file)

Step 4: Obtain makeMetaDataURL from Storage SDK

Specify the title, description, uploaded NFT asset's DID and a preview image and call makeMetaDataURL function in the Storage SDK to obtain a metadata URL.

  • Title: Private NFT Asset title
  • Description: Brief information about the NFT Asset
  • DID: The unique file identifier returned after uploading the file to the Arcana Store
  • Preview Image: An image of lower resolution used to identify or visually tag an NFT asset or its key characteristics without sharing the actual NFT asset details.
  //save metadataURL
const metadataURL = await storage.makeMetadataURL(title, description, did, preview)

Step 5: Change the Network in MetaMask

This is important. Previously, the MetaMask wallet was configured to use Arcana Network for uploading the file to Arcana Store. Before you mint this NFT using the standard Ethereum minting process, make sure you inform and prompt the dApp user to change the network setting in MetaMask to the blockchain where you would like to mint this NFT. It will require non-zero eth in your wallet.

caution

Before minting, you must change the network to one of the supported blockchain networks:

  • Ropsten (Ethereum Testnet)
  • Mumbai (Polygon Testnet)

After minting, before linking the minted NFT token with DID, you need to change the MetaMask network setting back to "Arcana Network".

caution

When you change the network setting in MetaMask, the dApp browser page may reload. This will remove all stored values in the current context. To make sure all the context is saved across page reload, make sure you save the DID, metadata URL and other details obtained in previous steps in the local storage of your dApp. This is MetaMask wallet-specific behavior.

note

As mentioned earlier, the dApp developer can choose to programmatically switch MetaMask wallet to the one of the supported minting network. This network change must be done only after user confirms the action.

Step 6: Mint the NFT

To mint the NFT using the preview image and other requisite metadata, you need a blockchain signer. Use the code listed below to derive the standard Ethereum provider from MetaMask. Then get a blockchain signer using ethers.js library as shown in the code below:


//abi
const abi = [
{
inputs: [
{
internalType: 'address',
name: 'to',
type: 'address',
},
{
internalType: 'string',
name: 'tokenURI',
type: 'string',
},
],
name: 'mint',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'nonpayable',
type: 'function',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'address',
name: 'from',
type: 'address',
},
{
indexed: true,
internalType: 'address',
name: 'to',
type: 'address',
},
{
indexed: true,
internalType: 'uint256',
name: 'tokenId',
type: 'uint256',
},
],
name: 'Transfer',
type: 'event',
},
]

// mint NFT using ethers.js
const provider = window.ethereum
const web3Provider = new ethers.providers.Web3Provider(provider)
const signer = web3Provider.getSigner()
const NFT721Contract = new ethers.Contract(NFT_CONTRACT_ADDRESS, abi, signer)

In addition to the blockchain signer, you need the smart contract address and abi to mint the NFT. Refer to the sample Arcana Smart Contract for details on what an AERC721 contract must contain to create a private NFT.

tip

As an alternative to using Arcana Smart Contract, you can also choose to create your own collection and deploy your own contract for minting the NFT. This process is more involved and you will be required to ensure that your contract notifies the Arcana Bridge adequately for any ownership changes on this NFT to register properly in the Arcana Store. Refer to the detailed instructions here.

Call the mint function of the NFT721Contract and specify the wallet address and metadata URL obtained in an earlier step, during minting.

  let tx = await NFT721Contract.mint(walletAddress, metadataURL)
tx = await tx.wait()

On success, the mint function returns an array of events. Grab the Transfer event and obtain the corresponding tokenID using the code below:

  const event = tx.events.find((item) => item.event === 'Transfer')
// save tokenId
const tokenID = event.args.tokenId.toString()

Step 7: Change the Network in MetaMask, again!

This is important. Before you link the tokenID received after minting with Arcana Store DID, you need to change the network setting in MetaMask back to "Arcana Network".

note

This network change in MetaMask wallet can either be performed by the user manually or the dApp can do this switching programmatically, once the user approves the switching action.

Use the following inputs and call the linkNFT function of the Arcana Storage SDK:

  • The tokenID obtained in the previous step
  • The DID of the NFT asset uploaded earlier
  • The chainID corresponding to the selected blockchain where you minted the NFT
  • The NFT smart contract address (Arcana Smart Contract or the one you deployed as your NFT collection)
  // Link NFT tokenID to Arcana Store DID
await storage.linkNft(did, tokenId, nftContractAddress, chainId)

Step 9: Verify private NFT creation

Verify that your private NFT is created by using Arcana NFT Viewer. If you specify the DID and use the same MetaMask account that was used to mint this NFT, you will be able to download this private NFT. Otherwise, if you specify the DID but use a different MetaMask account that did not create this NFT and does not own it, you can simply see a preview of the NFT asset but cannot download it.

That is all! 🎉

You have successfully created a private NFT using Arcana Storage SDK!

What's Next?

See also