Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

EspTokenV2

Git Source

Inherits: EspToken

Title: EspTokenV2

Upgrades EspToken to allow minting by the RewardClaim contract

Upgradeability & storage layout (frozen-inheritance pattern) We intentionally do not use __gap slots. Once a version is deployed, its storage layout is frozen and never modified. New state variables are added only in a new child contract (V2, V3, …) that inherits from the previous version and appends fields at the end. This preserves slot order across upgrades without relying on gaps. (Note: upstream OZ parents may include their own gaps—those remain untouched.)

State Variables

rewardClaim

Address of the RewardClaim contract authorized to mint tokens

Can only be set once, during initialization.

address public rewardClaim

Functions

constructor

constructor() ;

initializeV2

Initializes the V2 upgrade with the RewardClaim contract address

function initializeV2(address _rewardClaim) public onlyOwner reinitializer(2);

Parameters

NameTypeDescription
_rewardClaimaddressAddress of the RewardClaim contract

mint

Mints new tokens to a specified address

Only the RewardClaim contract can mint new tokens

function mint(address to, uint256 amount) public;

Parameters

NameTypeDescription
toaddressAddress to receive the minted tokens
amountuint256Number of tokens to mint

getVersion

Returns the contract version

function getVersion()
    public
    pure
    virtual
    override
    returns (uint8 majorVersion, uint8 minorVersion, uint8 patchVersion);

Returns

NameTypeDescription
majorVersionuint8Major version number
minorVersionuint8Minor version number
patchVersionuint8Patch version number

Errors

OnlyRewardClaim

A non-RewardClaim address attempts to mint

error OnlyRewardClaim();

ZeroRewardClaimAddress

RewardClaim address cannot be zero

error ZeroRewardClaimAddress();