Starcoin’s standard NFT protocol

* By Starcoin community

Ethereum's NFT

Starcoin's standard NFT protocol

Starcoin's standard NFT protocol

/// The info of NFT type
struct NFTTypeInfoV2<NFTMeta: copy + store + drop> has key, store {
register: address,
counter: u64,
meta: Metadata,
mint_events: Event::EventHandle<MintEvent<NFTMeta>>,
burn_events: Event::EventHandle<BurnEvent<NFTMeta>>,
}

/// The capability to mint the nft.
struct MintCapability<NFTMeta: store> has key, store {}
/// The Capability to burn the nft.
struct BurnCapability<NFTMeta: store> has key, store {}
/// The Capability to update the nft metadata.
struct UpdateCapability<NFTMeta: store> has key, store {}

public fun register_v2<NFTMeta: copy + store + drop>(sender: &signer, meta: Metadata)

public fun mint_v2<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer, base_meta: Metadata, type_meta: NFTMeta, body: NFTBody): NFT<NFTMeta, NFTBody> acquires NFTTypeInfoV2, MintCapability

public fun burn<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer, nft: NFT<NFTMeta, NFTBody>): NFTBody acquires NFTTypeInfoV2, BurnCapability
struct NFTGallery<NFTMeta: copy + store + drop, NFTBody: store> has key, store {
withdraw_events: Event::EventHandle<WithdrawEvent<NFTMeta>>,
deposit_events: Event::EventHandle<DepositEvent<NFTMeta>>,
items: vector<NFT<NFTMeta, NFTBody>>,
}

public fun accept<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer)

public fun transfer<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer, id: u64, receiver: address) acquires NFTGallery

public fun deposit<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer, nft: NFT<NFTMeta, NFTBody>) acquires NFTGallery

public fun withdraw<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer, id: u64): Option<NFT<NFTMeta, NFTBody>> acquires NFTGallery

Starcoin's IndentifierNFT

struct IdentifierNFT<NFTMeta: copy + store + drop, NFTBody: store> has key {
nft: Option<NFT<NFTMeta, NFTBody>>,
}

public fun accept<NFTMeta: copy + store + drop, NFTBody: store>(sender: &signer)

public fun grant<NFTMeta: copy + store + drop, NFTBody: store>(cap: &mut MintCapability<NFTMeta>, sender: &signer, nft: NFT<NFTMeta, NFTBody>) acquires IdentifierNFT

public fun revoke<NFTMeta: copy + store + drop, NFTBody: store>(_cap: &mut BurnCapability<NFTMeta>, owner: address): NFT<NFTMeta, NFTBody> acquires IdentifierNFT

Summarize

--

--

Starcoin is a proof-of-work blockchain that enables secure smart contracts based on Move to power services in Web 3.0

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Starcoin

Starcoin is a proof-of-work blockchain that enables secure smart contracts based on Move to power services in Web 3.0