> ## Documentation Index
> Fetch the complete documentation index at: https://docs.soo.network/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Create NFTs on SOON

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

1. Visit [Pinata Cloud](https://pinata.cloud) and create an account
2. Once registered, go to `API Keys` section
3. Create a new API key with the permissions you need
4. Save your JWT token and Gateway token
5. Create a `.env` file in your project root:

```env theme={"system"}
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:

```typescript theme={"system"}
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

```typescript theme={"system"}
// 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));
```

### Creating NFT Metadata

```typescript theme={"system"}
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

```typescript theme={"system"}
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

```typescript theme={"system"}
const tx = await createNft(umi, {
  mint: NFTsigner,
  sellerFeeBasisPoints: percentAmount(5.5),
  name: "My NFT",
  uri: metadatauri,
}).sendAndConfirm(umi);
```

## Running the Code

1. Install dependencies:

```bash theme={"system"}
pnpm add @metaplex-foundation/umi @metaplex-foundation/mpl-token-metadata @solana/web3.js pinata-web3 dotenv
```

2. Set up your environment variables in `.env` file

3. Replace the placeholder values:
   * Your wallet's secret key
   * Your NFT metadata
   * Your Pinata gateway

4. Run the script:

```bash theme={"system"}
pnpm start
```

## 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

* [Metaplex Documentation](https://developers.metaplex.com/)
* [Pinata Documentation](https://docs.pinata.cloud/)
* You can find the complete code for this guide on [GitHub](https://github.com/rkmonarch/soon-spl).
