How to Mint an NFT on Sui Using Pinata and the Sui JS SDK

·

Exploring new blockchains is a thrilling way to understand their capabilities, usability, and developer-friendliness. Recently, I discovered Sui, a blockchain renowned for its dynamic metadata and user-friendly onboarding. Despite being in development, Sui impressed me with its speed and seamless performance. However, I noticed a gap in beginner-friendly guides on minting NFTs on Sui. This article bridges that gap by walking you through the process using Pinata for storage and the Sui JS SDK for minting.

Prerequisites

Before diving in, ensure you have:


Step 1: Setting Up Your NFT with Pinata

Sui supports dynamic metadata, but you’ll still need a reliable service to store NFT assets (images, videos, etc.). Pinata is ideal because it leverages IPFS (InterPlanetary File System), ensuring content immutability and tamper-proof storage.

Getting Started with Pinata

  1. Sign Up: Visit Pinata’s signup page to create a free account.
  2. Upload Your Asset:

    • Navigate to the Files page.
    • Click Upload > Select File.
    • Choose your file, name it, and complete the upload.
  3. Copy the CID: After uploading, note the Content Identifier (CID)—you’ll need it later.

👉 Learn more about IPFS and its benefits


Step 2: Code Setup with the Sui JS SDK

Initialize Your Project

  1. Create a project directory:

    mkdir sui-nft && cd sui-nft
  2. Install the Sui JS SDK:

    npm init -y && npm install @mysten/sui.js
  3. Update package.json to include:

    {
      "type": "module",
      "dependencies": {
        "@mysten/sui.js": "^0.26.1"
      }
    }
  4. Create the minting script:

    touch mint-nft.js

Step 3: Minting the NFT

Wallet Creation and Funding

  1. Generate a Keypair:

    import { Ed25519Keypair, JsonRpcProvider, Network, RawSigner } from '@mysten/sui.js';
    const keypair = new Ed25519Keypair();
    const address = "0x" + keypair.getPublicKey().toSuiAddress().toString();
  2. Connect to Sui Devnet:

    const provider = new JsonRpcProvider(Network.DEVNET);
  3. Request Test Sui:

    const fund = await provider.requestSuiFromFaucet(address);

Merging Coin Objects

Sui treats each coin as a unique object. To simplify gas fees, merge coins:

const coin1 = fund.transferred_gas_objects[0].id;
const coin2 = fund.transferred_gas_objects[1].id;
const signer = new RawSigner(keypair, provider);
const mergeTxn = await signer.mergeCoin({
  primaryCoin: coin1,
  coinToMerge: coin2,
  gasBudget: 1000,
});

Execute the Mint

const mintTxn = await signer.executeMoveCall({
  packageObjectId: '0x2',
  module: 'devnet_nft',
  function: 'mint',
  arguments: [
    'NFT Name',
    'NFT Description',
    'ipfs://YOUR_PINATA_CID',
  ],
  gasBudget: 10000
});
console.log(`View NFT: https://explorer.sui.io/object/${mintTxn.effects.effects.created[0].reference.objectId}?network=devnet`);

FAQs

1. Why use Pinata for Sui NFTs?

Pinata ensures your NFT assets are stored on IPFS, making them immutable and decentralized. This aligns with blockchain’s trustless nature.

2. How do I merge Sui coins?

Sui’s model treats each coin as a separate object. Use mergeCoin() to combine them for simpler transactions.

3. Can I mint NFTs without coding?

Currently, minting on Sui requires using the SDK or similar tools. However, platforms may offer no-code solutions in the future.

👉 Explore advanced Sui NFT projects


Next Steps

Join the Pinata Discord for support and inspiration!


### Keywords:
- Mint NFT on Sui
- Sui JS SDK
- Pinata IPFS
- Dynamic metadata
- Sui blockchain
- NFT storage
- Merge Sui coins