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

·

Blockchain development continues to evolve at a rapid pace, and one of the most exciting platforms emerging in 2025 is Sui. With its high-speed transactions, object-centric model, and developer-friendly tools like the Sui JS SDK, building on Sui offers a smooth and efficient experience. Whether you're new to blockchain or an experienced developer, minting your first NFT on Sui can be both fun and educational.

In this guide, we’ll walk through how to mint an NFT on Sui using the Sui JavaScript SDK, store your asset securely with IPFS via Pinata, and deploy everything using just a few lines of code. No prior Sui experience? No problem — we’ll keep it beginner-friendly while covering key concepts like gas management, object merging, and smart contract interaction.


Step 1: Upload Your NFT Asset Using Pinata

Before you can mint an NFT, you need to host the digital file — whether it's an image, video, or audio — in a decentralized way. This ensures permanence and censorship resistance.

Pinata is one of the most reliable services for pinning files to IPFS (InterPlanetary File System). Here’s how to get started:

  1. Go to Pinata.cloud and sign up for a free account.
  2. Navigate to the "Files" section and click Upload.
  3. Select your NFT file (e.g., my-artwork.png) and upload it.
  4. Once uploaded, copy the CID (Content Identifier) — it will look like QmZhnkimthxvL32vin2mrQvnhN8ZbWFMvKMxRqHEq7dPz3.

Your file is now stored on IPFS and accessible via a URL like:
ipfs://QmZhnkimthxvL32vin2mrQvnhN8ZbWFMvKMxRqHEq7dPz3

👉 Learn how to securely manage digital assets with next-gen blockchain tools.


Step 2: Set Up Your Development Environment

To interact with the Sui network programmatically, we’ll use the Sui JS SDK, which allows developers to create wallets, send transactions, and call smart contracts directly from JavaScript.

Create a New Project

Open your terminal and run:

mkdir sui-nft && cd sui-nft
npm init -y
npm install @mysten/sui.js

Next, update your package.json to support ES modules by adding "type": "module":

{
  "name": "sui-nft",
  "version": "1.0.0",
  "type": "module",
  "dependencies": {
    "@mysten/sui.js": "^0.26.1"
  }
}

Finally, create a script file:

touch mint-nft.js

Step 3: Write the Code to Mint Your NFT

Now open mint-nft.js in your preferred editor (like VSCode) and begin writing the logic.

Import Required Modules

Start by importing essential classes from the Sui SDK:

import { Ed25519Keypair, JsonRpcProvider, Network, RawSigner } from '@mysten/sui.js';

Generate a Wallet

We’ll generate a new keypair for testing purposes:

const keypair = new Ed25519Keypair();
const address = "0x" + keypair.getPublicKey().toSuiAddress();
console.log("Wallet Address:", address);
🔐 In production, never hardcode private keys. Use secure wallet integrations instead.

Connect to Sui Devnet

Use the JSON-RPC provider to connect to Sui’s testnet (Devnet):

const provider = new JsonRpcProvider(Network.DEVNET);

Then request test SUI tokens from the faucet:

const fund = await provider.requestSuiFromFaucet(address);
console.log("Faucet Response:", fund);

You’ll receive multiple small coin objects — this is normal due to Sui’s object model.

Wait Before Proceeding

Because object creation is asynchronous, add a short delay function:

const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
await wait(3000); // Wait 3 seconds

Merge Coin Objects

Sui treats each coin as a separate object. For smoother transactions, merge two 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,
});
console.log("Merge Transaction:", mergeTxn);

👉 Discover powerful blockchain development tools that streamline NFT creation.


Step 4: Mint the NFT

Now comes the exciting part — calling the NFT minting function!

Sui Devnet includes a pre-deployed NFT module (devnet_nft) for testing:

const mintTxn = await signer.executeMoveCall({
  packageObjectId: '0x2',
  module: 'devnet_nft',
  function: 'mint',
  typeArguments: [],
  arguments: [
    'gm', // Name
    'A nice gm brought to you by Pinata and Sui', // Description
    'ipfs://QmZhnkimthxvL32vin2mrQvnhN8ZbWFMvKMxRqHEq7dPz3', // Image link
  ],
  gasBudget: 10000,
});

console.log('Mint Transaction:', mintTxn);

After execution, extract the NFT’s object ID to view it on-chain:

const nftId = mintTxn.effects.created[0].reference.objectId;
console.log(`🎉 View NFT: https://explorer.sui.io/object/${nftId}?network=devnet`);

Run the script:

node mint-nft.js

If successful, you'll see a link to your newly minted NFT in the Sui Explorer!


Frequently Asked Questions (FAQ)

Can I mint NFTs on Sui mainnet?

Yes! While this tutorial uses Devnet for testing, the same process applies on the mainnet. Just switch Network.DEVNET to Network.MAINNET and ensure you have real SUI tokens for gas.

Why do I need to merge coin objects?

Sui represents each token as a unique object. When performing transactions, you may need sufficient gas from a single coin object. Merging prevents errors caused by fragmented balances.

Is Pinata the only way to store NFT metadata?

No — while Pinata is popular for IPFS hosting, alternatives like NFT.Storage, Filecoin, or Arweave also offer decentralized storage. Choose based on durability, cost, and access speed.

What is the 'devnet_nft' module?

It’s a built-in smart contract on Sui Devnet designed for testing NFT minting. On mainnet or custom projects, you’d deploy your own Move-based NFT contract.

How much does it cost to mint an NFT on Sui?

Gas fees are extremely low — typically less than $0.01 per transaction. Costs depend on computation complexity and network congestion.

Can I customize my NFT beyond name, description, and image?

Absolutely. With custom Move smart contracts, you can add traits, dynamic metadata, royalties, unlockable content, and more.


Final Thoughts

Minting your first NFT on Sui using the Sui JS SDK opens the door to a world of high-performance decentralized applications. From seamless IPFS integration with Pinata to efficient gas handling via object merging, Sui simplifies many pain points found in older blockchains.

Whether you're building digital art collections, gaming assets, or token-gated experiences, mastering NFT creation is a foundational skill for modern Web3 development.

👉 Start building scalable NFT projects on cutting-edge blockchain networks today.


Core Keywords: mint NFT on Sui, Sui JS SDK, Pinata IPFS, Sui Devnet, NFT tutorial, JavaScript blockchain, object merging Sui, decentralized storage