Skip to main content

Module stardust::nft

use iota::address; use iota::display; use iota::event; use iota::hex; use iota::object; use iota::package; use iota::transfer; use iota::tx_context; use iota::types; use iota::url; use iota::vec_map; use stardust::irc27; use std::address; use std::ascii; use std::bcs; use std::fixed_point32; use std::option; use std::string; use std::type_name; use std::vector;

Structs

struct NFT

One Time Witness.

public struct NFT has drop

Fields

prv init

The Nft module initializer.

fun init(otw: stardust::nft::NFT, ctx: &mut iota::tx_context::TxContext)

Implementation

fun init(otw: NFT, ctx: &mut TxContext) {     // Claim the module publisher.     let publisher = package::claim(otw, ctx);     // Build a Display object.     let keys = vector[         // The IOTA standard fields.         string::utf8(b"name"),         string::utf8(b"image_url"),         string::utf8(b"description"),         string::utf8(b"creator"),         // The extra IRC27-nested fields.         string::utf8(b"version"),         string::utf8(b"media_type"),         string::utf8(b"collection_name"),         // The issuer of the NFT. Equivalent to IRC-27 collectionId.         string::utf8(b"immutable_issuer"),     ];     let values = vector[         // The IOTA standard fields.         string::utf8(b"{immutable_metadata.name}"),         string::utf8(b"{immutable_metadata.uri}"),         string::utf8(b"{immutable_metadata.description}"),         string::utf8(b"{immutable_metadata.issuer_name}"),         // The extra IRC27-nested fields.         string::utf8(b"{immutable_metadata.version}"),         string::utf8(b"{immutable_metadata.media_type}"),         string::utf8(b"{immutable_metadata.collection_name}"),         // The issuer of the NFT. Equivalent to IRC-27 collectionId.         string::utf8(b"{immutable_issuer}"),     ];     let mut display = display::new_with_fields<Nft>(         &publisher,         keys,         values,         ctx,     );     // Commit the first version of Display to apply changes.     display.update_version();     // Burn the publisher object.     package::burn_publisher(publisher);     // Freeze the display object.     iota::transfer::public_freeze_object(display); }

struct Nft

The Stardust NFT representation.

public struct Nft has key, store

Fields
id: iota::object::UID

The Nft's ID is nested from Stardust.

legacy_sender: std::option::Option<address>

The sender feature holds the last sender address assigned before the migration and is not supported by the protocol after it.

metadata: std::option::Option<vector<u8>>

The metadata feature.

tag: std::option::Option<vector<u8>>

The tag feature.

immutable_issuer: std::option::Option<address>

The immutable issuer feature.

immutable_metadata: stardust::irc27::Irc27Metadata

The immutable metadata feature.

pub destroy

Permanently destroy an Nft object.

public fun destroy(nft: stardust::nft::Nft)

Implementation

public fun destroy(nft: Nft) {     let Nft {         id,         legacy_sender: _,         metadata: _,         tag: _,         immutable_issuer: _,         immutable_metadata,     } = nft;     irc27::destroy(immutable_metadata);     object::delete(id); }

pub immutable_issuer

Get the Nft's immutable_sender.

public fun immutable_issuer(nft: &stardust::nft::Nft): &std::option::Option<address>

Implementation

public fun immutable_issuer(nft: &Nft): &Option<address> {     &nft.immutable_issuer }

pub immutable_metadata

Get the Nft's immutable_metadata.

public fun immutable_metadata(nft: &stardust::nft::Nft): &stardust::irc27::Irc27Metadata

Implementation

public fun immutable_metadata(nft: &Nft): &Irc27Metadata {     &nft.immutable_metadata }

pub legacy_sender

Get the Nft's legacy_sender.

public fun legacy_sender(nft: &stardust::nft::Nft): &std::option::Option<address>

Implementation

public fun legacy_sender(nft: &Nft): &Option<address> {     &nft.legacy_sender }

pub metadata

Get the Nft's metadata.

public fun metadata(nft: &stardust::nft::Nft): &std::option::Option<vector<u8>>

Implementation

public fun metadata(nft: &Nft): &Option> {     &nft.metadata }

pub tag

Get the Nft's tag.

public fun tag(nft: &stardust::nft::Nft): &std::option::Option<vector<u8>>

Implementation

public fun tag(nft: &Nft): &Option> {     &nft.tag }

pub(pkg) id

Get the Nft's id.

public(package) fun id(self: &mut stardust::nft::Nft): &mut iota::object::UID

Implementation

public(package) fun id(self: &mut Nft): &mut UID {     &mut self.id }