Burn a token. Caller must be the owner.
fn burn(env: soroban_sdk::Env, owner: soroban_sdk::Address, token_id: u32)
Mint a single NFT to to. Returns the new token ID.
fn mint(
env: soroban_sdk::Env,
minter: soroban_sdk::Address,
to: soroban_sdk::Address,
) -> u32
Returns the collection name.
fn name(env: soroban_sdk::Env) -> soroban_sdk::String
Get the current admin address.
fn admin(env: soroban_sdk::Env) -> soroban_sdk::Address
Pause the contract (admin only). Blocks minting and transfers.
fn pause(env: soroban_sdk::Env)
Returns true if token_id exists (has been minted and not burned).
fn exists(env: soroban_sdk::Env, token_id: u32) -> bool
Returns the collection symbol.
fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String
Approve approved to transfer token_id.
fn approve(
env: soroban_sdk::Env,
approver: soroban_sdk::Address,
approved: soroban_sdk::Address,
token_id: u32,
live_until_ledger: u32,
)
Returns the number of tokens held by owner.
fn balance(env: soroban_sdk::Env, owner: soroban_sdk::Address) -> u32
Unpause the contract (admin only).
fn unpause(env: soroban_sdk::Env)
Upgrade the contract WASM. Admin only. ⚠️ NEVER REMOVE THIS FUNCTION — doing so bricks the contract permanently.
fn upgrade(env: soroban_sdk::Env, new_wasm_hash: soroban_sdk::BytesN<32>)
Contract version, incremented on each upgrade.
fn version(env: soroban_sdk::Env) -> u32
Returns the owner of token_id. Panics if token does not exist.
fn owner_of(env: soroban_sdk::Env, token_id: u32) -> soroban_sdk::Address
Transfer a token from from to to. Caller must be the owner.
fn transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
token_id: u32,
)
Burn using an approval. Spender must be approved.
fn burn_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
owner: soroban_sdk::Address,
token_id: u32,
)
Check if a token is frozen.
fn is_frozen(env: soroban_sdk::Env, token_id: u32) -> bool
Check if an address has the minter role.
fn is_minter(env: soroban_sdk::Env, account: soroban_sdk::Address) -> bool
Returns the token URI for token_id.
Checks per-token override first, then falls back to base_uri + token_id.
fn token_uri(env: soroban_sdk::Env, token_id: u32) -> soroban_sdk::String
Returns all token IDs owned by owner (requires enumerable=true).
fn tokens_of(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
) -> soroban_sdk::Vec
Returns all token IDs in the collection (requires enumerable=true).
fn all_tokens(env: soroban_sdk::Env) -> soroban_sdk::Vec
Batch mint count sequential NFTs to to. Returns the token IDs.
fn batch_mint(
env: soroban_sdk::Env,
minter: soroban_sdk::Address,
to: soroban_sdk::Address,
count: u32,
) -> soroban_sdk::Vec
Returns the max supply cap (0 = unlimited).
fn max_supply(env: soroban_sdk::Env) -> u32
Freeze/unfreeze a specific token (admin only).
fn set_frozen(env: soroban_sdk::Env, token_id: u32, frozen: bool)
Permissionless mint — anyone can call when public mint is active. No minter/admin role required. Returns the new token ID.
fn public_mint(env: soroban_sdk::Env, to: soroban_sdk::Address) -> u32
Returns the approved address for token_id, or None.
fn get_approved(env: soroban_sdk::Env, token_id: u32) -> Option
Grant minter role to an address (admin only).
fn grant_minter(env: soroban_sdk::Env, account: soroban_sdk::Address)
Check if a token is soulbound (non-transferable).
fn is_soulbound(env: soroban_sdk::Env, token_id: u32) -> bool
Mint with a custom token ID (for non-sequential use cases).
fn mint_with_id(
env: soroban_sdk::Env,
minter: soroban_sdk::Address,
to: soroban_sdk::Address,
token_id: u32,
) -> u32
Query royalty info for a token at a given sale price. Returns (receiver, royalty_amount). Checks per-token override first, then collection default.
fn royalty_info(
env: soroban_sdk::Env,
token_id: u32,
sale_price: i128,
) -> (soroban_sdk::Address, i128)
Update the collection base URI (admin only).
fn set_base_uri(env: soroban_sdk::Env, base_uri: soroban_sdk::String)
Alias for total_supply — returns the next token ID (total minted including burned). Kept for compatibility with frontend code expecting this name.
fn total_minted(env: soroban_sdk::Env) -> u32
Returns total number of minted (non-burned) tokens.
fn total_supply(env: soroban_sdk::Env) -> u32
Deploy and initialize a Piko NFT collection.
base_uri - Base URI for metadata (e.g. "https://meta.kpop.rocks/gen1/")name - Collection name (e.g. "KPOP Genesis")symbol - Collection symbol (e.g. "KPOPGEN")admin - Admin address (can mint, pause, manage roles)max_supply - Maximum supply cap (0 = unlimited)enumerable - Enable enumerable extension (all_tokens, tokens_of)attributes - Enable on-chain attributes (per-token key-value store)royalty_receiver - Default royalty receiver addressroyalty_bps - Default royalty in basis points (e.g. 500 = 5%)fn __constructor(
env: soroban_sdk::Env,
base_uri: soroban_sdk::String,
name: soroban_sdk::String,
symbol: soroban_sdk::String,
admin: soroban_sdk::Address,
max_supply: u32,
enumerable: bool,
attributes: bool,
royalty_receiver: soroban_sdk::Address,
royalty_bps: u32,
)
Revoke minter role from an address (admin only).
fn revoke_minter(env: soroban_sdk::Env, account: soroban_sdk::Address)
Set/unset soulbound status on a token (admin only).
fn set_soulbound(env: soroban_sdk::Env, token_id: u32, soulbound: bool)
Set a custom URI for a specific token (overrides base_uri + id).
fn set_token_uri(env: soroban_sdk::Env, token_id: u32, uri: soroban_sdk::String)
Transfer a token using an approval. spender must be approved.
fn transfer_from(
env: soroban_sdk::Env,
spender: soroban_sdk::Address,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
token_id: u32,
)
Transfer multiple tokens from from to to in a single transaction.
fn batch_transfer(
env: soroban_sdk::Env,
from: soroban_sdk::Address,
to: soroban_sdk::Address,
token_ids: soroban_sdk::Vec,
)
Get all attributes for a token as a key-value map.
fn get_attributes(
env: soroban_sdk::Env,
token_id: u32,
) -> soroban_sdk::Map
Mint a soulbound (non-transferable) token.
fn mint_soulbound(
env: soroban_sdk::Env,
minter: soroban_sdk::Address,
to: soroban_sdk::Address,
) -> u32
Set attributes on a token (admin/minter only). Merges with existing attributes.
fn set_attributes(
env: soroban_sdk::Env,
caller: soroban_sdk::Address,
token_id: u32,
attrs: soroban_sdk::Map,
)
Transfer admin to a new address (admin only).
fn transfer_admin(env: soroban_sdk::Env, new_admin: soroban_sdk::Address)
Approve/revoke operator for all of owner's tokens.
fn approve_for_all(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
operator: soroban_sdk::Address,
live_until_ledger: u32,
)
Enable or disable public (permissionless) minting. Admin only.
fn set_public_mint(env: soroban_sdk::Env, active: bool)
Mint with a per-token royalty override.
fn mint_with_royalty(
env: soroban_sdk::Env,
minter: soroban_sdk::Address,
to: soroban_sdk::Address,
royalty_receiver: soroban_sdk::Address,
royalty_bps: u32,
) -> u32
Set a per-token royalty override (admin only).
fn set_token_royalty(
env: soroban_sdk::Env,
token_id: u32,
receiver: soroban_sdk::Address,
bps: u32,
)
Returns whether operator is approved to manage all of owner's tokens.
fn is_approved_for_all(
env: soroban_sdk::Env,
owner: soroban_sdk::Address,
operator: soroban_sdk::Address,
) -> bool
Update the collection-wide default royalty (admin only).
fn set_default_royalty(env: soroban_sdk::Env, receiver: soroban_sdk::Address, bps: u32)
Remove a per-token royalty override (falls back to collection default).
fn remove_token_royalty(env: soroban_sdk::Env, token_id: u32)
Check if public minting is currently active.
fn is_public_mint_active(env: soroban_sdk::Env) -> bool