Contract e10cd58fbcac623bce5a6fa67eaf5ea4244639aaec234757f5d98317dfa855c7

← Back to Index 📥 Download WASM

Meta

cliver 25.1.0#a048a57a75762458b487052e0021ea704a926bee
rssdkver 23.4.0#673d6c4f2368d282d25da29bda55c21b8be69ca6
rsver 1.89.0

Instances

  • CC3TXXYTH4LOA42ZD5F22DO2EVSYJXEFVS65MYQJPVTLNWCOLSLEZMSW

Interface

Constructor to initialize the NFT contract

Arguments

  • owner - The address that will own the contract (for administrative purposes)
  • native_asset_address - The XLM native asset contract address for your network
  • max_supply - Maximum number of NFTs that can be minted (0 = unlimited)

Note

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,
)

Mint a new NFT to the specified address

Arguments

  • to - The address that will receive the newly minted NFT

Returns

Returns the token ID of the newly minted NFT (sequential, starting from 1)

Note

Any user can mint NFTs. The function automatically transfers 0.01 XLM (100,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

Arguments

  • amount - The amount of XLM (in stroops) to withdraw. If None, withdraws all available balance.

Note

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
fn transfer(
    env: soroban_sdk::Env,
    from: soroban_sdk::Address,
    to: soroban_sdk::Address,
    token_id: u32,
)
fn transfer_from(
    env: soroban_sdk::Env,
    spender: soroban_sdk::Address,
    from: soroban_sdk::Address,
    to: soroban_sdk::Address,
    token_id: u32,
)
fn balance(env: soroban_sdk::Env, owner: soroban_sdk::Address) -> u32
fn owner_of(env: soroban_sdk::Env, token_id: u32) -> soroban_sdk::Address

Gives permission to approved to transfer the token with token_id to another account. The approval is cleared when the token is transferred.

Only a single account can be approved at a time for a token_id. To remove an approval, the approver can approve their own address, effectively removing the previous approved address. Alternatively, setting the live_until_ledger to 0 will also revoke the approval.

Arguments

  • e - Access to Soroban environment.
  • approver - The address of the approver (should be owner or operator).
  • approved - The address receiving the approval.
  • token_id - Token ID as a number.
  • live_until_ledger - The ledger number at which the allowance expires. If live_until_ledger is 0, the approval is revoked.

Errors

  • [NonFungibleTokenError::NonExistentToken] - If the token does not exist.
  • [NonFungibleTokenError::InvalidApprover] - If the owner address is not the actual owner of the token.
  • [NonFungibleTokenError::InvalidLiveUntilLedger] - If the ledge
fn approve(
    env: soroban_sdk::Env,
    approver: soroban_sdk::Address,
    approved: soroban_sdk::Address,
    token_id: u32,
    live_until_ledger: u32,
)

Approve or remove operator as an operator for the owner.

Operators can call transfer_from() for any token held by owner, and call approve() on behalf of owner.

Arguments

  • e - Access to Soroban environment.
  • owner - The address holding the tokens.
  • operator - Account to add to the set of authorized operators.
  • live_until_ledger - The ledger number at which the allowance expires. If live_until_ledger is 0, the approval is revoked.

Errors

  • [NonFungibleTokenError::InvalidLiveUntilLedger] - If the ledger number is less than the current ledger number.

Events

  • topics - ["approve_for_all", from: Address]
  • data - [operator: Address, live_until_ledger: u32]
fn approve_for_all(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
    operator: soroban_sdk::Address,
    live_until_ledger: u32,
)

Returns the account approved for the token with token_id.

Arguments

  • e - Access to the Soroban environment.
  • token_id - Token ID as a number.

Errors

  • [NonFungibleTokenError::NonExistentToken] - If the token does not exist.
fn get_approved(env: soroban_sdk::Env, token_id: u32) -> Option

Returns whether the operator is allowed to manage all the assets of owner.

Arguments

  • e - Access to the Soroban environment.
  • owner - Account of the token's owner.
  • operator - Account to be checked.
fn is_approved_for_all(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
    operator: soroban_sdk::Address,
) -> bool

Returns the token collection name.

Arguments

  • e - Access to the Soroban environment.
fn name(env: soroban_sdk::Env) -> soroban_sdk::String

Returns the token collection symbol.

Arguments

  • e - Access to the Soroban environment.
fn symbol(env: soroban_sdk::Env) -> soroban_sdk::String

Returns the Uniform Resource Identifier (URI) for the token with token_id.

Arguments

  • e - Access to the Soroban environment.
  • token_id - Token ID as a number.

Notes

If the token does not exist, this function is expected to panic.

fn token_uri(env: soroban_sdk::Env, token_id: u32) -> soroban_sdk::String
fn burn(env: soroban_sdk::Env, from: soroban_sdk::Address, token_id: u32)
fn burn_from(
    env: soroban_sdk::Env,
    spender: soroban_sdk::Address,
    from: soroban_sdk::Address,
    token_id: u32,
)

Returns the total amount of tokens stored by the contract.

Arguments

  • e - Access to the Soroban environment.
fn total_supply(env: soroban_sdk::Env) -> u32

Returns the token_id owned by owner at a given index in the owner's local list. Use along with [crate::non_fungible::NonFungibleToken::balance] to enumerate all of owner's tokens.

Arguments

  • e - Access to the Soroban environment.
  • owner - Account of the token's owner.
  • index - Index of the token in the owner's local list.

Errors

  • [crate::non_fungible::NonFungibleTokenError::TokenNotFoundInOwnerList] - When the token ID is not found in the owner's enumeration.
fn get_owner_token_id(
    env: soroban_sdk::Env,
    owner: soroban_sdk::Address,
    index: u32,
) -> u32

Returns the token_id at a given index in the global token list. Use along with [NonFungibleEnumerable::total_supply] to enumerate all the tokens in the contract.

We do not provide a function to get all the tokens of a contract, since that would be unbounded. If you need to enumerate all the tokens of a contract, you can use [NonFungibleEnumerable::total_supply] to get the total number of tokens and then use [NonFungibleEnumerable::get_token_id] to get each token one by one.

Arguments

  • e - Access to the Soroban environment.
  • index - Index of the token in the global list.

Errors

  • [crate::non_fungible::NonFungibleTokenError::TokenNotFoundInGlobalList] - When the token ID is not found in the global enumeration.
fn get_token_id(env: soroban_sdk::Env, index: u32) -> u32

Returns Some(Address) if ownership is set, or None if ownership has been renounced.

Arguments

  • e - Access to the Soroban environment.
fn get_owner(env: soroban_sdk::Env) -> Option

Initiates a 2-step ownership transfer to a new address.

Requires authorization from the current owner. The new owner must later call accept_ownership() to complete the transfer.

Arguments

  • e - Access to the Soroban environment.
  • new_owner - The proposed new owner.
  • live_until_ledger - Ledger number until which the new owner can accept. A value of 0 cancels any pending transfer.

Errors

  • [OwnableError::OwnerNotSet] - If the owner is not set.
  • [crate::role_transfer::RoleTransferError::NoPendingTransfer] - If trying to cancel a transfer that doesn't exist.
  • [crate::role_transfer::RoleTransferError::InvalidLiveUntilLedger] - If the specified ledger is in the past.
  • [crate::role_transfer::RoleTransferError::InvalidPendingAccount] - If the specified pending account is not the same as the provided new address.

Notes

  • Authorization for the current owner is required.
fn transfer_ownership(
    env: soroban_sdk::Env,
    new_owner: soroban_sdk::Address,
    live_until_ledger: u32,
)

Accepts a pending ownership transfer.

Arguments

  • e - Access to the Soroban environment.

Errors

  • [crate::role_transfer::RoleTransferError::NoPendingTransfer] - If there is no pending transfer to accept.

Events

  • topics - ["ownership_transfer_completed"]
  • data - [new_owner: Address]
fn accept_ownership(env: soroban_sdk::Env)

Renounces ownership of the contract.

Permanently removes the owner, disabling all functions gated by #[only_owner].

Arguments

  • e - Access to the Soroban environment.

Errors

  • [OwnableError::TransferInProgress] - If there is a pending ownership transfer.
  • [OwnableError::OwnerNotSet] - If the owner is not set.

Notes

  • Authorization for the current owner is required.
fn renounce_ownership(env: soroban_sdk::Env)
fn paused(env: soroban_sdk::Env) -> bool
fn pause(env: soroban_sdk::Env, caller: soroban_sdk::Address)
fn unpause(env: soroban_sdk::Env, caller: soroban_sdk::Address)

Imports

WebAssembly Text (WAT) ▶