Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

InternalTrait

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait

pub trait InternalTrait<
    TContractState,
    +HasComponent<TContractState>,
    impl SRC5: HasComponent<TContractState>,
    impl Hooks: ERC721HooksTrait<TContractState>,
    +Drop<TContractState>,
>

Trait functions

initializer

Initializes the contract by setting the token name, symbol, and base URI. This should only be used inside the contract’s constructor.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::initializer

fn initializer(
    ref self: ComponentState<TContractState>,
    name: ByteArray,
    symbol: ByteArray,
    base_uri: ByteArray,
)

exists

Returns whether token_id exists.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::exists

fn exists(self: @ComponentState<TContractState>, token_id: u256) -> bool

transfer

Transfers token_id from from to to.

Internal function without access restriction.

WARNING: This method may lead to the loss of tokens if to is not aware of the ERC721 protocol.

Requirements:

  • to is not the zero address.
  • from is the token owner.
  • token_id exists.

Emits a Transfer event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::transfer

fn transfer(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    token_id: u256,
)

mint

Mints token_id and transfers it to to. Internal function without access restriction.

WARNING: This method may lead to the loss of tokens if to is not aware of the ERC721 protocol.

Requirements:

  • to is not the zero address.
  • token_id does not exist.

Emits a Transfer event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::mint

fn mint(ref self: ComponentState<TContractState>, to: ContractAddress, token_id: u256)

safe_transfer

Transfers ownership of token_id from from if to is either an account or IERC721Receiver.

data is additional data, it has no specified format and it is sent in call to to.

WARNING: This method makes an external call to the recipient contract, which can lead to reentrancy vulnerabilities.

Requirements:

  • to cannot be the zero address.
  • from must be the token owner.
  • token_id exists.
  • to is either an account contract or supports the IERC721Receiver interface.

Emits a Transfer event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::safe_transfer

fn safe_transfer(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    token_id: u256,
    data: Span<felt252>,
)

safe_mint

Mints token_id if to is either an account or IERC721Receiver.

data is additional data, it has no specified format and it is sent in call to to.

WARNING: This method makes an external call to the recipient contract, which can lead to reentrancy vulnerabilities.

Requirements:

  • token_id does not exist.
  • to is either an account contract or supports the IERC721Receiver interface.

Emits a Transfer event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::safe_mint

fn safe_mint(
    ref self: ComponentState<TContractState>,
    to: ContractAddress,
    token_id: u256,
    data: Span<felt252>,
)

burn

Destroys token_id. The approval is cleared when the token is burned.

This internal function does not check if the caller is authorized to operate on the token.

Requirements:

  • token_id exists.

Emits a Transfer event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::burn

fn burn(ref self: ComponentState<TContractState>, token_id: u256)

update

Transfers token_id from its current owner to to, or alternatively mints (or burns) if the current owner (or to) is the zero address. Returns the owner of the token_id before the update.

The auth argument is optional. If the value passed is non-zero, then this function will check that auth is either the owner of the token, or approved to operate on the token (by the owner).

Emits a Transfer event.

NOTE: This function can be extended using the ERC721HooksTrait, to add functionality before and/or after the transfer, mint, or burn.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::update

fn update(
    ref self: ComponentState<TContractState>,
    to: ContractAddress,
    token_id: u256,
    auth: ContractAddress,
) -> ContractAddress

_owner_of

Returns the owner address of token_id.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_owner_of

fn _owner_of(self: @ComponentState<TContractState>, token_id: u256) -> ContractAddress

_require_owned

Returns the owner address of token_id.

Requirements:

  • token_id exists.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_require_owned

fn _require_owned(self: @ComponentState<TContractState>, token_id: u256) -> ContractAddress

_approve

Approve to to operate on token_id

The auth argument is optional. If the value passed is non-zero, then this function will check that auth is either the owner of the token, or approved to operate on all tokens held by this owner.

Emits an Approval event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_approve

fn _approve(
    ref self: ComponentState<TContractState>,
    to: ContractAddress,
    token_id: u256,
    auth: ContractAddress,
)

_approve_with_optional_event

Variant of _approve with an optional flag to enable or disable the Approval event. The event is not emitted in the context of transfers.

WARNING: If auth is zero and emit_event is false, this function will not check that the token exists.

Requirements:

  • If auth is non-zero, it must be either the owner of the token or approved to operate on all of its tokens.

May emit an Approval event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_approve_with_optional_event

fn _approve_with_optional_event(
    ref self: ComponentState<TContractState>,
    to: ContractAddress,
    token_id: u256,
    auth: ContractAddress,
    emit_event: bool,
)

_set_approval_for_all

Enables or disables approval for operator to manage all of the owner assets.

Requirements:

  • operator is not the zero address.

Emits an Approval event.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_set_approval_for_all

fn _set_approval_for_all(
    ref self: ComponentState<TContractState>,
    owner: ContractAddress,
    operator: ContractAddress,
    approved: bool,
)

_set_base_uri

Sets the base URI.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_set_base_uri

fn _set_base_uri(ref self: ComponentState<TContractState>, base_uri: ByteArray)

_set_allow_transfer

Custom Sets if transfer is enabled

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_set_allow_transfer

fn _set_allow_transfer(ref self: ComponentState<TContractState>, allow_transfer: bool)

_base_uri

Base URI for computing token_uri.

If set, the resulting URI for each token will be the concatenation of the base URI and the token ID. Returns an empty ByteArray if not set.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_base_uri

fn _base_uri(self: @ComponentState<TContractState>) -> ByteArray

_is_authorized

Returns whether spender is allowed to manage owner’s tokens, or token_id in particular (ignoring whether it is owned by owner).

WARNING: This function assumes that owner is the actual owner of token_id and does not verify this assumption.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_is_authorized

fn _is_authorized(
    self: @ComponentState<TContractState>,
    owner: ContractAddress,
    spender: ContractAddress,
    token_id: u256,
) -> bool

_check_authorized

Checks if spender can operate on token_id, assuming the provided owner is the actual owner.

Requirements:

  • owner cannot be the zero address.
  • spender cannot be the zero address.
  • spender must be the owner of token_id or be approved to operate on it.

WARNING: This function assumes that owner is the actual owner of token_id and does not verify this assumption.

Fully qualified path: tokentable_v2::components::custom_erc721::ERC721Component::InternalTrait::_check_authorized

fn _check_authorized(
    self: @ComponentState<TContractState>,
    owner: ContractAddress,
    spender: ContractAddress,
    token_id: u256,
)