Skip to content
Lattice

ERC20BurnableLib

Git Source

Title: ERC20BurnableLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/extensions/ERC20Burnable.sol)

Library implementing ERC-20 burn extensions. Adds no own storage.

Ports OpenZeppelin v5.6.1 ERC20Burnable. Differences from OpenZeppelin:

  • Known limitation (IMP-1): OZ marks _spendAllowance as virtual to allow downstream extensions (e.g., Permit-based overrides) to intercept allowance consumption. Solidity libraries cannot declare virtual functions, so burnFrom is hardwired to ERC20Lib._spendAllowance. If permit-based allowance overriding is required in the future, an _inner delegate pattern or a hook in ERC20Lib will be needed to restore the override chain.
  • Burns call ERC20Lib._burn directly, so the ERC20Pausable and ERC20Votes overrides of transfer/transferFrom never see them: a burn goes through while paused and does not move votes (decision D25 on #234).
  • The caller is msg.sender, not _msgSender().
  • Registers IERC20Burnable for ERC-165 in its init; OpenZeppelin's extension has no ERC-165.

Functions

__ERC20Burnable_init

Registers the IERC20Burnable interface for ERC-165 discovery.

Must be called inside a pre/postInitializer block. No own storage to initialize.

function __ERC20Burnable_init() internal;

registerInterface

Registers support for the IERC20Burnable interface via ERC-165.

function registerInterface() internal;

burn

Destroys value tokens from the caller's balance.

function burn(uint256 value) internal;

Parameters

NameTypeDescription
valueuint256

burnFrom

Destroys value tokens from account, using the caller's allowance.

function burnFrom(address account, uint256 value) internal;

Parameters

NameTypeDescription
accountaddress
valueuint256