CEP95Interface

Trait CEP95Interface 

Source
pub trait CEP95Interface {
Show 13 methods // Required methods fn name(&self) -> String; fn symbol(&self) -> String; fn balance_of(&self, owner: Address) -> U256; fn owner_of(&self, token_id: U256) -> Option<Address>; fn safe_transfer_from( &mut self, from: Address, to: Address, token_id: U256, data: Option<Bytes>, ); fn transfer_from(&mut self, from: Address, to: Address, token_id: U256); fn approve(&mut self, spender: Address, token_id: U256); fn revoke_approval(&mut self, token_id: U256); fn approved_for(&self, token_id: U256) -> Option<Address>; fn approve_for_all(&mut self, operator: Address); fn revoke_approval_for_all(&mut self, operator: Address); fn is_approved_for_all(&self, owner: Address, operator: Address) -> bool; fn token_metadata(&self, token_id: U256) -> Vec<(String, String)>;
}
Expand description

Casper-compatible NFT interface

Required Methods§

Source

fn name(&self) -> String

Returns a name of the NFT token/collection.

Source

fn symbol(&self) -> String

Returns a short symbol or abbreviation for the NFT token/collection.

Source

fn balance_of(&self, owner: Address) -> U256

Returns the number of NFTs owned by a given account or contract

§Arguments

owner - The account to query.

§Returns

The number of NFTs owned by the account.

Source

fn owner_of(&self, token_id: U256) -> Option<Address>

Returns the owner of a specific NFT.

§Arguments

token_id - The ID of the NFT.

§Returns

The owner if it exists, else None.

Source

fn safe_transfer_from( &mut self, from: Address, to: Address, token_id: U256, data: Option<Bytes>, )

Performs a recipient check and transfers the ownership of an NFT.

Reverts unless the contract caller is the current owner, an authorized operator, or the approved spender for this NFT. Reverts if from is not the current owner, or if token_id does not reference a valid NFT. Once ownership is updated and a Transfer event is emitted, the function checks whether to is a contract hash. If it is, the contract MUST call on_cep95_received on to and revert the entire transfer if that call is absent or returns any value other than true.

§Arguments

from - The current owner of the NFT. to - The new owner. token_id - The NFT ID. data - Optional payload to pass to a receiving contract.

Source

fn transfer_from(&mut self, from: Address, to: Address, token_id: U256)

Transfers the ownership of an NFT without checking the recipient contract.

§Arguments

from - The current owner of the NFT. to - The new owner. token_id - The NFT ID.

Source

fn approve(&mut self, spender: Address, token_id: U256)

Approves another account or contract to transfer a specific NFT.

§Arguments

spender - The account or contract that will be granted approval. token_id - The NFT ID.

Source

fn revoke_approval(&mut self, token_id: U256)

Revokes approval for a specific NFT.

§Arguments

token_id - The NFT ID to revoke approval for.

Source

fn approved_for(&self, token_id: U256) -> Option<Address>

Gets the approved account or contract for a specific NFT.

§Arguments

token_id - The ID of the NFT to check.

§Returns

Option

- The approved spender account if one exists, else None.

Source

fn approve_for_all(&mut self, operator: Address)

Enables operator approval for all of the caller’s NFTs.

§Arguments

operator - The operator address to be approved.

Source

fn revoke_approval_for_all(&mut self, operator: Address)

Revokes operator approval for all of the caller’s NFTs.

§Arguments

operator - The operator address to be revoked.

Source

fn is_approved_for_all(&self, owner: Address, operator: Address) -> bool

Checks if an operator is approved to manage all NFTs of the owner.

§Arguments

owner - The NFT owner’s address. operator - The operator to check.

§Returns

True if the operator is approved for all NFTs, false otherwise.

Source

fn token_metadata(&self, token_id: U256) -> Vec<(String, String)>

Returns metadata for a given token ID.

§Arguments

token_id - The ID of the NFT.

§Returns

A vector of key-value pairs representing the metadata.

Implementors§