createNFT
This function creates an NFT on the Solana blockchain with metadata support.
Usage
page.tsx
import { useConnection, useWallet } from "@solana/wallet-adapter-react";
import { createNFT } from "@okito/sdk";
const {connection} = useConnection();
const wallet = useWallet();
const nftData = {
name: "My NFT", // Name of the NFT
symbol: "MNFT", // Symbol of the NFT
description: "This is my NFT", // Description of the NFT
imageUrl: "https://example.com/image.png", // Image URL of the NFT
externalUrl: "https://example.com", // (optional) External URL for the NFT
attributes: [ // (optional) Array of attributes
{ trait_type: "Background", value: "Blue" },
{ trait_type: "Eyes", value: "Green" }
],
collection: {
name: "My Collection",
family: "My Family"
}
}
const productionResult = await createNFT(connection, wallet, nftData, {
enableLogging: true, // Detailed operation tracking
enableSimulation: true, // Pre-flight transaction testing
maxRetries: 3, // Automatic retry on failure
confirmationStrategy: 'confirmed'
});
Capabilities
- Metadata fields (name, symbol, description, image URL)
- Optional external URL, attributes, and collection info
- Optional pre-flight simulation
- Clear error messages and safer defaults
Parameters
| Name | Type | Default |
|---|---|---|
connection | ConnectionSolana connection instance. | |
wallet | SignerWalletWallet with signing capabilities. | |
data | NFTDataNFT metadata fields. | |
config | NFTConfigSee <a href="/OperationConfig">OperationConfig</a>. | |
NFTConfig
| Name | Type | Default |
|---|---|---|
enableFreezeAuthority | booleanWhether to enable freeze authority. | |
royaltyBasisPoints | numberRoyalty basis points. | |
OperationConfig | OperationConfigSee <a href="/OperationConfig">OperationConfig</a>. | |
Response
Returns OperationResult.
| Name | Type | Default |
|---|---|---|
OperationResult | OperationResultThe result of the NFT creation. | |
mintAddress | string | |
Last updated on