CCIP v1.5.1 BurnMintERC20 Contract API Reference

The BurnMintERC20 contract implements a basic ERC20 token with burn and mint capabilities controlled through roles.

Errors

MaxSupplyExceeded

error MaxSupplyExceeded(uint256 supplyAfterMint)

Thrown when a mint would exceed the maximum token supply.

ParameterTypeDescription
supplyAfterMintuint256Total supply that would result from the mint

InvalidRecipient

error InvalidRecipient(address recipient)

Thrown when trying to transfer or approve tokens for the contract itself.

ParameterTypeDescription
recipientaddressInvalid recipient address

Events

CCIPAdminTransferred

event CCIPAdminTransferred(address indexed previousAdmin, address indexed newAdmin)

Emitted when the CCIP admin role is transferred.

ParameterTypeDescription
previousAdminaddressPrevious CCIP admin address
newAdminaddressNew CCIP admin address

Constants

MINTER_ROLE

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE")

Role identifier for addresses allowed to mint tokens.

BURNER_ROLE

bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE")

Role identifier for addresses allowed to burn tokens.

Functions

constructor

constructor(
    string memory name,
    string memory symbol,
    uint8 decimals_,
    uint256 maxSupply_,
    uint256 preMint
) ERC20(name, symbol)

Initializes the token with its basic properties.

Parameters

NameTypeDescription
namestringToken name
symbolstringToken symbol
decimals_uint8Number of decimal places
maxSupply_uint256Maximum token supply (0 for unlimited)
preMintuint256Amount to mint to the deployer initially

burn

function burn(uint256 amount) public override(IBurnMintERC20, ERC20Burnable) onlyRole(BURNER_ROLE)

Burns tokens from the caller's balance.

Parameters

NameTypeDescription
amountuint256Amount of tokens to burn

burnFrom

function burnFrom(
    address account,
    uint256 amount
) public override(IBurnMintERC20, ERC20Burnable) onlyRole(BURNER_ROLE)

Burns tokens from a specific account (requires approval).

Parameters

NameTypeDescription
accountaddressAccount to burn tokens from
amountuint256Amount of tokens to burn

mint

function mint(address account, uint256 amount) external override onlyRole(MINTER_ROLE)

Mints new tokens to a specified account.

Parameters

NameTypeDescription
accountaddressRecipient of the minted tokens
amountuint256Amount of tokens to mint

CCIP Admin Management

getCCIPAdmin

function getCCIPAdmin() external view returns (address)

Returns the current CCIP admin address.

Return Value

TypeDescription
addressCurrent CCIP admin address

setCCIPAdmin

function setCCIPAdmin(address newAdmin) public onlyRole(DEFAULT_ADMIN_ROLE)

Transfers the CCIP admin role to a new address.

Parameters

NameTypeDescription
newAdminaddressNew CCIP admin address

Role Management

grantMintAndBurnRoles

function grantMintAndBurnRoles(address burnAndMinter) external

Grants both minting and burning roles to an address.

Parameters

NameTypeDescription
burnAndMinteraddressAddress to receive both roles

Get the latest Chainlink content straight to your inbox.