pub trait Dip721 {
Show 31 methods
// Required methods
fn dip721_metadata() -> Metadata;
fn dip721_stats() -> Stats;
fn dip721_logo() -> Option<String>;
fn dip721_set_logo(logo: String);
fn dip721_name() -> Option<String>;
fn dip721_set_name(name: String);
fn dip721_symbol() -> Option<String>;
fn dip721_set_symbol(symbol: String);
fn dip721_custodians() -> Vec<Principal>;
fn dip721_set_custodians(custodians: Vec<Principal>);
fn dip721_cycles() -> Nat;
fn dip721_total_unique_holders() -> Nat;
fn dip721_token_metadata(
token_identifier: TokenIdentifier,
) -> Result<TokenMetadata, NftError>;
fn dip721_balance_of(owner: Principal) -> Result<Nat, NftError>;
fn dip721_owner_of(
token_identifier: TokenIdentifier,
) -> Result<Option<Principal>, NftError>;
fn dip721_owner_token_identifiers(
owner: Principal,
) -> Result<Vec<TokenIdentifier>, NftError>;
fn dip721_owner_token_metadata(
owner: Principal,
) -> Result<Vec<TokenMetadata>, NftError>;
fn dip721_operator_of(
token_identifier: TokenIdentifier,
) -> Result<Option<Principal>, NftError>;
fn dip721_operator_token_identifiers(
operator: Principal,
) -> Result<Vec<TokenIdentifier>, NftError>;
fn dip721_operator_token_metadata(
operator: Principal,
) -> Result<Vec<TokenMetadata>, NftError>;
fn dip721_supported_interfaces() -> Vec<SupportedInterface>;
fn dip721_total_supply() -> Nat;
fn dip721_approve(
operator: Principal,
token_identifier: TokenIdentifier,
) -> Result<Nat, NftError>;
fn dip721_set_approval_for_all(
operator: Principal,
approved: bool,
) -> Result<Nat, NftError>;
fn dip721_is_approved_for_all(
owner: Principal,
operator: Principal,
) -> Result<bool, NftError>;
fn dip721_transfer<'async_trait>(
to: Principal,
token_identifier: TokenIdentifier,
) -> Pin<Box<dyn Future<Output = Result<Nat, NftError>> + Send + 'async_trait>>;
fn dip721_transfer_from<'async_trait>(
owner: Principal,
to: Principal,
token_identifier: TokenIdentifier,
) -> Pin<Box<dyn Future<Output = Result<Nat, NftError>> + Send + 'async_trait>>;
fn dip721_mint(
to: Principal,
token_identifier: TokenIdentifier,
properties: Vec<(String, GenericValue)>,
) -> Result<Nat, NftError>;
fn dip721_burn(token_identifier: TokenIdentifier) -> Result<Nat, NftError>;
fn dip721_transaction(tx_id: Nat) -> Result<TxEvent, NftError>;
fn dip721_total_transactions() -> Nat;
}
Expand description
Represents the method a DIP721 canister must implement
Required Methods§
Sourcefn dip721_metadata() -> Metadata
fn dip721_metadata() -> Metadata
Returns the Metadata of the NFT canister which includes custodians, logo, name, symbol.
Sourcefn dip721_stats() -> Stats
fn dip721_stats() -> Stats
Returns the Stats of the NFT canister which includes cycles, totalSupply, totalTransactions, totalUniqueHolders.
Sourcefn dip721_logo() -> Option<String>
fn dip721_logo() -> Option<String>
Returns the logo of the NFT contract as Base64 encoded text.
Sourcefn dip721_set_logo(logo: String)
fn dip721_set_logo(logo: String)
Sets the logo of the NFT canister. Base64 encoded text is recommended. Caller must be the custodian of NFT canister.
Sourcefn dip721_name() -> Option<String>
fn dip721_name() -> Option<String>
Returns the name of the NFT canister.
Sourcefn dip721_set_name(name: String)
fn dip721_set_name(name: String)
Sets the name of the NFT contract. Caller must be the custodian of NFT canister.
Sourcefn dip721_symbol() -> Option<String>
fn dip721_symbol() -> Option<String>
Returns the symbol of the NFT contract.
Sourcefn dip721_set_symbol(symbol: String)
fn dip721_set_symbol(symbol: String)
Set symbol Caller must be the custodian of NFT canister.
Sourcefn dip721_custodians() -> Vec<Principal>
fn dip721_custodians() -> Vec<Principal>
Returns a list of the canister custodians
Sourcefn dip721_set_custodians(custodians: Vec<Principal>)
fn dip721_set_custodians(custodians: Vec<Principal>)
Set canister custodians Caller must be the custodian of NFT canister.
Sourcefn dip721_cycles() -> Nat
fn dip721_cycles() -> Nat
Returns canister cycles
Sourcefn dip721_total_unique_holders() -> Nat
fn dip721_total_unique_holders() -> Nat
Returns total unique holders of tokens
Sourcefn dip721_token_metadata(
token_identifier: TokenIdentifier,
) -> Result<TokenMetadata, NftError>
fn dip721_token_metadata( token_identifier: TokenIdentifier, ) -> Result<TokenMetadata, NftError>
Returns metadata for token
Sourcefn dip721_balance_of(owner: Principal) -> Result<Nat, NftError>
fn dip721_balance_of(owner: Principal) -> Result<Nat, NftError>
Returns the count of NFTs owned by user. If the user does not own any NFTs, returns an error containing NftError.
Sourcefn dip721_owner_of(
token_identifier: TokenIdentifier,
) -> Result<Option<Principal>, NftError>
fn dip721_owner_of( token_identifier: TokenIdentifier, ) -> Result<Option<Principal>, NftError>
Returns the owner of the token. Returns an error containing NftError if token_identifier is invalid.
Sourcefn dip721_owner_token_identifiers(
owner: Principal,
) -> Result<Vec<TokenIdentifier>, NftError>
fn dip721_owner_token_identifiers( owner: Principal, ) -> Result<Vec<TokenIdentifier>, NftError>
Returns the list of the token_identifier of the NFT associated with owner. Returns an error containing NftError if principal is invalid.
Sourcefn dip721_owner_token_metadata(
owner: Principal,
) -> Result<Vec<TokenMetadata>, NftError>
fn dip721_owner_token_metadata( owner: Principal, ) -> Result<Vec<TokenMetadata>, NftError>
Returns the list of the token_metadata of the NFT associated with owner. Returns an error containing NftError if principal is invalid.
Sourcefn dip721_operator_of(
token_identifier: TokenIdentifier,
) -> Result<Option<Principal>, NftError>
fn dip721_operator_of( token_identifier: TokenIdentifier, ) -> Result<Option<Principal>, NftError>
Returns the Principal of the operator of the NFT associated with token_identifier.
Sourcefn dip721_operator_token_identifiers(
operator: Principal,
) -> Result<Vec<TokenIdentifier>, NftError>
fn dip721_operator_token_identifiers( operator: Principal, ) -> Result<Vec<TokenIdentifier>, NftError>
Returns the list of the token_identifier of the NFT associated with operator.
Sourcefn dip721_operator_token_metadata(
operator: Principal,
) -> Result<Vec<TokenMetadata>, NftError>
fn dip721_operator_token_metadata( operator: Principal, ) -> Result<Vec<TokenMetadata>, NftError>
Returns the list of the token_metadata of the NFT associated with operator.
Sourcefn dip721_supported_interfaces() -> Vec<SupportedInterface>
fn dip721_supported_interfaces() -> Vec<SupportedInterface>
Returns the list of the interfaces supported by this canister
Sourcefn dip721_total_supply() -> Nat
fn dip721_total_supply() -> Nat
Returns the total supply of the NFT. NFTs that are minted and later burned explicitly or sent to the zero address should also count towards totalSupply.
Sourcefn dip721_approve(
operator: Principal,
token_identifier: TokenIdentifier,
) -> Result<Nat, NftError>
fn dip721_approve( operator: Principal, token_identifier: TokenIdentifier, ) -> Result<Nat, NftError>
Interface: approval
Sourcefn dip721_set_approval_for_all(
operator: Principal,
approved: bool,
) -> Result<Nat, NftError>
fn dip721_set_approval_for_all( operator: Principal, approved: bool, ) -> Result<Nat, NftError>
Enable or disable an operator to manage all of the tokens for the caller of this function. The contract allows multiple operators per owner. Approvals granted by the approve function are independent from the approvals granted by setApprovalForAll function. If the approval goes through, returns a nat that represents the CAP History transaction ID that can be used at the transaction method. Interface: approval
Sourcefn dip721_is_approved_for_all(
owner: Principal,
operator: Principal,
) -> Result<bool, NftError>
fn dip721_is_approved_for_all( owner: Principal, operator: Principal, ) -> Result<bool, NftError>
Returns true if the given operator is an approved operator for all the tokens owned by the caller through the use of the setApprovalForAll method, returns false otherwise. Interface: approval
Sourcefn dip721_transfer<'async_trait>(
to: Principal,
token_identifier: TokenIdentifier,
) -> Pin<Box<dyn Future<Output = Result<Nat, NftError>> + Send + 'async_trait>>
fn dip721_transfer<'async_trait>( to: Principal, token_identifier: TokenIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Nat, NftError>> + Send + 'async_trait>>
Sends the callers nft token_identifier to `to`` and returns a nat that represents a transaction id that can be used at the transaction method.
Sourcefn dip721_transfer_from<'async_trait>(
owner: Principal,
to: Principal,
token_identifier: TokenIdentifier,
) -> Pin<Box<dyn Future<Output = Result<Nat, NftError>> + Send + 'async_trait>>
fn dip721_transfer_from<'async_trait>( owner: Principal, to: Principal, token_identifier: TokenIdentifier, ) -> Pin<Box<dyn Future<Output = Result<Nat, NftError>> + Send + 'async_trait>>
Caller of this method is able to transfer the NFT token_identifier that is in from’s balance to to’s balance if the caller is an approved operator to do so.
If the transfer goes through, returns a nat that represents the CAP History transaction ID that can be used at the transaction method.
Sourcefn dip721_mint(
to: Principal,
token_identifier: TokenIdentifier,
properties: Vec<(String, GenericValue)>,
) -> Result<Nat, NftError>
fn dip721_mint( to: Principal, token_identifier: TokenIdentifier, properties: Vec<(String, GenericValue)>, ) -> Result<Nat, NftError>
Mint an NFT for principal to that has an ID of token_identifier and metadata akin to properties. Implementations are encouraged to only allow minting by the owner of the canister. If the mint goes through, returns a nat that represents the CAP History transaction ID that can be used at the transaction method.
Interface: mint
Sourcefn dip721_burn(token_identifier: TokenIdentifier) -> Result<Nat, NftError>
fn dip721_burn(token_identifier: TokenIdentifier) -> Result<Nat, NftError>
Burn an NFT identified by token_identifier. Calling burn on a token sets the owner to None and will no longer be useable. Burned tokens do still count towards totalSupply. Implementations are encouraged to only allow burning by the owner of the token_identifier.
Sourcefn dip721_transaction(tx_id: Nat) -> Result<TxEvent, NftError>
fn dip721_transaction(tx_id: Nat) -> Result<TxEvent, NftError>
Returns the TxEvent that corresponds with tx_id. If there is no TxEvent that corresponds with the tx_id entered, returns a NftError.TxNotFound.
Sourcefn dip721_total_transactions() -> Nat
fn dip721_total_transactions() -> Nat
Returns a nat that represents the total number of transactions that have occurred on the NFT canister.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.