Skip to content

Solidity API

ERC20BaseInternal

Implements core internal functions for ERC20 token operations This contract serves as the base for ERC20 implementations, providing internal functions for transfers, approvals, minting, and burning

_totalSupply

solidity
function _totalSupply() internal view virtual returns (uint256)

Query the total minted token supply

Returns the current total supply of tokens from storage

Return Values

NameTypeDescription
[0]uint256Total number of tokens in existence

_balanceOf

solidity
function _balanceOf(address account) internal view virtual returns (uint256)

Query the token balance of given account

Returns the current balance of an address from storage

Parameters

NameTypeDescription
accountaddressAddress to query the balance of

Return Values

NameTypeDescription
[0]uint256Number of tokens owned by the account

_allowance

solidity
function _allowance(address holder, address spender) internal view virtual returns (uint256)

Query the allowance granted from given holder to given spender

Returns the number of tokens the spender is allowed to spend on behalf of the holder

Parameters

NameTypeDescription
holderaddressOwner of the tokens
spenderaddressAddress authorized to spend tokens

Return Values

NameTypeDescription
[0]uint256Number of tokens the spender is allowed to spend

_spendAllowance

solidity
function _spendAllowance(address owner, address spender, uint256 value) internal virtual

_Updates owner s allowance for spender based on spent value.

Does not update the allowance value in case of infinite allowance. Revert if not enough allowance is available.

Does not emit an {Approval} event._

_approve

solidity
function _approve(address holder, address spender, uint256 amount) internal virtual returns (bool)

Enable spender to spend tokens on behalf of holder

Sets or updates the allowance granted to a spender by a holder Emits an Approval event

Parameters

NameTypeDescription
holderaddressAddress on whose behalf tokens may be spent
spenderaddressAddress authorized to spend tokens
amountuint256Number of tokens approved for spending

Return Values

NameTypeDescription
[0]boolsuccess Always returns true (reverts on failure)

_decreaseAllowance

solidity
function _decreaseAllowance(address holder, address spender, uint256 amount) internal

Decrease spend amount granted by holder to spender

Reduces the allowance granted to a spender by a specified amount Uses unchecked subtraction for gas optimization when amount is valid

Parameters

NameTypeDescription
holderaddressAddress that granted the allowance
spenderaddressAddress whose allowance will be decreased
amountuint256Amount to decrease the allowance by

_mint

solidity
function _mint(address account, uint256 amount) internal virtual

Mint tokens for given account

Creates new tokens and assigns them to the specified account Increases total supply and recipient's balance Emits a Transfer event with 'from' set to zero address

Parameters

NameTypeDescription
accountaddressRecipient of minted tokens
amountuint256Quantity of tokens to mint

_burn

solidity
function _burn(address account, uint256 amount) internal virtual

Burn tokens held by given account

Destroys tokens from the specified account Decreases total supply and holder's balance Emits a Transfer event with 'to' set to zero address

Parameters

NameTypeDescription
accountaddressAddress whose tokens will be burned
amountuint256Quantity of tokens to burn

_transfer

solidity
function _transfer(address holder, address recipient, uint256 amount) internal virtual returns (bool)

Transfer tokens from holder to recipient

Moves tokens from one address to another Updates balances of both addresses Emits a Transfer event

Parameters

NameTypeDescription
holderaddressOwner of tokens to be transferred
recipientaddressBeneficiary of transfer
amountuint256Quantity of tokens to transfer

Return Values

NameTypeDescription
[0]boolsuccess Always returns true (reverts on failure)

_transferFrom

solidity
function _transferFrom(address holder, address recipient, uint256 amount) internal virtual returns (bool)

Transfer tokens on behalf of holder using allowance mechanism

_Moves tokens using the allowance mechanism and updates relevant allowance Calls _decreaseAllowance and transfer internally

Parameters

NameTypeDescription
holderaddressAddress that owns the tokens
recipientaddressBeneficiary of transfer
amountuint256Quantity of tokens to transfer

Return Values

NameTypeDescription
[0]boolsuccess Always returns true (reverts on failure)

_beforeTokenTransfer

solidity
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual

ERC20 hook, called before all transfers including mint and burn

Hook that is called before any token transfer, including mints and burns Can be used to add custom logic before transfers Must be overridden by derived contracts that need transfer hooks

Parameters

NameTypeDescription
fromaddressAddress sending tokens (zero address for mints)
toaddressAddress receiving tokens (zero address for burns)
amountuint256Number of tokens being transferred