This guide demonstrates how to create NFTs on the SOON using the Metaplex Foundation’s UMI framework, MPL Token Metadata program, and Pinata for IPFS storage.
Prerequisites
Before you begin, make sure you have:
- Node.js installed
- A funded wallet on SOON testnet
- Pinata account for IPFS storage
Setting up Pinata
- Visit Pinata Cloud and create an account
- Once registered, go to
API Keys
section
- Create a new API key with the permissions you need
- Save your JWT token and Gateway token
- Create a
.env
file in your project root:
PINATA_JWT=your_jwt_token_here
PINATA_GATEWAY_TOKEN=your_gateway_token_here
Implementation
Let’s break down the code that creates NFTs on SOON:
import {
percentAmount,
generateSigner,
createSignerFromKeypair,
signerIdentity,
} from "@metaplex-foundation/umi";
import {
createNft,
mplTokenMetadata,
} from "@metaplex-foundation/mpl-token-metadata";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { Keypair, LAMPORTS_PER_SOL } from "@solana/web3.js";
import { base58 } from "@metaplex-foundation/umi/serializers";
import { PinataSDK } from "pinata-web3";
import dotenv from "dotenv";
dotenv.config();
// Initialize UMI with SOON testnet
const umi = createUmi("https://rpc.testnet.soo.network/rpc").use(
mplTokenMetadata()
);
Setting up the Wallet
// Create keypair and signer
const payerSecretKey = new Uint8Array([]); // Your wallet's secret key
let keypair = umi.eddsa.createKeypairFromSecretKey(payerSecretKey);
const balance = await umi.rpc.getBalance(keypair.publicKey);
console.log(
"Payer Balance:",
(Number(balance.basisPoints) / LAMPORTS_PER_SOL).toFixed(2),
"SOL"
);
const myKeypairSigner = createSignerFromKeypair(umi, keypair);
umi.use(signerIdentity(myKeypairSigner));
const metadata = {
name: "My NFT",
description: "This is an NFT on SOON",
image: "your_image_url",
external_url: "https://x.com/soon-svm",
attributes: [
{
trait_type: "trait1",
value: "value1",
},
{
trait_type: "trait2",
value: "value2",
},
],
properties: {
files: [
{
uri: "your_image_url",
type: "image/png",
},
],
category: "image",
},
};
Uploading to IPFS using Pinata
const pinata = new PinataSDK({
pinataJwt: process.env.PINATA_JWT!,
pinataGateway: "your_pinata_gateway",
});
const upload = await pinata.upload.json(metadata);
const metadatauri = `https://your_gateway.mypinata.cloud/ipfs/${upload.IpfsHash}?pinataGatewayToken=${process.env.PINATA_GATEWAY_TOKEN}`;
Creating the NFT
const tx = await createNft(umi, {
mint: NFTsigner,
sellerFeeBasisPoints: percentAmount(5.5),
name: "My NFT",
uri: metadatauri,
}).sendAndConfirm(umi);
Running the Code
- Install dependencies:
pnpm add @metaplex-foundation/umi @metaplex-foundation/mpl-token-metadata @solana/web3.js pinata-web3 dotenv
-
Set up your environment variables in .env
file
-
Replace the placeholder values:
- Your wallet’s secret key
- Your NFT metadata
- Your Pinata gateway
-
Run the script:
Output
After successful execution, you’ll see:
- Your wallet balance
- IPFS upload confirmation
- Metadata URI
- Transaction signature
- NFT mint address
Security Considerations
- Never commit your
.env
file or expose your secret keys
- Store sensitive information securely
- Ensure your wallet has sufficient SOON tokens for transactions
Network Selection
The code is configured for SOON testnet. For different networks, update the RPC URL:
- Devnet:
https://rpc.devnet.soo.network/rpc
- Testnet:
https://rpc.testnet.soo.network/rpc
Additional Resources