Keyboard shortcuts

Press ← or → to navigate between chapters

Press ? to show this help

Press Esc to hide this help

openzeppelin_token

Fully qualified path: openzeppelin_token

Modules

common—
erc1155—
erc20—
erc721—

Modules

Modules

common—
erc1155—
erc20—
erc721—

common

Fully qualified path: openzeppelin_token::common

Modules

erc2981—

Modules

Modules

erc2981—

erc2981

Fully qualified path: openzeppelin_token::common::erc2981

Modules

erc2981—

Re-exports:

DefaultConfigImplementation of the default ERC2981Component ImmutableConfig. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation The default fee denominator is set to…


Modules

Modules

erc2981—

erc2981

Fully qualified path: openzeppelin_token::common::erc2981::erc2981

Modules

Impls

DefaultConfigImplementation of the default ERC2981Component ImmutableConfig. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation The default fee denominator is set to…

Modules

Modules

ERC2981Component

ERC2981 Component

Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.

Royalty information can be specified globally for all token ids via set_default_royalty, and/or individually for specific token ids via set_token_royalty. The latter takes precedence over the first.

Royalty is specified as a fraction of sale price. The denominator is set by the contract by using the Immutable Component Config pattern. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md

IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-paymentsRationale in the ERC. Marketplaces are expected to voluntarily pay royalties together with sales.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component

Modules

Constants

ROYALTY_ADMIN_ROLERole for the admin responsible for managing royalty settings.
DEFAULT_FEE_DENOMINATOR—

Free functions

Structs

Enums

Event—

Traits

Modules

Modules

Errors

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Errors

Constants

Constants

Constants

INVALID_ROYALTY

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Errors::INVALID_ROYALTY

pub const INVALID_ROYALTY: felt252 = 1699754257840709950168247819197704976323732217030010238073;

INVALID_ROYALTY_RECEIVER

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Errors::INVALID_ROYALTY_RECEIVER

pub const INVALID_ROYALTY_RECEIVER: felt252 =
    435137090007221747243071441714612473938875444720760727692658;

INVALID_FEE_DENOMINATOR

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Errors::INVALID_FEE_DENOMINATOR

pub const INVALID_FEE_DENOMINATOR: felt252 =
    7033339804690827301661156860845027271122137638134640498;

__external_ERC2981Impl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__external_ERC2981Impl

__l1_handler_ERC2981Impl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__l1_handler_ERC2981Impl

__constructor_ERC2981Impl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__constructor_ERC2981Impl

__external_ERC2981InfoImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__external_ERC2981InfoImpl

__l1_handler_ERC2981InfoImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__l1_handler_ERC2981InfoImpl

__constructor_ERC2981InfoImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__constructor_ERC2981InfoImpl

__external_ERC2981AdminOwnableImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__external_ERC2981AdminOwnableImpl

__l1_handler_ERC2981AdminOwnableImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__l1_handler_ERC2981AdminOwnableImpl

__constructor_ERC2981AdminOwnableImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__constructor_ERC2981AdminOwnableImpl

__external_ERC2981AdminAccessControlImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__external_ERC2981AdminAccessControlImpl

__l1_handler_ERC2981AdminAccessControlImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__l1_handler_ERC2981AdminAccessControlImpl

__constructor_ERC2981AdminAccessControlImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__constructor_ERC2981AdminAccessControlImpl

__external_ERC2981AdminAccessControlDefaultAdminRulesImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__external_ERC2981AdminAccessControlDefaultAdminRulesImpl

__l1_handler_ERC2981AdminAccessControlDefaultAdminRulesImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__l1_handler_ERC2981AdminAccessControlDefaultAdminRulesImpl

__constructor_ERC2981AdminAccessControlDefaultAdminRulesImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::__constructor_ERC2981AdminAccessControlDefaultAdminRulesImpl

Constants

Constants

ROYALTY_ADMIN_ROLERole for the admin responsible for managing royalty settings.
DEFAULT_FEE_DENOMINATOR—

ROYALTY_ADMIN_ROLE

Role for the admin responsible for managing royalty settings.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::ROYALTY_ADMIN_ROLE

pub const ROYALTY_ADMIN_ROLE: felt252 =
    770387435133372507257642958672645943185612715122236777234933570164353708049;

DEFAULT_FEE_DENOMINATOR

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::DEFAULT_FEE_DENOMINATOR

pub const DEFAULT_FEE_DENOMINATOR: u128 = 10000;

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

RoyaltyInfo

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::RoyaltyInfo

[derive(Serde, Drop, starknet::Store)]
pub struct RoyaltyInfo {
    pub receiver: ContractAddress,
    pub royalty_fraction: u128,
}

Members

receiver

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::RoyaltyInfo::receiver

pub receiver: ContractAddress

royalty_fraction

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::RoyaltyInfo::royalty_fraction

pub royalty_fraction: u128

Storage

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Storage

[storage]
pub struct Storage {
    pub ERC2981_default_royalty_info: RoyaltyInfo,
    pub ERC2981_token_royalty_info: Map<u256, RoyaltyInfo>,
}

Members

ERC2981_default_royalty_info

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Storage::ERC2981_default_royalty_info

pub ERC2981_default_royalty_info: RoyaltyInfo

ERC2981_token_royalty_info

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Storage::ERC2981_token_royalty_info

pub ERC2981_token_royalty_info: Map<u256, RoyaltyInfo>

ComponentState

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Event

pub enum Event {}

Traits

Traits

ImmutableConfig

Constants expected to be defined at the contract level used to configure the component behavior.

  • FEE_DENOMINATOR: The denominator with which to interpret the fee set in _set_token_royalty and _set_default_royalty as a fraction of the sale price.

Requirements:

  • FEE_DENOMINATOR must be greater than 0.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::ImmutableConfig

pub trait ImmutableConfig

Trait constants

FEE_DENOMINATOR

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::ImmutableConfig::FEE_DENOMINATOR

const FEE_DENOMINATOR: u128;

Trait functions

validate

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::ImmutableConfig::validate

fn validate()

HasComponent

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::HasComponent::emit

fn emit<
    S, impl IntoImp: Into<S, openzeppelin_token::common::erc2981::erc2981::ERC2981Component::Event>,
>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait

pub trait InternalTrait<
    TContractState,
    +HasComponent<TContractState>,
    impl Immutable: ImmutableConfig,
    impl SRC5: HasComponent<TContractState>,
    +Drop<TContractState>,
>

Trait functions

initializer

Initializes the contract by setting the default royalty.

Requirements:

  • default_receiver cannot be the zero address.
  • default_royalty_fraction cannot be greater than the fee denominator.
  • The fee denominator must be greater than 0.

NOTE: The fee denominator is set by the contract using the Immutable Component Config.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::initializer

fn initializer(
    ref self: ComponentState<TContractState>,
    default_receiver: ContractAddress,
    default_royalty_fraction: u128,
)

_default_royalty

Returns the royalty information that all ids in this contract will default to.

The returned tuple contains:

  • t.0: The receiver of the royalty payment.
  • t.1: The numerator of the royalty fraction.
  • t.2: The denominator of the royalty fraction.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::_default_royalty

fn _default_royalty(self: @ComponentState<TContractState>) -> (ContractAddress, u128, u128)

_set_default_royalty

Sets the royalty information that all ids in this contract will default to.

Requirements:

  • receiver cannot be the zero address.
  • fee_numerator cannot be greater than the fee denominator.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::_set_default_royalty

fn _set_default_royalty(
    ref self: ComponentState<TContractState>, receiver: ContractAddress, fee_numerator: u128,
)

_delete_default_royalty

Sets the default royalty percentage and receiver to zero.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::_delete_default_royalty

fn _delete_default_royalty(ref self: ComponentState<TContractState>)

_token_royalty

Returns the royalty information specific to a token. If no specific royalty information is set for the token, the default is returned.

The returned tuple contains:

  • t.0: The receiver of the royalty payment.
  • t.1: The numerator of the royalty fraction.
  • t.2: The denominator of the royalty fraction.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::_token_royalty

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

_set_token_royalty

Sets the royalty information for a specific token id that takes precedence over the global default.

Requirements:

  • receiver cannot be the zero address.
  • fee_numerator cannot be greater than the fee denominator.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::_set_token_royalty

fn _set_token_royalty(
    ref self: ComponentState<TContractState>,
    token_id: u256,
    receiver: ContractAddress,
    fee_numerator: u128,
)

_reset_token_royalty

Resets royalty information for the token id back to unset.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::InternalTrait::_reset_token_royalty

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

UnsafeNewContractStateTraitForERC2981Impl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981Impl

pub trait UnsafeNewContractStateTraitForERC2981Impl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981Impl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC2981InfoImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981InfoImpl

pub trait UnsafeNewContractStateTraitForERC2981InfoImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981InfoImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC2981AdminOwnableImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981AdminOwnableImpl

pub trait UnsafeNewContractStateTraitForERC2981AdminOwnableImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981AdminOwnableImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC2981AdminAccessControlImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981AdminAccessControlImpl

pub trait UnsafeNewContractStateTraitForERC2981AdminAccessControlImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981AdminAccessControlImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC2981AdminAccessControlDefaultAdminRulesImpl

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981AdminAccessControlDefaultAdminRulesImpl

pub trait UnsafeNewContractStateTraitForERC2981AdminAccessControlDefaultAdminRulesImpl<
    TContractState,
>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::ERC2981Component::UnsafeNewContractStateTraitForERC2981AdminAccessControlDefaultAdminRulesImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

Impls

Impls

DefaultConfigImplementation of the default ERC2981Component ImmutableConfig. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation The default fee denominator is set to…

DefaultConfig

Implementation of the default ERC2981Component ImmutableConfig.

See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation

The default fee denominator is set to DEFAULT_FEE_DENOMINATOR.

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::DefaultConfig

pub impl DefaultConfig of ImmutableConfig;

Impl constants

FEE_DENOMINATOR

Fully qualified path: openzeppelin_token::common::erc2981::erc2981::DefaultConfig::FEE_DENOMINATOR

const FEE_DENOMINATOR: u128 = ERC2981Component::DEFAULT_FEE_DENOMINATOR;

erc1155

Fully qualified path: openzeppelin_token::erc1155

Modules


Re-exports:

ERC1155HooksEmptyImplAn empty implementation of the ERC1155 hooks to be used in basic ERC1155 preset contracts.


Modules

Modules

erc1155

Fully qualified path: openzeppelin_token::erc1155::erc1155

Modules

Impls

ERC1155HooksEmptyImplAn empty implementation of the ERC1155 hooks to be used in basic ERC1155 preset contracts.

Modules

Modules

ERC1155Component

ERC1155 Component

The ERC1155 component provides an implementation of the basic standard multi-token. See https://eips.ethereum.org/EIPS/eip-1155.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component

Modules

Free functions

Structs

Storage—
TransferSingleEmitted when value token is transferred from from to to for id .
TransferBatchEmitted when values are transferred from from to to for ids .
ApprovalForAllEmitted when account enables or disables ( approved ) operator to manage all of its assets.
URIEmitted when the URI for token type id changes to value , if it is a non-programmatic URI. If an URI event was emitted for id , the standard guarantees that value will equal the…
ComponentState—

Enums

Event—

Traits

Modules

Modules

Errors

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors

Constants

Constants

Constants

UNAUTHORIZED

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::UNAUTHORIZED

pub const UNAUTHORIZED: felt252 =
    478438289715301829996768881402087393226436157487501112331320631571541874;

SELF_APPROVAL

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::SELF_APPROVAL

pub const SELF_APPROVAL: felt252 = 25936191655478970838689484552120815602561389442785644;

INVALID_RECEIVER

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::INVALID_RECEIVER

pub const INVALID_RECEIVER: felt252 = 435137089621368277218381393912759544813016424183403967309170;

INVALID_SENDER

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::INVALID_SENDER

pub const INVALID_SENDER: felt252 = 6639665063802616534704305937389519421585334720658695538;

INVALID_ARRAY_LENGTH

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::INVALID_ARRAY_LENGTH

pub const INVALID_ARRAY_LENGTH: felt252 =
    478438289715301829996758655148673609610493128314849328529588103118550120;

INSUFFICIENT_BALANCE

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::INSUFFICIENT_BALANCE

pub const INSUFFICIENT_BALANCE: felt252 =
    1868899569200397773424809936655656520788742270802102168023995413062501;

SAFE_TRANSFER_FAILED

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Errors::SAFE_TRANSFER_FAILED

pub const SAFE_TRANSFER_FAILED: felt252 =
    1868899569200397773424866735515679970217101410251298792678887764288868;

__external_ERC1155Impl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__external_ERC1155Impl

__l1_handler_ERC1155Impl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__l1_handler_ERC1155Impl

__constructor_ERC1155Impl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__constructor_ERC1155Impl

__external_ERC1155MetadataURIImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__external_ERC1155MetadataURIImpl

__l1_handler_ERC1155MetadataURIImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__l1_handler_ERC1155MetadataURIImpl

__constructor_ERC1155MetadataURIImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__constructor_ERC1155MetadataURIImpl

__external_ERC1155CamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__external_ERC1155CamelImpl

__l1_handler_ERC1155CamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__l1_handler_ERC1155CamelImpl

__constructor_ERC1155CamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__constructor_ERC1155CamelImpl

__external_ERC1155MixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__external_ERC1155MixinImpl

__l1_handler_ERC1155MixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__l1_handler_ERC1155MixinImpl

__constructor_ERC1155MixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::__constructor_ERC1155MixinImpl

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage—
TransferSingleEmitted when value token is transferred from from to to for id .
TransferBatchEmitted when values are transferred from from to to for ids .
ApprovalForAllEmitted when account enables or disables ( approved ) operator to manage all of its assets.
URIEmitted when the URI for token type id changes to value , if it is a non-programmatic URI. If an URI event was emitted for id , the standard guarantees that value will equal the…
ComponentState—

Storage

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Storage

[storage]
pub struct Storage {
    pub ERC1155_balances: Map<(u256, ContractAddress), u256>,
    pub ERC1155_operator_approvals: Map<(ContractAddress, ContractAddress), bool>,
    pub ERC1155_uri: ByteArray,
}

Members

ERC1155_balances

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Storage::ERC1155_balances

pub ERC1155_balances: Map<(u256, ContractAddress), u256>

ERC1155_operator_approvals

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Storage::ERC1155_operator_approvals

pub ERC1155_operator_approvals: Map<(ContractAddress, ContractAddress), bool>

ERC1155_uri

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Storage::ERC1155_uri

pub ERC1155_uri: ByteArray

TransferSingle

Emitted when value token is transferred from from to to for id.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct TransferSingle {
    pub operator: ContractAddress,
    pub from: ContractAddress,
    pub to: ContractAddress,
    pub id: u256,
    pub value: u256,
}

Members

operator

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle::operator

pub operator: ContractAddress

from

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle::from

pub from: ContractAddress

to

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle::to

pub to: ContractAddress

id

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle::id

pub id: u256

value

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferSingle::value

pub value: u256

TransferBatch

Emitted when values are transferred from from to to for ids.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct TransferBatch {
    pub operator: ContractAddress,
    pub from: ContractAddress,
    pub to: ContractAddress,
    pub ids: Span<u256>,
    pub values: Span<u256>,
}

Members

operator

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch::operator

pub operator: ContractAddress

from

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch::from

pub from: ContractAddress

to

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch::to

pub to: ContractAddress

ids

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch::ids

pub ids: Span<u256>

values

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::TransferBatch::values

pub values: Span<u256>

ApprovalForAll

Emitted when account enables or disables (approved) operator to manage all of its assets.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ApprovalForAll

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct ApprovalForAll {
    pub owner: ContractAddress,
    pub operator: ContractAddress,
    pub approved: bool,
}

Members

owner

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ApprovalForAll::owner

pub owner: ContractAddress

operator

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ApprovalForAll::operator

pub operator: ContractAddress

approved

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ApprovalForAll::approved

pub approved: bool

URI

Emitted when the URI for token type id changes to value, if it is a non-programmatic URI.

If an URI event was emitted for id, the standard guarantees that value will equal the value returned by IERC1155MetadataURI::uri. https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::URI

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct URI {
    pub value: ByteArray,
    pub id: u256,
}

Members

value

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::URI::value

pub value: ByteArray

id

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::URI::id

pub id: u256

ComponentState

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Event

pub enum Event {
    TransferSingle: TransferSingle,
    TransferBatch: TransferBatch,
    ApprovalForAll: ApprovalForAll,
    URI: URI,
}

Variants

TransferSingle

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Event::TransferSingle

TransferSingle: TransferSingle

TransferBatch

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Event::TransferBatch

TransferBatch: TransferBatch

ApprovalForAll

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Event::ApprovalForAll

ApprovalForAll: ApprovalForAll

URI

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::Event::URI

URI: URI

Traits

Traits

ERC1155HooksTrait

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ERC1155HooksTrait

pub trait ERC1155HooksTrait<TContractState>

Trait functions

before_update

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ERC1155HooksTrait::before_update

fn before_update(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    token_ids: Span<u256>,
    values: Span<u256>,
)

after_update

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::ERC1155HooksTrait::after_update

fn after_update(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    token_ids: Span<u256>,
    values: Span<u256>,
)

HasComponent

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::HasComponent::emit

fn emit<S, impl IntoImp: Into<S, openzeppelin_token::erc1155::erc1155::ERC1155Component::Event>>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait

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

Trait functions

initializer

Initializes the contract by setting the base_uri for all tokens, and registering the supported interfaces. This should only be used inside the contract’s constructor.

WARNING: Most ERC1155 contracts expose the IERC1155MetadataURI interface which is what this initializer is meant to support. If the contract DOES NOT expose the IERC1155MetadataURI interface, meaning the token does not have a URI, the contract must instead use initializer_no_metadata in the constructor. Failure to abide by these instructions can lead to unexpected issues especially with UIs.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::initializer

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

initializer_no_metadata

Initializes the contract with no metadata by registering only the IERC1155 interface.

WARNING: This initializer should ONLY be used during construction in the very specific instance when the contract does NOT expose the IERC1155MetadataURI interface. Initializing a contract with this initializer means that tokens will not have a URI.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::initializer_no_metadata

fn initializer_no_metadata(ref self: ComponentState<TContractState>)

mint_with_acceptance_check

Creates a value amount of tokens of type token_id, and assigns them to to.

Requirements:

  • to cannot be the zero address.
  • If to refers to a smart contract, it must implement IERC1155Receiver::on_ERC1155_received and return the acceptance magic value.

Emits a TransferSingle event.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::mint_with_acceptance_check

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

batch_mint_with_acceptance_check

Batched version of mint_with_acceptance_check.

Requirements:

  • to cannot be the zero address.
  • token_ids and values must have the same length.
  • If to refers to a smart contract, it must implement IERC1155Receiver::on_ERC1155_batch_received and return the acceptance magic value.

Emits a TransferBatch event.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::batch_mint_with_acceptance_check

fn batch_mint_with_acceptance_check(
    ref self: ComponentState<TContractState>,
    to: ContractAddress,
    token_ids: Span<u256>,
    values: Span<u256>,
    data: Span<felt252>,
)

burn

Destroys a value amount of tokens of type token_id from from.

Requirements:

  • from cannot be the zero address.
  • from must have at least value amount of tokens of type token_id.

Emits a TransferSingle event.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::burn

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

batch_burn

Batched version of burn.

Requirements:

  • from cannot be the zero address.
  • from must have at least value amount of tokens of type token_id.
  • token_ids and values must have the same length.

Emits a TransferBatch event.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::batch_burn

fn batch_burn(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    token_ids: Span<u256>,
    values: Span<u256>,
)

update_with_acceptance_check

Version of update that performs the token acceptance check by calling IERC1155Receiver::onERC1155Received or IERC1155Receiver::onERC1155BatchReceived if the receiver is not recognized as an account.

Requirements:

  • to is either an account contract or supports the IERC1155Receiver interface.
  • token_ids and values must have the same length.

Emits a TransferSingle event if the arrays contain one element, and TransferBatch otherwise.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::update_with_acceptance_check

fn update_with_acceptance_check(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    token_ids: Span<u256>,
    values: Span<u256>,
    data: Span<felt252>,
)

update

Transfers a value amount of tokens of type id from from to to. Will mint (or burn) if from (or to) is the zero address.

Requirements:

  • token_ids and values must have the same length.

Emits a TransferSingle event if the arrays contain one element, and TransferBatch otherwise.

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

NOTE: The ERC1155 acceptance check is not performed in this function. See update_with_acceptance_check instead.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::update

fn update(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    token_ids: Span<u256>,
    values: Span<u256>,
)

_set_base_uri

Sets a new URI for all token types, by relying on the token type ID substitution mechanism defined in the ERC1155 standard. See https://eips.ethereum.org/EIPS/eip-1155#metadata.

By this mechanism, any occurrence of the \{id\} substring in either the URI or any of the values in the JSON file at said URI will be replaced by clients with the token type ID.

For example, the https://token-cdn-domain/\{id\}.json URI would be interpreted by clients as https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json for token type ID 0x4cce0.

Because these URIs cannot be meaningfully represented by the URI event, this function emits no events.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::InternalTrait::_set_base_uri

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

UnsafeNewContractStateTraitForERC1155Impl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155Impl

pub trait UnsafeNewContractStateTraitForERC1155Impl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155Impl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC1155MetadataURIImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155MetadataURIImpl

pub trait UnsafeNewContractStateTraitForERC1155MetadataURIImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155MetadataURIImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC1155CamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155CamelImpl

pub trait UnsafeNewContractStateTraitForERC1155CamelImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155CamelImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC1155MixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155MixinImpl

pub trait UnsafeNewContractStateTraitForERC1155MixinImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155Component::UnsafeNewContractStateTraitForERC1155MixinImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

Impls

Impls

ERC1155HooksEmptyImplAn empty implementation of the ERC1155 hooks to be used in basic ERC1155 preset contracts.

ERC1155HooksEmptyImpl

An empty implementation of the ERC1155 hooks to be used in basic ERC1155 preset contracts.

Fully qualified path: openzeppelin_token::erc1155::erc1155::ERC1155HooksEmptyImpl

pub impl ERC1155HooksEmptyImpl<TContractState> of ERC1155HooksTrait<TContractState>;

erc1155_receiver

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver

Modules

Modules

Modules

ERC1155ReceiverComponent

ERC1155Receiver Component

The ERC1155Receiver component provides implementations for the IERC1155Receiver interface. Integrating this component allows contracts to support ERC1155 safe transfers.

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent

Modules

Free functions

Structs

Enums

Event—

Traits

Modules

Modules

__external_ERC1155ReceiverImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__external_ERC1155ReceiverImpl

__l1_handler_ERC1155ReceiverImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__l1_handler_ERC1155ReceiverImpl

__constructor_ERC1155ReceiverImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__constructor_ERC1155ReceiverImpl

__external_ERC1155ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__external_ERC1155ReceiverCamelImpl

__l1_handler_ERC1155ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__l1_handler_ERC1155ReceiverCamelImpl

__constructor_ERC1155ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__constructor_ERC1155ReceiverCamelImpl

__external_ERC1155ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__external_ERC1155ReceiverMixinImpl

__l1_handler_ERC1155ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__l1_handler_ERC1155ReceiverMixinImpl

__constructor_ERC1155ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::__constructor_ERC1155ReceiverMixinImpl

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::Storage

[storage]
pub struct Storage {}

ComponentState

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::Event

pub enum Event {}

Traits

Traits

HasComponent

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::HasComponent::emit

fn emit<
    S,
    impl IntoImp: Into<
        S, openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::Event,
    >,
>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::InternalTrait

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

Trait functions

initializer

Initializes the contract by registering the IERC1155Receiver interface ID. This should be used inside the contract’s constructor.

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::InternalTrait::initializer

fn initializer(ref self: ComponentState<TContractState>)

UnsafeNewContractStateTraitForERC1155ReceiverImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::UnsafeNewContractStateTraitForERC1155ReceiverImpl

pub trait UnsafeNewContractStateTraitForERC1155ReceiverImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::UnsafeNewContractStateTraitForERC1155ReceiverImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC1155ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::UnsafeNewContractStateTraitForERC1155ReceiverCamelImpl

pub trait UnsafeNewContractStateTraitForERC1155ReceiverCamelImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::UnsafeNewContractStateTraitForERC1155ReceiverCamelImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC1155ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::UnsafeNewContractStateTraitForERC1155ReceiverMixinImpl

pub trait UnsafeNewContractStateTraitForERC1155ReceiverMixinImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc1155::erc1155_receiver::ERC1155ReceiverComponent::UnsafeNewContractStateTraitForERC1155ReceiverMixinImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

erc20

Fully qualified path: openzeppelin_token::erc20

Modules


Re-exports:

DefaultConfigImplementation of the default ERC20Component ImmutableConfig. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation The default decimals is set to…
ERC20HooksEmptyImplAn empty implementation of the ERC20 hooks to be used in basic ERC20 preset contracts.


Modules

Modules

erc20

Fully qualified path: openzeppelin_token::erc20::erc20

Modules

Impls

DefaultConfigImplementation of the default ERC20Component ImmutableConfig. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation The default decimals is set to…
ERC20HooksEmptyImplAn empty implementation of the ERC20 hooks to be used in basic ERC20 preset contracts.

Modules

Modules

ERC20Component

ERC20 Component

The ERC20 component provides an implementation of the IERC20 interface as well as non-standard implementations that can be used to create an ERC20 contract. This component is agnostic regarding how tokens are created, which means that developers must create their own token distribution mechanism. See the documentation (https://docs.openzeppelin.com/contracts-cairo/3.0.0/guides/erc20-supply) for examples.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component

Modules

Constants

Free functions

Structs

Storage—
TransferEmitted when tokens are moved from address from to address to .
ApprovalEmitted when the allowance of a spender for an owner is set by a call to approve . value is the new allowance.
ComponentState—

Enums

Event—

Traits

Modules

Modules

Errors

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors

Constants

Constants

Constants

APPROVE_FROM_ZERO

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::APPROVE_FROM_ZERO

pub const APPROVE_FROM_ZERO: felt252 = 101313248740993271302566317381896466254801065025584;

APPROVE_TO_ZERO

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::APPROVE_TO_ZERO

pub const APPROVE_TO_ZERO: felt252 = 1545917491775410023537694051847785435030822960;

TRANSFER_FROM_ZERO

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::TRANSFER_FROM_ZERO

pub const TRANSFER_FROM_ZERO: felt252 = 25936191677694277552149992725516921697451103245639728;

TRANSFER_TO_ZERO

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::TRANSFER_TO_ZERO

pub const TRANSFER_TO_ZERO: felt252 = 395754877894504967531585582359572169455970492464;

BURN_FROM_ZERO

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::BURN_FROM_ZERO

pub const BURN_FROM_ZERO: felt252 = 6038740202247695405676691625063102337065008;

MINT_TO_ZERO

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::MINT_TO_ZERO

pub const MINT_TO_ZERO: felt252 = 92143862949336172774019376959445737520;

INSUFFICIENT_BALANCE

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::INSUFFICIENT_BALANCE

pub const INSUFFICIENT_BALANCE: felt252 =
    28517144329851979398958244156126768237078601998068993600170910565;

INSUFFICIENT_ALLOWANCE

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::INSUFFICIENT_ALLOWANCE

pub const INSUFFICIENT_ALLOWANCE: felt252 =
    1868899570801179321890127489015923883185183260545431910485693286998885;

EXPIRED_PERMIT_SIGNATURE

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::EXPIRED_PERMIT_SIGNATURE

pub const EXPIRED_PERMIT_SIGNATURE: felt252 =
    122480202272026087942268350314979893259331706174981672776230904878641541733;

INVALID_PERMIT_SIGNATURE

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Errors::INVALID_PERMIT_SIGNATURE

pub const INVALID_PERMIT_SIGNATURE: felt252 =
    122480202272026088039392488357692699633302049598224187374825241184790999653;

__external_ERC20Impl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__external_ERC20Impl

__l1_handler_ERC20Impl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__l1_handler_ERC20Impl

__constructor_ERC20Impl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__constructor_ERC20Impl

__external_ERC20MetadataImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__external_ERC20MetadataImpl

__l1_handler_ERC20MetadataImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__l1_handler_ERC20MetadataImpl

__constructor_ERC20MetadataImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__constructor_ERC20MetadataImpl

__external_ERC20CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__external_ERC20CamelOnlyImpl

__l1_handler_ERC20CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__l1_handler_ERC20CamelOnlyImpl

__constructor_ERC20CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__constructor_ERC20CamelOnlyImpl

__external_ERC20MixinImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__external_ERC20MixinImpl

__l1_handler_ERC20MixinImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__l1_handler_ERC20MixinImpl

__constructor_ERC20MixinImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__constructor_ERC20MixinImpl

__external_ERC20PermitImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__external_ERC20PermitImpl

__l1_handler_ERC20PermitImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__l1_handler_ERC20PermitImpl

__constructor_ERC20PermitImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__constructor_ERC20PermitImpl

__external_SNIP12MetadataExternalImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__external_SNIP12MetadataExternalImpl

__l1_handler_SNIP12MetadataExternalImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__l1_handler_SNIP12MetadataExternalImpl

__constructor_SNIP12MetadataExternalImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::__constructor_SNIP12MetadataExternalImpl

Constants

Constants

DEFAULT_DECIMALS

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::DEFAULT_DECIMALS

pub const DEFAULT_DECIMALS: u8 = 18;

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage—
TransferEmitted when tokens are moved from address from to address to .
ApprovalEmitted when the allowance of a spender for an owner is set by a call to approve . value is the new allowance.
ComponentState—

Storage

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Storage

[storage]
pub struct Storage {
    pub ERC20_name: ByteArray,
    pub ERC20_symbol: ByteArray,
    pub ERC20_total_supply: u256,
    pub ERC20_balances: Map<ContractAddress, u256>,
    pub ERC20_allowances: Map<(ContractAddress, ContractAddress), u256>,
}

Members

ERC20_name

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Storage::ERC20_name

pub ERC20_name: ByteArray

ERC20_symbol

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Storage::ERC20_symbol

pub ERC20_symbol: ByteArray

ERC20_total_supply

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Storage::ERC20_total_supply

pub ERC20_total_supply: u256

ERC20_balances

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Storage::ERC20_balances

pub ERC20_balances: Map<ContractAddress, u256>

ERC20_allowances

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Storage::ERC20_allowances

pub ERC20_allowances: Map<(ContractAddress, ContractAddress), u256>

Transfer

Emitted when tokens are moved from address from to address to.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Transfer

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct Transfer {
    pub from: ContractAddress,
    pub to: ContractAddress,
    pub value: u256,
}

Members

from

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Transfer::from

pub from: ContractAddress

to

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Transfer::to

pub to: ContractAddress

value

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Transfer::value

pub value: u256

Approval

Emitted when the allowance of a spender for an owner is set by a call to approve. value is the new allowance.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Approval

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct Approval {
    pub owner: ContractAddress,
    pub spender: ContractAddress,
    pub value: u256,
}

Members

owner

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Approval::owner

pub owner: ContractAddress

spender

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Approval::spender

pub spender: ContractAddress

value

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Approval::value

pub value: u256

ComponentState

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Event

pub enum Event {
    Transfer: Transfer,
    Approval: Approval,
}

Variants

Transfer

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Event::Transfer

Transfer: Transfer

Approval

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::Event::Approval

Approval: Approval

Traits

Traits

ImmutableConfig

Constants expected to be defined at the contract level used to configure the component behavior.

  • DECIMALS: Returns the number of decimals the token uses.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::ImmutableConfig

pub trait ImmutableConfig

Trait constants

DECIMALS

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::ImmutableConfig::DECIMALS

const DECIMALS: u8;

ERC20HooksTrait

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::ERC20HooksTrait

pub trait ERC20HooksTrait<TContractState>

Trait functions

before_update

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::ERC20HooksTrait::before_update

fn before_update(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    recipient: ContractAddress,
    amount: u256,
)

after_update

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::ERC20HooksTrait::after_update

fn after_update(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    recipient: ContractAddress,
    amount: u256,
)

HasComponent

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::HasComponent::emit

fn emit<S, impl IntoImp: Into<S, openzeppelin_token::erc20::erc20::ERC20Component::Event>>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait

pub trait InternalTrait<
    TContractState, +HasComponent<TContractState>, impl Hooks: ERC20HooksTrait<TContractState>,
>

Trait functions

initializer

Initializes the contract by setting the token name and symbol. To prevent reinitialization, this should only be used inside of a contract’s constructor.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::initializer

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

mint

Creates a value amount of tokens and assigns them to account.

Requirements:

  • recipient is not the zero address.

Emits a Transfer event with from set to the zero address.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::mint

fn mint(ref self: ComponentState<TContractState>, recipient: ContractAddress, amount: u256)

burn

Destroys amount of tokens from account.

Requirements:

  • account is not the zero address.
  • account must have at least a balance of amount.

Emits a Transfer event with to set to the zero address.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::burn

fn burn(ref self: ComponentState<TContractState>, account: ContractAddress, amount: u256)

update

Transfers an amount of tokens from from to to, or alternatively mints (or burns) if from (or to) is the zero address.

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

Emits a Transfer event.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::update

fn update(
    ref self: ComponentState<TContractState>,
    from: ContractAddress,
    to: ContractAddress,
    amount: u256,
)

_transfer

Internal method that moves an amount of tokens from from to to.

Requirements:

  • sender is not the zero address.
  • sender must have at least a balance of amount.
  • recipient is not the zero address.

Emits a Transfer event.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::_transfer

fn _transfer(
    ref self: ComponentState<TContractState>,
    sender: ContractAddress,
    recipient: ContractAddress,
    amount: u256,
)

_approve

Internal method that sets amount as the allowance of spender over the owners tokens.

Requirements:

  • owner is not the zero address.
  • spender is not the zero address.

Emits an Approval event.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::_approve

fn _approve(
    ref self: ComponentState<TContractState>,
    owner: ContractAddress,
    spender: ContractAddress,
    amount: u256,
)

_spend_allowance

Updates owners allowance for spender based on spent amount. Does not update the allowance value in case of infinite allowance.

Requirements:

  • spender must have at least an allowance of amount from owner.

Possibly emits an Approval event.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::InternalTrait::_spend_allowance

fn _spend_allowance(
    ref self: ComponentState<TContractState>,
    owner: ContractAddress,
    spender: ContractAddress,
    amount: u256,
)

UnsafeNewContractStateTraitForERC20Impl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20Impl

pub trait UnsafeNewContractStateTraitForERC20Impl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20Impl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC20MetadataImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20MetadataImpl

pub trait UnsafeNewContractStateTraitForERC20MetadataImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20MetadataImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC20CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20CamelOnlyImpl

pub trait UnsafeNewContractStateTraitForERC20CamelOnlyImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20CamelOnlyImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC20MixinImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20MixinImpl

pub trait UnsafeNewContractStateTraitForERC20MixinImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20MixinImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC20PermitImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20PermitImpl

pub trait UnsafeNewContractStateTraitForERC20PermitImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForERC20PermitImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForSNIP12MetadataExternalImpl

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForSNIP12MetadataExternalImpl

pub trait UnsafeNewContractStateTraitForSNIP12MetadataExternalImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20Component::UnsafeNewContractStateTraitForSNIP12MetadataExternalImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

Impls

Impls

DefaultConfigImplementation of the default ERC20Component ImmutableConfig. See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation The default decimals is set to…
ERC20HooksEmptyImplAn empty implementation of the ERC20 hooks to be used in basic ERC20 preset contracts.

DefaultConfig

Implementation of the default ERC20Component ImmutableConfig.

See https://github.com/starknet-io/SNIPs/blob/main/SNIPS/snip-107.md#defaultconfig-implementation

The default decimals is set to DEFAULT_DECIMALS.

Fully qualified path: openzeppelin_token::erc20::erc20::DefaultConfig

pub impl DefaultConfig of ImmutableConfig;

Impl constants

DECIMALS

Fully qualified path: openzeppelin_token::erc20::erc20::DefaultConfig::DECIMALS

const DECIMALS: u8 = ERC20Component::DEFAULT_DECIMALS;

ERC20HooksEmptyImpl

An empty implementation of the ERC20 hooks to be used in basic ERC20 preset contracts.

Fully qualified path: openzeppelin_token::erc20::erc20::ERC20HooksEmptyImpl

pub impl ERC20HooksEmptyImpl<TContractState> of ERC20HooksTrait<TContractState>;

extensions

Fully qualified path: openzeppelin_token::erc20::extensions

Modules

erc4626—

Modules

Modules

erc4626—

erc4626

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626

Modules

erc4626—

Re-exports:

DefaultConfigImplementation of the default ERC4626Component::ImmutableConfig . See…
ERC4626DefaultNoFees—
ERC4626DefaultNoLimits—
ERC4626EmptyHooks—
ERC4626SelfAssetsManagement—


Modules

Modules

erc4626—

erc4626

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626

Modules

Impls

DefaultConfigImplementation of the default ERC4626Component::ImmutableConfig . See…
ERC4626DefaultNoFees—
ERC4626DefaultNoLimits—
ERC4626EmptyHooks—
ERC4626SelfAssetsManagement—

Modules

Modules

ERC4626Component

ERC4626 Component

The ERC4626 component is an extension of ERC20 and provides an implementation of the IERC4626 interface which allows the minting and burning of “shares” in exchange for an underlying “asset”. The component leverages traits to configure fees, limits, and decimals.

CAUTION: In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning with a “donation” to the vault that inflates the price of a share. This is variously known as a donation or inflation attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by verifying the amount received is as expected, using a wrapper that performs these checks.

This implementation offers configurable virtual assets and shares to help developers mitigate that risk. ImmutableConfig::DECIMALS_OFFSET corresponds to an offset in the decimal representation between the underlying asset’s decimals and vault decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset (0) makes it non-profitable even if an attacker is able to capture value from multiple user deposits, as a result of the value being captured by the virtual shares (out of the attacker’s donation) matching the attacker’s expected gains. With a larger offset, the attack becomes orders of magnitude more expensive than it is profitable.

The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued to the vault. Also, if the vault experiences losses and users try to exit the vault, the virtual shares and assets will cause the first exiting user to experience reduced losses to the detriment to the last users who will experience bigger losses.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component

Modules

Constants

Free functions

Structs

Storage—
DepositEmitted when sender exchanges assets for shares and transfers those shares to owner .
WithdrawEmitted when sender exchanges shares , owned by owner , for assets and transfers those assets to receiver .
PreviewInternal helper struct containing assets, shares, and fees calculated in preview functions.
ComponentState—

Enums

Event—
FeeA fee amount represented either in underlying assets or in shares.

Traits

ImmutableConfigConstants expected to be defined at the contract level which configure virtual assets and shares. UNDERLYING_DECIMALS should match the underlying asset’s decimals. The default value is 18 ….
FeeConfigTraitThe logic for calculating entry and exit fees is expected to be defined at the contract level. Defaults to no entry or exit fees….
LimitConfigTraitSets limits to the target exchange type and is expected to be defined at the contract level. It’s important to note that these limits correspond directly to the max_<OPERATION> i.e. deposit_limit…
ERC4626HooksTraitAllows contracts to hook logic into deposit and withdraw transactions. This is where contracts can transfer fees. NOTE: ERC4626 preview methods must be inclusive of any entry or exit fees….
AssetsManagementTraitDefines how the ERC4626 vault manages its underlying assets. This trait provides the core asset management functionality for the vault, abstracting the actual storage and transfer mechanisms….
HasComponent—
InternalTrait—
UnsafeNewContractStateTraitForERC4626Impl—
UnsafeNewContractStateTraitForERC4626MetadataImpl—

Modules

Modules

Errors

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors

Constants

Constants

Constants

EXCEEDED_MAX_DEPOSIT

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::EXCEEDED_MAX_DEPOSIT

pub const EXCEEDED_MAX_DEPOSIT: felt252 =
    7300388961142671683100395680463673630553974429045141526829168028020;

EXCEEDED_MAX_MINT

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::EXCEEDED_MAX_MINT

pub const EXCEEDED_MAX_MINT: felt252 = 435137090751091938203596811322192766103385354819604400664180;

EXCEEDED_MAX_WITHDRAW

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::EXCEEDED_MAX_WITHDRAW

pub const EXCEEDED_MAX_WITHDRAW: felt252 =
    1868899574052523950873701294198700449421817453835557601092821373313399;

EXCEEDED_MAX_REDEEM

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::EXCEEDED_MAX_REDEEM

pub const EXCEEDED_MAX_REDEEM: felt252 =
    28517144379463561262110920626811225119351462613457599482137240941;

TOKEN_TRANSFER_FAILED

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::TOKEN_TRANSFER_FAILED

pub const TOKEN_TRANSFER_FAILED: felt252 =
    478438290957446131423689402636919274930100673285950975284941460263953764;

INVALID_ASSET_ADDRESS

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::INVALID_ASSET_ADDRESS

pub const INVALID_ASSET_ADDRESS: felt252 =
    122480202485106209644457384222766355008901646292153041647981631433096503344;

DECIMALS_OVERFLOW

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Errors::DECIMALS_OVERFLOW

pub const DECIMALS_OVERFLOW: felt252 =
    111395095232279536180120418160864269797789349909039835656253303;

__external_ERC4626Impl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::__external_ERC4626Impl

__l1_handler_ERC4626Impl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::__l1_handler_ERC4626Impl

__constructor_ERC4626Impl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::__constructor_ERC4626Impl

__external_ERC4626MetadataImpl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::__external_ERC4626MetadataImpl

__l1_handler_ERC4626MetadataImpl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::__l1_handler_ERC4626MetadataImpl

__constructor_ERC4626MetadataImpl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::__constructor_ERC4626MetadataImpl

Constants

Constants

DEFAULT_UNDERLYING_DECIMALS

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::DEFAULT_UNDERLYING_DECIMALS

pub const DEFAULT_UNDERLYING_DECIMALS: u8 = 18;

DEFAULT_DECIMALS_OFFSET

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::DEFAULT_DECIMALS_OFFSET

pub const DEFAULT_DECIMALS_OFFSET: u8 = 0;

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage—
DepositEmitted when sender exchanges assets for shares and transfers those shares to owner .
WithdrawEmitted when sender exchanges shares , owned by owner , for assets and transfers those assets to receiver .
PreviewInternal helper struct containing assets, shares, and fees calculated in preview functions.
ComponentState—

Storage

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Storage

[storage]
pub struct Storage {
    pub ERC4626_asset: ContractAddress,
}

Members

ERC4626_asset

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Storage::ERC4626_asset

pub ERC4626_asset: ContractAddress

Deposit

Emitted when sender exchanges assets for shares and transfers those shares to owner.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Deposit

[derive(Drop, PartialEq, starknet::Event)]
pub struct Deposit {
    pub sender: ContractAddress,
    pub owner: ContractAddress,
    pub assets: u256,
    pub shares: u256,
}

Members

sender

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Deposit::sender

pub sender: ContractAddress

owner

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Deposit::owner

pub owner: ContractAddress

assets

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Deposit::assets

pub assets: u256

shares

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Deposit::shares

pub shares: u256

Withdraw

Emitted when sender exchanges shares, owned by owner, for assets and transfers those assets to receiver.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Withdraw

[derive(Drop, PartialEq, starknet::Event)]
pub struct Withdraw {
    pub sender: ContractAddress,
    pub receiver: ContractAddress,
    pub owner: ContractAddress,
    pub assets: u256,
    pub shares: u256,
}

Members

sender

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Withdraw::sender

pub sender: ContractAddress

receiver

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Withdraw::receiver

pub receiver: ContractAddress

owner

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Withdraw::owner

pub owner: ContractAddress

assets

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Withdraw::assets

pub assets: u256

shares

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Withdraw::shares

pub shares: u256

Preview

Internal helper struct containing assets, shares, and fees calculated in preview functions.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Preview

                    [derive(Drop, Copy)]
pub struct Preview { /* private fields */ }

ComponentState

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—
FeeA fee amount represented either in underlying assets or in shares.

Event

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Event

pub enum Event {
    Deposit: Deposit,
    Withdraw: Withdraw,
}

Variants

Deposit

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Event::Deposit

Deposit: Deposit

Withdraw

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Event::Withdraw

Withdraw: Withdraw

Fee

A fee amount represented either in underlying assets or in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Fee

pub enum Fee {
    Assets: u256,
    Shares: u256,
}

Variants

Assets

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Fee::Assets

Assets: u256

Shares

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Fee::Shares

Shares: u256

Traits

Traits

ImmutableConfigConstants expected to be defined at the contract level which configure virtual assets and shares. UNDERLYING_DECIMALS should match the underlying asset’s decimals. The default value is 18 ….
FeeConfigTraitThe logic for calculating entry and exit fees is expected to be defined at the contract level. Defaults to no entry or exit fees….
LimitConfigTraitSets limits to the target exchange type and is expected to be defined at the contract level. It’s important to note that these limits correspond directly to the max_<OPERATION> i.e. deposit_limit…
ERC4626HooksTraitAllows contracts to hook logic into deposit and withdraw transactions. This is where contracts can transfer fees. NOTE: ERC4626 preview methods must be inclusive of any entry or exit fees….
AssetsManagementTraitDefines how the ERC4626 vault manages its underlying assets. This trait provides the core asset management functionality for the vault, abstracting the actual storage and transfer mechanisms….
HasComponent—
InternalTrait—
UnsafeNewContractStateTraitForERC4626Impl—
UnsafeNewContractStateTraitForERC4626MetadataImpl—

ImmutableConfig

Constants expected to be defined at the contract level which configure virtual assets and shares.

UNDERLYING_DECIMALS should match the underlying asset’s decimals. The default value is 18.

DECIMALS_OFFSET corresponds to the representational offset between UNDERLYING_DECIMALS and the vault decimals. The greater the offset, the more expensive it is for attackers to execute an inflation attack.

Requirements:

  • UNDERLYING_DECIMALS + DECIMALS_OFFSET cannot exceed 255 (max u8).

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ImmutableConfig

pub trait ImmutableConfig

Trait constants

UNDERLYING_DECIMALS

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ImmutableConfig::UNDERLYING_DECIMALS

const UNDERLYING_DECIMALS: u8;

DECIMALS_OFFSET

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ImmutableConfig::DECIMALS_OFFSET

const DECIMALS_OFFSET: u8;

Trait functions

validate

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ImmutableConfig::validate

fn validate()

FeeConfigTrait

The logic for calculating entry and exit fees is expected to be defined at the contract level. Defaults to no entry or exit fees.

NOTE: The FeeConfigTrait hooks directly into the preview methods of the ERC4626 component. The preview methods must return as close to the exact amount of shares or assets as possible if the actual (previewed) operation occurred in the same transaction (according to EIP-4626 spec). All operations use their corresponding preview method as the value of assets or shares being moved to or from the user. The fees calculated in FeeConfigTrait are used to adjust the final asset and share amounts used in both the preview and the actual operations.

NOTE: To transfer fees, this trait needs to be coordinated with ERC4626Component::ERC4626Hooks. See the ERC4626AssetsFeesMock and ERC4626SharesFeesMock examples: https://github.com/OpenZeppelin/cairo-contracts/tree/main/packages/test_common/src/mocks/erc4626.cairo

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait

pub trait FeeConfigTrait<TContractState, +HasComponent<TContractState>>

Trait functions

calculate_deposit_fee

Calculates the entry fee for a deposit during preview_deposit. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the after_deposit hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be minted to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_deposit_fee

fn calculate_deposit_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

calculate_mint_fee

Calculates the entry fee for a mint during preview_mint. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the after_deposit hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be minted to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_mint_fee

fn calculate_mint_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

calculate_withdraw_fee

Calculates the exit fee for a withdraw during preview_withdraw. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the before_withdraw hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be transferred from the owner to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_withdraw_fee

fn calculate_withdraw_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

calculate_redeem_fee

Calculates the exit fee for a redeem during preview_redeem. The returned fee affects the final asset and share amounts. Fees are not transferred automatically and must be handled in the before_withdraw hook: asset fees should be transferred from the vault’s management to the fee recipient, while share fees should be transferred from the owner to the fee recipient.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::FeeConfigTrait::calculate_redeem_fee

fn calculate_redeem_fee(
    self: @ComponentState<TContractState>, assets: u256, shares: u256,
) -> Option<Fee>

LimitConfigTrait

Sets limits to the target exchange type and is expected to be defined at the contract level.

It’s important to note that these limits correspond directly to the max_<OPERATION> i.e. deposit_limit -> max_deposit.

The EIP-4626 spec states that the max_<OPERATION> methods must take into account all global and user-specific limits. If an operation is disabled (even temporarily), the corresponding limit MUST be 0 and MUST NOT panic.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::LimitConfigTrait

pub trait LimitConfigTrait<TContractState, +HasComponent<TContractState>>

Trait functions

deposit_limit

The max deposit allowed. Defaults (Option::None) to 2 ** 256 - 1.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::LimitConfigTrait::deposit_limit

fn deposit_limit(self: @ComponentState<TContractState>, receiver: ContractAddress) -> Option<u256>

mint_limit

The max mint allowed. Defaults (Option::None) to 2 ** 256 - 1.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::LimitConfigTrait::mint_limit

fn mint_limit(self: @ComponentState<TContractState>, receiver: ContractAddress) -> Option<u256>

withdraw_limit

The max withdraw allowed. Defaults (Option::None) to the full asset balance of owner converted from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::LimitConfigTrait::withdraw_limit

fn withdraw_limit(self: @ComponentState<TContractState>, owner: ContractAddress) -> Option<u256>

redeem_limit

The max redeem allowed. Defaults (Option::None) to the full asset balance of owner.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::LimitConfigTrait::redeem_limit

fn redeem_limit(self: @ComponentState<TContractState>, owner: ContractAddress) -> Option<u256>

ERC4626HooksTrait

Allows contracts to hook logic into deposit and withdraw transactions. This is where contracts can transfer fees.

NOTE: ERC4626 preview methods must be inclusive of any entry or exit fees. Fees are calculated using FeeConfigTrait methods and automatically adjust the final asset and share amounts. Fee transfers are handled in ERC4626HooksTrait methods.

NOTE: When a vault implements fees on deposits or withdrawals (either in shares or assets), fee transfers must be handled in these hooks by library clients. This creates a non-atomic operation flow consisting of multiple state-changing steps: transferring assets, minting or burning shares, and transferring (or minting) fees. Between these steps, the vault’s state is temporarily inconsistent: the asset-to-share conversion rate does not accurately reflect the vault’s final state until all steps have completed. Therefore, it is critical to avoid making any external calls (including to the vault contract itself) or querying conversion rates during hook execution.

CAUTION: Special care must be taken when calling external contracts in these hooks. In that case, consider implementing reentrancy protections. For example, in the withdraw flow, the withdraw_limit is checked before the before_withdraw hook is invoked. If this hook performs a reentrant call that invokes withdraw again, the subsequent check on withdraw_limit will be done before the first withdrawal’s core logic (e.g., burning shares and transferring assets) is executed. This could lead to bypassing withdrawal constraints or draining funds.

See the example: https://github.com/OpenZeppelin/cairo-contracts/tree/main/packages/test_common/src/mocks/erc4626.cairo

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ERC4626HooksTrait

pub trait ERC4626HooksTrait<TContractState, +HasComponent<TContractState>>

Trait functions

before_deposit

Hooks into InternalImpl::_deposit. Executes logic before transferring assets and minting shares. The fee is calculated via FeeConfigTrait. Assets and shares represent the actual amounts the user will spend and receive, respectively. Asset fees are included in assets; share fees are excluded from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ERC4626HooksTrait::before_deposit

fn before_deposit(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

after_deposit

Hooks into InternalImpl::_deposit. Executes logic after transferring assets and minting shares. The fee is calculated via FeeConfigTrait. Assets and shares represent the actual amounts the user will spend and receive, respectively. Asset fees are included in assets; share fees are excluded from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ERC4626HooksTrait::after_deposit

fn after_deposit(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

before_withdraw

Hooks into InternalImpl::_withdraw. Executes logic before burning shares and transferring assets. The fee is calculated via FeeConfigTrait. Assets and shares represent the actual amounts the user will receive and spend, respectively. Asset fees are excluded from assets; share fees are included in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ERC4626HooksTrait::before_withdraw

fn before_withdraw(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    owner: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

after_withdraw

Hooks into InternalImpl::_withdraw. Executes logic after burning shares and transferring assets. The fee is calculated via FeeConfigTrait. Assets and shares represent the actual amounts the user will receive and spend, respectively. Asset fees are excluded from assets; share fees are included in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::ERC4626HooksTrait::after_withdraw

fn after_withdraw(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    owner: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

AssetsManagementTrait

Defines how the ERC4626 vault manages its underlying assets. This trait provides the core asset management functionality for the vault, abstracting the actual storage and transfer mechanisms. It enables two primary implementation patterns:

1. Self-managed assets: The vault contract holds assets directly on its own address. This is the default behavior provided by ERC4626SelfAssetsManagement implementation.

2. External vault: Assets are managed by an external contract, allowing for more complex asset management strategies. The exact implementation is expected to be defined by the contract implementing the ERC4626 component.

The trait methods are called during deposit, withdrawal, and total assets calculations, ensuring that the vault’s share pricing remains accurate regardless of the underlying asset management strategy.

CAUTION: Implementations must ensure that get_total_assets returns the actual amount of assets that can be withdrawn by users. Inaccurate reporting can lead to incorrect share valuations and potential economic attacks.

See the examples:

  • Self-managed vault: ERC4626SelfAssetsManagement at the end of the file.
  • External vault: ERC4626ExternalAssetsManagement in ERC4626ExternalVaultMock.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::AssetsManagementTrait

pub trait AssetsManagementTrait<TContractState, +HasComponent<TContractState>>

Trait functions

get_total_assets

Returns the total amount of underlying assets under the vault’s management. Used for share price calculations and determining the vault’s total value.

This method should return the actual amount of assets that the vault controls and that can be used to satisfy withdrawal requests. For self-managed vaults, this is typically the vault contract’s token balance. For external vaults, this should include any assets deposited in external protocols, minus any that are locked or unredeemable.

The accuracy of this method is critical for proper vault operation:

  • Overreporting can lead to share dilution and user losses.
  • Underreporting can lead to share inflation and potential economic attacks.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::AssetsManagementTrait::get_total_assets

fn get_total_assets(self: @ComponentState<TContractState>) -> u256

transfer_assets_in

Transfers assets from an external address into the vault’s management. Called during deposit and mint operations.

This method should handle the actual transfer of underlying assets from the from address into the vault’s control. For self-managed vaults, this typically means transferring tokens to the vault contract’s address. For external vaults, this might involve transferring into an external contract.

Requirements:

  • MUST transfer exactly assets amount of the underlying token.
  • SHOULD revert if the transfer fails or insufficient allowance/balance.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::AssetsManagementTrait::transfer_assets_in

fn transfer_assets_in(ref self: ComponentState<TContractState>, from: ContractAddress, assets: u256)

transfer_assets_out

Transfers assets from the vault’s management to an external address. Called during withdraw and redeem operations.

This method should handle the actual transfer of underlying assets from the vault’s control to the to address. For self-managed vaults, this typically means transferring tokens from the vault contract’s address. For external vaults, this might involve withdrawing from an external contract first.

Requirements:

  • MUST transfer exactly assets amount of the underlying token.
  • SHOULD revert if insufficient assets are available or transfer fails.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::AssetsManagementTrait::transfer_assets_out

fn transfer_assets_out(ref self: ComponentState<TContractState>, to: ContractAddress, assets: u256)

HasComponent

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::HasComponent::emit

fn emit<
    S,
    impl IntoImp: Into<
        S, openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::Event,
    >,
>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait

pub trait InternalTrait<TContractState, +HasComponent<TContractState>, impl Hooks: ERC4626HooksTrait<TContractState, +HasComponent<TContractState>>, impl Immutable: ImmutableConfig, impl ERC20: HasComponent<TContractState>, impl Assets: AssetsManagementTrait<TContractState, +HasComponent<TContractState>>, impl FeeConfig: FeeConfigTrait<TContractState, +HasComponent<TContractState>>, +LimitConfigTrait<TContractState>, impl ERC20HooksTrait<TContractState>: ERC20HooksTrait<TContractState>, +Drop<TContractState>>

Trait functions

initializer

Validates the ImmutableConfig constants and sets the asset_address to the vault. This should be set in the contract’s constructor.

Requirements:

  • asset_address cannot be the zero address.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::initializer

fn initializer(ref self: ComponentState<TContractState>, asset_address: ContractAddress)

_preview_deposit

Internal preview function for deposit operations. Returns the actual assets the user will spend and shares the user will receive. Asset fees are included in assets, share fees are excluded from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_deposit

fn _preview_deposit(self: @ComponentState<TContractState>, assets: u256) -> Preview

_preview_mint

Internal preview function for mint operations. Returns the actual assets the user will spend and shares the user will receive. Asset fees are included in assets, share fees are excluded from shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_mint

fn _preview_mint(self: @ComponentState<TContractState>, shares: u256) -> Preview

_preview_withdraw

Internal preview function for withdraw operations. Returns the actual assets the user will receive and shares the user will spend. Asset fees are excluded from assets, share fees are included in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_withdraw

fn _preview_withdraw(self: @ComponentState<TContractState>, assets: u256) -> Preview

_preview_redeem

Internal preview function for redeem operations. Returns the actual assets the user will receive and shares the user will spend. Asset fees are excluded from assets, share fees are included in shares.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_preview_redeem

fn _preview_redeem(self: @ComponentState<TContractState>, shares: u256) -> Preview

_deposit

Internal logic for deposit and mint. Transfers assets from caller to the Vault contract then mints shares to receiver. Fees can be transferred in the ERC4626Hooks::after_deposit hook which is executed after assets are transferred and shares are minted.

Requirements:

  • ERC20::transfer_from must return true.

Emits two ERC20::Transfer events (ERC20::mint and ERC20::transfer_from). Emits a Deposit event.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_deposit

fn _deposit(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

_withdraw

Internal logic for withdraw and redeem. Burns shares from owner and then transfers assets to receiver. Fees can be transferred in the ERC4626Hooks::before_withdraw hook which is executed before shares are burned and assets are transferred.

Requirements:

  • ERC20::transfer must return true.

Emits two ERC20::Transfer events (ERC20::burn and ERC20::transfer).

Emits a Withdraw event.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_withdraw

fn _withdraw(
    ref self: ComponentState<TContractState>,
    caller: ContractAddress,
    receiver: ContractAddress,
    owner: ContractAddress,
    assets: u256,
    shares: u256,
    fee: Option<Fee>,
)

_convert_to_shares

Internal conversion function (from assets to shares) with support for rounding direction.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_convert_to_shares

fn _convert_to_shares(
    self: @ComponentState<TContractState>, assets: u256, rounding: Rounding,
) -> u256

_convert_to_assets

Internal conversion function (from shares to assets) with support for rounding direction.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::InternalTrait::_convert_to_assets

fn _convert_to_assets(
    self: @ComponentState<TContractState>, shares: u256, rounding: Rounding,
) -> u256

UnsafeNewContractStateTraitForERC4626Impl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::UnsafeNewContractStateTraitForERC4626Impl

pub trait UnsafeNewContractStateTraitForERC4626Impl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::UnsafeNewContractStateTraitForERC4626Impl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC4626MetadataImpl

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::UnsafeNewContractStateTraitForERC4626MetadataImpl

pub trait UnsafeNewContractStateTraitForERC4626MetadataImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626Component::UnsafeNewContractStateTraitForERC4626MetadataImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

Impls

Impls

DefaultConfigImplementation of the default ERC4626Component::ImmutableConfig . See…
ERC4626DefaultNoFees—
ERC4626DefaultNoLimits—
ERC4626EmptyHooks—
ERC4626SelfAssetsManagement—

DefaultConfig

Implementation of the default ERC4626Component::ImmutableConfig.

See https://github.com/starknet-io/SNIPs/blob/963848f0752bde75c7087c2446d83b7da8118b25/SNIPS/snip-107.md#defaultconfig-implementation

The default UNDERLYING_DECIMALS is set to 18. The default DECIMALS_OFFSET is set to 0.

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::DefaultConfig

pub impl DefaultConfig of ImmutableConfig;

Impl constants

UNDERLYING_DECIMALS

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::DefaultConfig::UNDERLYING_DECIMALS

const UNDERLYING_DECIMALS: u8 = ERC4626Component::DEFAULT_UNDERLYING_DECIMALS;

DECIMALS_OFFSET

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::DefaultConfig::DECIMALS_OFFSET

const DECIMALS_OFFSET: u8 = ERC4626Component::DEFAULT_DECIMALS_OFFSET;

ERC4626DefaultNoFees

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626DefaultNoFees

pub impl ERC4626DefaultNoFees<
    TContractState, +ERC4626Component::HasComponent<TContractState>,
> of FeeConfigTrait<TContractState, HasComponent<TContractState>>;

ERC4626DefaultNoLimits

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626DefaultNoLimits

pub impl ERC4626DefaultNoLimits<
    TContractState, +ERC4626Component::HasComponent<TContractState>,
> of LimitConfigTrait<TContractState, HasComponent<TContractState>>;

ERC4626EmptyHooks

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626EmptyHooks

pub impl ERC4626EmptyHooks<
    TContractState, +ERC4626Component::HasComponent<TContractState>,
> of ERC4626HooksTrait<TContractState, HasComponent<TContractState>>;

ERC4626SelfAssetsManagement

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626SelfAssetsManagement

pub impl ERC4626SelfAssetsManagement<
    TContractState, +ERC4626Component::HasComponent<TContractState>,
> of AssetsManagementTrait<TContractState, HasComponent<TContractState>>;

Impl functions

get_total_assets

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626SelfAssetsManagement::get_total_assets

fn get_total_assets(self: @ERC4626Component::ComponentState<TContractState>) -> u256

transfer_assets_in

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626SelfAssetsManagement::transfer_assets_in

fn transfer_assets_in(
    ref self: ERC4626Component::ComponentState<TContractState>, from: ContractAddress, assets: u256,
)

transfer_assets_out

Fully qualified path: openzeppelin_token::erc20::extensions::erc4626::erc4626::ERC4626SelfAssetsManagement::transfer_assets_out

fn transfer_assets_out(
    ref self: ERC4626Component::ComponentState<TContractState>, to: ContractAddress, assets: u256,
)

snip12_utils

Fully qualified path: openzeppelin_token::erc20::snip12_utils

Modules

permit—

Modules

Modules

permit—

permit

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit

Constants

Structs

Permit—

Constants

Constants

PERMIT_TYPE_HASH

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::PERMIT_TYPE_HASH

pub const PERMIT_TYPE_HASH: felt252 =
    1415336368914719292163152228389901548672538424606611267979437740446022424015;

Structs

Structs

Permit—

Permit

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::Permit

[derive(Copy, Drop, Hash)]
pub struct Permit {
    pub token: ContractAddress,
    pub spender: ContractAddress,
    pub amount: u256,
    pub nonce: felt252,
    pub deadline: u64,
}

Members

token

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::Permit::token

pub token: ContractAddress

spender

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::Permit::spender

pub spender: ContractAddress

amount

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::Permit::amount

pub amount: u256

nonce

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::Permit::nonce

pub nonce: felt252

deadline

Fully qualified path: openzeppelin_token::erc20::snip12_utils::permit::Permit::deadline

pub deadline: u64

erc721

Fully qualified path: openzeppelin_token::erc721

Modules


Re-exports:

ERC721HooksEmptyImplAn empty implementation of the ERC721 hooks to be used in basic ERC721 preset contracts.


Modules

Modules

erc721

Fully qualified path: openzeppelin_token::erc721::erc721

Modules

Impls

ERC721HooksEmptyImplAn empty implementation of the ERC721 hooks to be used in basic ERC721 preset contracts.

Modules

Modules

ERC721Component

ERC721 Component

The ERC721 component provides implementations for both the IERC721 interface and the IERC721Metadata interface.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component

Modules

Free functions

Structs

Storage—
TransferEmitted when token_id token is transferred from from to to .
ApprovalEmitted when owner enables approved to manage the token_id token.
ApprovalForAllEmitted when owner enables or disables ( approved ) operator to manage all of its assets.
ComponentState—

Enums

Event—

Traits

Modules

Modules

Errors

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors

Constants

Constants

Constants

INVALID_TOKEN_ID

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::INVALID_TOKEN_ID

pub const INVALID_TOKEN_ID: felt252 = 1699754265108099871470897430857803785044358442022594431300;

INVALID_ACCOUNT

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::INVALID_ACCOUNT

pub const INVALID_ACCOUNT: felt252 = 6639665098078515122933193089288296035324163911262236276;

INVALID_OPERATOR

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::INVALID_OPERATOR

pub const INVALID_OPERATOR: felt252 = 1699754265108099871470897430857803785043998428985933721458;

UNAUTHORIZED

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::UNAUTHORIZED

pub const UNAUTHORIZED: felt252 = 28517144452639854893507085734425180430328771592574685650394834290;

INVALID_RECEIVER

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::INVALID_RECEIVER

pub const INVALID_RECEIVER: felt252 = 1699754265108099871470897430857803785044211503288580203890;

ALREADY_MINTED

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::ALREADY_MINTED

pub const ALREADY_MINTED: felt252 =
    7300388979875802852732128123657212830355657500092055048969713378660;

INVALID_SENDER

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::INVALID_SENDER

pub const INVALID_SENDER: felt252 = 25936191789369199698957785505032406388004815261427058;

SAFE_MINT_FAILED

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::SAFE_MINT_FAILED

pub const SAFE_MINT_FAILED: felt252 = 1699754265108099871484121886731334982652068626744482751844;

SAFE_TRANSFER_FAILED

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Errors::SAFE_TRANSFER_FAILED

pub const SAFE_TRANSFER_FAILED: felt252 =
    7300388979875802852726106486788936616499335593446695555330055365988;

__external_ERC721Impl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__external_ERC721Impl

__l1_handler_ERC721Impl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__l1_handler_ERC721Impl

__constructor_ERC721Impl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__constructor_ERC721Impl

__external_ERC721MetadataImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__external_ERC721MetadataImpl

__l1_handler_ERC721MetadataImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__l1_handler_ERC721MetadataImpl

__constructor_ERC721MetadataImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__constructor_ERC721MetadataImpl

__external_ERC721CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__external_ERC721CamelOnlyImpl

__l1_handler_ERC721CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__l1_handler_ERC721CamelOnlyImpl

__constructor_ERC721CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__constructor_ERC721CamelOnlyImpl

__external_ERC721MetadataCamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__external_ERC721MetadataCamelOnlyImpl

__l1_handler_ERC721MetadataCamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__l1_handler_ERC721MetadataCamelOnlyImpl

__constructor_ERC721MetadataCamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__constructor_ERC721MetadataCamelOnlyImpl

__external_ERC721MixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__external_ERC721MixinImpl

__l1_handler_ERC721MixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__l1_handler_ERC721MixinImpl

__constructor_ERC721MixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::__constructor_ERC721MixinImpl

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage—
TransferEmitted when token_id token is transferred from from to to .
ApprovalEmitted when owner enables approved to manage the token_id token.
ApprovalForAllEmitted when owner enables or disables ( approved ) operator to manage all of its assets.
ComponentState—

Storage

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage

[storage]
pub struct Storage {
    pub ERC721_name: ByteArray,
    pub ERC721_symbol: ByteArray,
    pub ERC721_owners: Map<u256, ContractAddress>,
    pub ERC721_balances: Map<ContractAddress, u256>,
    pub ERC721_token_approvals: Map<u256, ContractAddress>,
    pub ERC721_operator_approvals: Map<(ContractAddress, ContractAddress), bool>,
    pub ERC721_base_uri: ByteArray,
}

Members

ERC721_name

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_name

pub ERC721_name: ByteArray

ERC721_symbol

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_symbol

pub ERC721_symbol: ByteArray

ERC721_owners

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_owners

pub ERC721_owners: Map<u256, ContractAddress>

ERC721_balances

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_balances

pub ERC721_balances: Map<ContractAddress, u256>

ERC721_token_approvals

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_token_approvals

pub ERC721_token_approvals: Map<u256, ContractAddress>

ERC721_operator_approvals

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_operator_approvals

pub ERC721_operator_approvals: Map<(ContractAddress, ContractAddress), bool>

ERC721_base_uri

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Storage::ERC721_base_uri

pub ERC721_base_uri: ByteArray

Transfer

Emitted when token_id token is transferred from from to to.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Transfer

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct Transfer {
    pub from: ContractAddress,
    pub to: ContractAddress,
    pub token_id: u256,
}

Members

from

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Transfer::from

pub from: ContractAddress

to

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Transfer::to

pub to: ContractAddress

token_id

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Transfer::token_id

pub token_id: u256

Approval

Emitted when owner enables approved to manage the token_id token.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Approval

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct Approval {
    pub owner: ContractAddress,
    pub approved: ContractAddress,
    pub token_id: u256,
}

Members

owner

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Approval::owner

pub owner: ContractAddress

approved

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Approval::approved

pub approved: ContractAddress

token_id

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Approval::token_id

pub token_id: u256

ApprovalForAll

Emitted when owner enables or disables (approved) operator to manage all of its assets.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll

[derive(Drop, Debug, PartialEq, starknet::Event)]
pub struct ApprovalForAll {
    pub owner: ContractAddress,
    pub operator: ContractAddress,
    pub approved: bool,
}

Members

owner

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll::owner

pub owner: ContractAddress

operator

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll::operator

pub operator: ContractAddress

approved

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ApprovalForAll::approved

pub approved: bool

ComponentState

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Event

pub enum Event {
    Transfer: Transfer,
    Approval: Approval,
    ApprovalForAll: ApprovalForAll,
}

Variants

Transfer

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Event::Transfer

Transfer: Transfer

Approval

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Event::Approval

Approval: Approval

ApprovalForAll

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::Event::ApprovalForAll

ApprovalForAll: ApprovalForAll

Traits

Traits

ERC721HooksTrait

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ERC721HooksTrait

pub trait ERC721HooksTrait<TContractState>

Trait functions

before_update

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ERC721HooksTrait::before_update

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

after_update

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::ERC721HooksTrait::after_update

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

HasComponent

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::HasComponent::emit

fn emit<S, impl IntoImp: Into<S, openzeppelin_token::erc721::erc721::ERC721Component::Event>>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc721::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.

WARNING: Most ERC721 contracts expose the IERC721Metadata interface which is what this initializer is meant to support. If the contract DOES NOT expose the IERC721Metadata interface, meaning the token does not have a name, symbol, or URI, the contract must instead instead use initializer_no_metadata in the constructor. Failure to abide by these instructions can lead to unexpected issues especially with UIs.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::InternalTrait::initializer

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

initializer_no_metadata

Initializes the contract with no metadata by registering only the IERC721 interface.

WARNING: This initializer should ONLY be used during construction in the very specific instance when the contract does NOT expose the IERC721Metadata interface. Initializing a contract with this initializer means that tokens will not have a name, symbol, or URI.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::InternalTrait::initializer_no_metadata

fn initializer_no_metadata(ref self: ComponentState<TContractState>)

exists

Returns whether token_id exists.

Fully qualified path: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::erc721::ERC721Component::InternalTrait::_set_base_uri

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

_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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::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: openzeppelin_token::erc721::erc721::ERC721Component::InternalTrait::_check_authorized

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

UnsafeNewContractStateTraitForERC721Impl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721Impl

pub trait UnsafeNewContractStateTraitForERC721Impl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721Impl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC721MetadataImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721MetadataImpl

pub trait UnsafeNewContractStateTraitForERC721MetadataImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721MetadataImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC721CamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721CamelOnlyImpl

pub trait UnsafeNewContractStateTraitForERC721CamelOnlyImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721CamelOnlyImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC721MetadataCamelOnlyImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721MetadataCamelOnlyImpl

pub trait UnsafeNewContractStateTraitForERC721MetadataCamelOnlyImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721MetadataCamelOnlyImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC721MixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721MixinImpl

pub trait UnsafeNewContractStateTraitForERC721MixinImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721Component::UnsafeNewContractStateTraitForERC721MixinImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

Impls

Impls

ERC721HooksEmptyImplAn empty implementation of the ERC721 hooks to be used in basic ERC721 preset contracts.

ERC721HooksEmptyImpl

An empty implementation of the ERC721 hooks to be used in basic ERC721 preset contracts.

Fully qualified path: openzeppelin_token::erc721::erc721::ERC721HooksEmptyImpl

pub impl ERC721HooksEmptyImpl<TContractState> of ERC721HooksTrait<TContractState>;

erc721_receiver

Fully qualified path: openzeppelin_token::erc721::erc721_receiver

Modules

Modules

Modules

ERC721ReceiverComponent

ERC721Receiver Component

The ERC721Receiver component provides implementations for the IERC721Receiver interface. Integrating this component allows contracts to support ERC721 safe transfers.

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent

Modules

Free functions

Structs

Enums

Event—

Traits

Modules

Modules

__external_ERC721ReceiverImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__external_ERC721ReceiverImpl

__l1_handler_ERC721ReceiverImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__l1_handler_ERC721ReceiverImpl

__constructor_ERC721ReceiverImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__constructor_ERC721ReceiverImpl

__external_ERC721ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__external_ERC721ReceiverCamelImpl

__l1_handler_ERC721ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__l1_handler_ERC721ReceiverCamelImpl

__constructor_ERC721ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__constructor_ERC721ReceiverCamelImpl

__external_ERC721ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__external_ERC721ReceiverMixinImpl

__l1_handler_ERC721ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__l1_handler_ERC721ReceiverMixinImpl

__constructor_ERC721ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::__constructor_ERC721ReceiverMixinImpl

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::Storage

[storage]
pub struct Storage {}

ComponentState

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::Event

pub enum Event {}

Traits

Traits

HasComponent

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::HasComponent::emit

fn emit<
    S,
    impl IntoImp: Into<
        S, openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::Event,
    >,
>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::InternalTrait

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

Trait functions

initializer

Initializes the contract by registering the IERC721Receiver interface ID. This should be used inside the contract’s constructor.

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::InternalTrait::initializer

fn initializer(ref self: ComponentState<TContractState>)

UnsafeNewContractStateTraitForERC721ReceiverImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::UnsafeNewContractStateTraitForERC721ReceiverImpl

pub trait UnsafeNewContractStateTraitForERC721ReceiverImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::UnsafeNewContractStateTraitForERC721ReceiverImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC721ReceiverCamelImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::UnsafeNewContractStateTraitForERC721ReceiverCamelImpl

pub trait UnsafeNewContractStateTraitForERC721ReceiverCamelImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::UnsafeNewContractStateTraitForERC721ReceiverCamelImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

UnsafeNewContractStateTraitForERC721ReceiverMixinImpl

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::UnsafeNewContractStateTraitForERC721ReceiverMixinImpl

pub trait UnsafeNewContractStateTraitForERC721ReceiverMixinImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::erc721_receiver::ERC721ReceiverComponent::UnsafeNewContractStateTraitForERC721ReceiverMixinImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState

extensions

Fully qualified path: openzeppelin_token::erc721::extensions

Modules


Re-exports:


Modules

Modules

erc721_enumerable

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable

Modules


Re-exports:


Modules

Modules

erc721_enumerable

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable

Modules

Modules

Modules

ERC721EnumerableComponent

ERC721Enumerable Component

Extension of ERC721 as defined in the EIP that adds enumerability of all the token ids in the contract as well as all token ids owned by each account. It allows contracts to publish their entire list of NFTs and make them discoverable.

NOTE: Implementing ERC721Component is a requirement for this component to be implemented.

WARNING: To properly track token ids, this extension requires that the ERC721EnumerableComponent::before_update function is called after every transfer, mint, or burn operation. For this, the ERC721HooksTrait::before_update hook must be used.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent

Modules

Free functions

Structs

Enums

Event—

Traits

Modules

Modules

Errors

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Errors

Constants

Constants

Constants

OUT_OF_BOUNDS_INDEX

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Errors::OUT_OF_BOUNDS_INDEX

pub const OUT_OF_BOUNDS_INDEX: felt252 =
    122480202799396068594471588599384390921845137422556154739854694742137005432;

__external_ERC721EnumerableImpl

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::__external_ERC721EnumerableImpl

__l1_handler_ERC721EnumerableImpl

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::__l1_handler_ERC721EnumerableImpl

__constructor_ERC721EnumerableImpl

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::__constructor_ERC721EnumerableImpl

Free functions

Free functions

unsafe_new_component_state

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::unsafe_new_component_state

pub fn unsafe_new_component_state<TContractState>() -> ComponentState<TContractState>

Structs

Structs

Storage

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Storage

[storage]
pub struct Storage {
    pub ERC721Enumerable_owned_tokens: Map<(ContractAddress, u256), u256>,
    pub ERC721Enumerable_owned_tokens_index: Map<u256, u256>,
    pub ERC721Enumerable_all_tokens_len: u256,
    pub ERC721Enumerable_all_tokens: Map<u256, u256>,
    pub ERC721Enumerable_all_tokens_index: Map<u256, u256>,
}

Members

ERC721Enumerable_owned_tokens

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Storage::ERC721Enumerable_owned_tokens

pub ERC721Enumerable_owned_tokens: Map<(ContractAddress, u256), u256>

ERC721Enumerable_owned_tokens_index

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Storage::ERC721Enumerable_owned_tokens_index

pub ERC721Enumerable_owned_tokens_index: Map<u256, u256>

ERC721Enumerable_all_tokens_len

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Storage::ERC721Enumerable_all_tokens_len

pub ERC721Enumerable_all_tokens_len: u256

ERC721Enumerable_all_tokens

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Storage::ERC721Enumerable_all_tokens

pub ERC721Enumerable_all_tokens: Map<u256, u256>

ERC721Enumerable_all_tokens_index

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Storage::ERC721Enumerable_all_tokens_index

pub ERC721Enumerable_all_tokens_index: Map<u256, u256>

ComponentState

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::ComponentState

pub struct ComponentState<TContractState> {}

Enums

Enums

Event—

Event

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event

pub enum Event {}

Traits

Traits

HasComponent

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::HasComponent

pub trait HasComponent<TContractState>

Trait functions

get_component

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::HasComponent::get_component

fn get_component(self: @TContractState) -> @ComponentState<TContractState>

get_component_mut

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::HasComponent::get_component_mut

fn get_component_mut(ref self: TContractState) -> ComponentState<TContractState>

get_contract

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::HasComponent::get_contract

fn get_contract(self: @ComponentState<TContractState>) -> @TContractState

get_contract_mut

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::HasComponent::get_contract_mut

fn get_contract_mut(ref self: ComponentState<TContractState>) -> TContractState

emit

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::HasComponent::emit

fn emit<
    S,
    impl IntoImp: Into<
        S,
        openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::Event,
    >,
>(
    ref self: ComponentState<TContractState>, event: S,
)

InternalTrait

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait

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

Trait functions

initializer

Initializes the contract by declaring support for the IERC721Enumerable interface id.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::initializer

fn initializer(ref self: ComponentState<TContractState>)

before_update

Updates the ownership and token-tracking data structures.

When a token is minted (or burned), token_id is added to (or removed from) the token-tracking structures.

When a token is transferred, minted, or burned, the ownership-tracking data structures reflect the change in ownership of token_id.

This must be added to the implementing contract’s ERC721HooksTrait::before_update hook.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::before_update

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

all_tokens_of_owner

Returns a list of all token ids owned by the specified owner. This function provides a more efficient alternative to calling ERC721::balance_of and iterating through tokens with ERC721Enumerable::token_of_owner_by_index.

Requirements:

  • owner is not the zero address.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::all_tokens_of_owner

fn all_tokens_of_owner(self: @ComponentState<TContractState>, owner: ContractAddress) -> Span<u256>

_add_token_to_owner_enumeration

Adds token to this extension’s ownership-tracking data structures.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::_add_token_to_owner_enumeration

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

_add_token_to_all_tokens_enumeration

Adds token to this extension’s token-tracking data structures.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::_add_token_to_all_tokens_enumeration

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

_remove_token_from_owner_enumeration

Removes a token from this extension’s ownership-tracking data structures.

This has O(1) time complexity but alters the indexed order of owned-tokens by swapping token_id and the index thereof with the last token id and the index thereof.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::_remove_token_from_owner_enumeration

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

_remove_token_from_all_tokens_enumeration

Removes token_id from this extension’s token-tracking data structures.

This has O(1) time complexity but alters the indexed order by swapping token_id and the index thereof with the last token id and the index thereof.

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::InternalTrait::_remove_token_from_all_tokens_enumeration

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

UnsafeNewContractStateTraitForERC721EnumerableImpl

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::UnsafeNewContractStateTraitForERC721EnumerableImpl

pub trait UnsafeNewContractStateTraitForERC721EnumerableImpl<TContractState>

Trait functions

unsafe_new_contract_state

Fully qualified path: openzeppelin_token::erc721::extensions::erc721_enumerable::erc721_enumerable::ERC721EnumerableComponent::UnsafeNewContractStateTraitForERC721EnumerableImpl::unsafe_new_contract_state

fn unsafe_new_contract_state() -> TContractState