Struct near_contract_standards::non_fungible_token::NonFungibleToken[][src]

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: AccountIdextra_storage_in_bytes_per_token: StorageUsageowner_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

Transfer token_id from from to to

Do not perform any safety checks or do any logging

Transfer from current owner to receiver_id, checking that sender is allowed to transfer. Clear approvals, if approval extension being used. Return previous owner and approvals.

👎 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

Trait Implementations

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes. Read more

Deserialize this instance from a slice of bytes.

Whether Self is u8. NOTE: Vec<u8> is the most common use-case for serialization and deserialization, it’s worth handling it as a special case to improve performance. It’s a workaround for specific Vec<u8> implementation versus generic Vec<T> implementation. See https://github.com/rust-lang/rfcs/pull/1210 for details. Read more

Serialize this instance into a vector of bytes.

Whether Self is u8. NOTE: Vec<u8> is the most common use-case for serialization and deserialization, it’s worth handling it as a special case to improve performance. It’s a workaround for specific Vec<u8> implementation versus generic Vec<T> implementation. See https://github.com/rust-lang/rfcs/pull/1210 for details. Read more

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

Simple transfer. Transfer a given token_id from current owner to receiver_id. Read more

Transfer token and call a method on a receiver contract. A successful workflow will end in a success execution outcome to the callback on the NFT contract at the method nft_resolve_transfer. 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. Read more

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

Returns true if token was successfully transferred to receiver_id.

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

Performs the conversion.

Performs the conversion.

Should always be Self

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.