Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

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,
)