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.
Events
CCIPAdminTransferred
event CCIPAdminTransferred(address indexed previousAdmin, address indexed newAdmin);
Parameters
Name | Type | Indexed | Description |
---|---|---|---|
previousAdmin | address | Yes | The address that held the role |
newAdmin | address | Yes | The 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
Name | Type | Description |
---|---|---|
owner | address | The address that currently owns the tokens |
spender | address | The address that will be allowed to spend tokens |
amount | uint256 | The 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
Name | Type | Description |
---|---|---|
amount | uint256 | The 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
Name | Type | Description |
---|---|---|
account | address | The account to remove tokens from |
amount | uint256 | The 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
Name | Type | Description |
---|---|---|
account | address | The account to remove tokens from |
amount | uint256 | The number of tokens to destroy |
constructor
constructor(
string memory name,
string memory symbol,
uint8 decimals_,
uint256 maxSupply_,
uint256 preMint
) ERC20(name, symbol);
Parameters
Name | Type | Description |
---|---|---|
name | string | The display name of the token |
symbol | string | The token's ticker symbol |
decimals_ | uint8 | The number of decimal places for token amounts |
maxSupply_ | uint256 | The maximum allowed token supply (0 for unlimited) |
preMint | uint256 | The amount of tokens to mint to the deployer |
decimals
Returns the token's decimal precision.
function decimals() public view virtual override returns (uint8);
Returns
Type | Description |
---|---|
uint8 | The number of decimal places used for token amounts |
getCCIPAdmin
Retrieves the current CCIP administrator's address.
function getCCIPAdmin() external view returns (address);
Returns
Type | Description |
---|---|
address | The current CCIP administrator's address |
grantMintAndBurnRoles
Assigns both minting and burning permissions to a single address.
function grantMintAndBurnRoles(address burnAndMinter) external;
Parameters
Name | Type | Description |
---|---|---|
burnAndMinter | address | The address that will receive minting and burning rights |
maxSupply
Returns the token's maximum supply limit.
function maxSupply() public view virtual returns (uint256);
Returns
Type | Description |
---|---|
uint256 | The 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
Name | Type | Description |
---|---|---|
account | address | The address that will receive the new tokens |
amount | uint256 | The number of new tokens to create |
setCCIPAdmin
Updates the CCIP administrator role.
function setCCIPAdmin(address newAdmin) public onlyRole(DEFAULT_ADMIN_ROLE);
Parameters
Name | Type | Description |
---|---|---|
newAdmin | address | The 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
Name | Type | Description |
---|---|---|
interfaceId | bytes4 | The interface identifier to check |
Returns
Type | Description |
---|---|
bool | true 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
Name | Type | Description |
---|---|---|
from | address | The address sending tokens |
to | address | The address receiving tokens |
amount | uint256 | The number of tokens to transfer |