ERC20B
Extended ERC20 with bridging capabilities and admin controls
ERC20B
Extended ERC20 token implementation with bridging capabilities, admin-controlled minting/burning, and access control.
Inherits: ERC20, Ownable, AccessControl
Functions
constructor
constructor(string memory name, string memory symbol) ERC20(name, symbol)onlyAdmin
modifier onlyAdmin()Restricts function access to admin role holders.
grantAdmin
function grantAdmin(address to) public onlyAdminGrants admin role to an address.
revokeAdmin
function revokeAdmin(address to) public onlyAdminRevokes admin role from an address.
mint
function mint(address account, uint256 amount) public onlyAdmin returns (bool)Mints tokens to an account. Only callable by admins.
burnIt
function burnIt(address account, uint256 amount) public onlyAdmin returns (bool)Burns tokens from an account. Only callable by admins.
Events
LogMint
event LogMint(address indexed account, uint256 amount)LogBurn
event LogBurn(address indexed account, uint256 amount)AdminGranted
event AdminGranted(address to)AdminRevoked
event AdminRevoked(address to)Usage
import "@luxfi/standard/src/tokens/ERC20B.sol";
contract MyToken is ERC20B {
constructor() ERC20B("My Token", "MTK") {}
}
// Deploy and configure
MyToken token = new MyToken();
token.grantAdmin(bridgeContract);
// Admin mints
token.mint(user, 1000 ether);
// Admin burns
token.burnIt(user, 500 ether);Bridge Integration
ERC20B is designed for cross-chain bridge integration:
// Bridge contract as admin
contract Bridge {
ERC20B public token;
function bridgeMint(address to, uint256 amount) external {
token.mint(to, amount);
}
function bridgeBurn(address from, uint256 amount) external {
token.burnIt(from, amount);
}
}