API Version: v1.5.1

CCIP v1.5.1 BurnMintERC20 Contract API Reference

BurnMintERC20

An ERC20-compliant token contract that extends the standard functionality with controlled minting and burning capabilities through role-based access control.

Git Source

Events

CCIPAdminTransferred

event CCIPAdminTransferred(address indexed previousAdmin, address indexed newAdmin);

Parameters

NameTypeIndexedDescription
previousAdminaddressYesThe address that held the role
newAdminaddressYesThe address receiving the role

Errors

InvalidRecipient

error InvalidRecipient(address recipient);

MaxSupplyExceeded

error MaxSupplyExceeded(uint256 supplyAfterMint);

State Variables

BURNER_ROLE

bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");

MINTER_ROLE

bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

Functions

_approve

Internal function that manages token spending allowances with built-in safety checks.

function _approve(address owner, address spender, uint256 amount) internal virtual override;

Parameters

NameTypeDescription
owneraddressThe address that currently owns the tokens
spenderaddressThe address that will be allowed to spend tokens
amountuint256The number of tokens to approve for spending

burn (with amount)

Allows authorized addresses to burn (destroy) tokens from their own account.

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

Parameters

NameTypeDescription
amountuint256The number of tokens to destroy

burn (with account)

Alternative burn function that allows burning tokens from a specified account.

function burn(address account, uint256 amount) public virtual override;

Parameters

NameTypeDescription
accountaddressThe account to remove tokens from
amountuint256The number of tokens to destroy

burnFrom

Burns tokens from a specified account, requiring prior approval.

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

Parameters

NameTypeDescription
accountaddressThe account to remove tokens from
amountuint256The number of tokens to destroy

constructor

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

Parameters

NameTypeDescription
namestringThe display name of the token
symbolstringThe token's ticker symbol
decimals_uint8The number of decimal places for token amounts
maxSupply_uint256The maximum allowed token supply (0 for unlimited)
preMintuint256The amount of tokens to mint to the deployer

decimals

Returns the token's decimal precision.

function decimals() public view virtual override returns (uint8);

Returns

TypeDescription
uint8The number of decimal places used for token amounts

getCCIPAdmin

Retrieves the current CCIP administrator's address.

function getCCIPAdmin() external view returns (address);

Returns

TypeDescription
addressThe current CCIP administrator's address

grantMintAndBurnRoles

Assigns both minting and burning permissions to a single address.

function grantMintAndBurnRoles(address burnAndMinter) external;

Parameters

NameTypeDescription
burnAndMinteraddressThe address that will receive minting and burning rights

maxSupply

Returns the token's maximum supply limit.

function maxSupply() public view virtual returns (uint256);

Returns

TypeDescription
uint256The maximum allowed token supply (0 means unlimited)

mint

Creates new tokens and assigns them to a specified address.

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

Parameters

NameTypeDescription
accountaddressThe address that will receive the new tokens
amountuint256The number of new tokens to create

setCCIPAdmin

Updates the CCIP administrator role.

function setCCIPAdmin(address newAdmin) public onlyRole(DEFAULT_ADMIN_ROLE);

Parameters

NameTypeDescription
newAdminaddressThe address that will become the new CCIP administrator

supportsInterface

Determines whether the contract implements a specific interface.

function supportsInterface(bytes4 interfaceId) public pure virtual override(AccessControl, IERC165) returns (bool);

Parameters

NameTypeDescription
interfaceIdbytes4The interface identifier to check

Returns

TypeDescription
booltrue if the contract implements the specified interface

_transfer

Internal function that handles token transfers between addresses.

function _transfer(address from, address to, uint256 amount) internal virtual override;

Parameters

NameTypeDescription
fromaddressThe address sending tokens
toaddressThe address receiving tokens
amountuint256The number of tokens to transfer

Get the latest Chainlink content straight to your inbox.