pub struct NonFungibleToken {
    pub owner_id: AccountId,
    pub extra_storage_in_bytes_per_token: StorageUsage,
    pub owner_by_id: TreeMap<TokenId, AccountId>,
    pub token_metadata_by_id: Option<LookupMap<TokenId, TokenMetadata>>,
    pub tokens_per_owner: Option<LookupMap<AccountId, UnorderedSet<TokenId>>>,
    pub approvals_by_id: Option<LookupMap<TokenId, HashMap<AccountId, u64>>>,
    pub next_approval_id_by_id: Option<LookupMap<TokenId, u64>>,
}
Expand description

Implementation of the non-fungible token standard. Allows to include NEP-171 compatible token to any contract. There are next traits that any contract may implement: - NonFungibleTokenCore – interface with nft_transfer methods. NonFungibleToken provides methods for it. - NonFungibleTokenApproval – interface with nft_approve methods. NonFungibleToken provides methods for it. - NonFungibleTokenEnumeration – interface for getting lists of tokens. NonFungibleToken provides methods for it. - NonFungibleTokenMetadata – return metadata for the token in NEP-177, up to contract to implement.

For example usage, see examples/non-fungible-token/src/lib.rs.

Fields§

§owner_id: AccountId§extra_storage_in_bytes_per_token: StorageUsage§owner_by_id: TreeMap<TokenId, AccountId>§token_metadata_by_id: Option<LookupMap<TokenId, TokenMetadata>>§tokens_per_owner: Option<LookupMap<AccountId, UnorderedSet<TokenId>>>§approvals_by_id: Option<LookupMap<TokenId, HashMap<AccountId, u64>>>§next_approval_id_by_id: Option<LookupMap<TokenId, u64>>

Implementations§

👎Deprecated since 4.0.0: mint is deprecated, please use internal_mint instead.

Mint a new token. Not part of official standard, but needed in most situations. Consuming contract expected to wrap this with an nft_mint function.

Requirements:

  • Caller must be the owner_id set during contract initialization.
  • Caller of the method must attach a deposit of 1 yoctoⓃ for security purposes.
  • If contract is using Metadata extension (by having provided metadata_prefix during contract initialization), token_metadata must be given.
  • token_id must be unique

Returns the newly minted token

Mint a new token without checking:

  • Whether the caller id is equal to the owner_id
  • Assumes there will be a refund to the predecessor after covering the storage costs

Returns the newly minted token and emits the mint event

Mint a new token without checking:

  • Whether the caller id is equal to the owner_id
  • refund_id will transfer the left over balance after storage costs are calculated to the provided account. Typically the account will be the owner. If None, will not refund. This is useful for delaying refunding until multiple tokens have been minted.

Returns the newly minted token and does not emit the mint event. This allows minting multiple before emitting.

Trait Implementations§

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Deserialize this instance from a slice of bytes.
Serialize this instance into a vector of bytes.
Add an approved account for a specific token. Read more
Revoke an approved account for a specific token. Read more
Revoke all approved accounts for a specific token. Read more
Check if a token is approved for transfer by a given account, optionally checking an approval_id Read more
Returns the token with the given token_id or null if no such token.
Returns the total supply of non-fungible tokens as a string representing an unsigned 128-bit integer to avoid JSON number limit of 2^53.
Get a list of all tokens Read more
Get number of tokens owned by a given account Read more
Get list of all tokens owned by a given account Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.