pub trait Erc721 {
// Required methods
fn balance_of(&self, owner: &Address) -> U256;
fn owner_of(&self, token_id: &U256) -> Address;
fn safe_transfer_from(
&mut self,
from: &Address,
to: &Address,
token_id: &U256,
);
fn safe_transfer_from_with_data(
&mut self,
from: &Address,
to: &Address,
token_id: &U256,
data: &Bytes,
);
fn transfer_from(&mut self, from: &Address, to: &Address, token_id: &U256);
fn approve(&mut self, approved: &Option<Address>, token_id: &U256);
fn set_approval_for_all(&mut self, operator: &Address, approved: bool);
fn get_approved(&self, token_id: &U256) -> Option<Address>;
fn is_approved_for_all(&self, owner: &Address, operator: &Address) -> bool;
}Expand description
The ERC-721 interface as defined in the standard.
Required Methods§
Sourcefn balance_of(&self, owner: &Address) -> U256
fn balance_of(&self, owner: &Address) -> U256
Returns the amount of tokens owned by owner.
Sourcefn owner_of(&self, token_id: &U256) -> Address
fn owner_of(&self, token_id: &U256) -> Address
Returns the owner of the token_id token.
Reverts if token_id does not exist.
Sourcefn safe_transfer_from(&mut self, from: &Address, to: &Address, token_id: &U256)
fn safe_transfer_from(&mut self, from: &Address, to: &Address, token_id: &U256)
Safely transfers token_id token from from to to, checking the recipient contract uses
Erc721Receiver.
Emits a Transfer event.
Sourcefn safe_transfer_from_with_data(
&mut self,
from: &Address,
to: &Address,
token_id: &U256,
data: &Bytes,
)
fn safe_transfer_from_with_data( &mut self, from: &Address, to: &Address, token_id: &U256, data: &Bytes, )
Safely transfers token_id token from from to to, checking the recipient contract uses
Erc721Receiver, passes additional data.
Emits a Transfer event.
Sourcefn transfer_from(&mut self, from: &Address, to: &Address, token_id: &U256)
fn transfer_from(&mut self, from: &Address, to: &Address, token_id: &U256)
Transfers a specific NFT tokenId from one account from to another to.
Sourcefn approve(&mut self, approved: &Option<Address>, token_id: &U256)
fn approve(&mut self, approved: &Option<Address>, token_id: &U256)
Grants permission to approved to transfer token_id token. The approval is cleared when the token is transferred.
Only a single account can be approved at a time, so approving None clears the previous approval.
Sourcefn set_approval_for_all(&mut self, operator: &Address, approved: bool)
fn set_approval_for_all(&mut self, operator: &Address, approved: bool)
Approves or removes operator for the caller. Operators can call transfer_from or safe_transfer_from for all
tokens owned by the caller.
The operator cannot be the caller.
Emits a ApprovalForAll event.
Sourcefn get_approved(&self, token_id: &U256) -> Option<Address>
fn get_approved(&self, token_id: &U256) -> Option<Address>
Returns the address approved for token_id token.
Reverts if token_id does not exist.
Sourcefn is_approved_for_all(&self, owner: &Address, operator: &Address) -> bool
fn is_approved_for_all(&self, owner: &Address, operator: &Address) -> bool
Returns if the operator is allowed to manage all of the tokens of owner.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".