Mint a new NFT to the specified address
to - The address that will receive the newly minted NFTReturns the token ID of the newly minted NFT (sequential, starting from 1)
Any user can mint NFTs. The function automatically transfers 1 XLM (10,000,000 stroops)
from the recipient (to) to the contract as payment. The recipient must have sufficient XLM balance
and must authorize the transaction (sign it).
If minting fails after payment, the payment will be refunded to the recipient. In Soroban, if sequential_mint panics, the entire transaction reverts, so the payment transfer will also be reverted automatically. No explicit refund needed.
fn mint(env: soroban_sdk::Env, to: soroban_sdk::Address) -> u32
Withdraw XLM from the contract to the owner
amount - The amount of XLM (in stroops) to withdraw. If None, withdraws all available balance.Only the contract owner can call this function. The function transfers XLM from the contract address to the owner's address. This allows the owner to withdraw minting fees collected by the contract.
fn withdraw(env: soroban_sdk::Env, amount: Option) -> i128
Constructor to initialize the NFT contract
owner - The address that will own the contract (for administrative purposes)native_asset_address - The XLM native asset contract address for your networkmax_supply - Maximum number of NFTs that can be minted (0 = unlimited)Sets the contract metadata (name, symbol, URI) and assigns the owner. The owner can be used for future administrative functions, but any user can mint NFTs.
To get the XLM contract address for your network:
soroban contract id asset --asset native --network <network>
fn __constructor(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
native_asset_address: soroban_sdk::Address,
max_supply: u32,
)