EIP1559Burn
The EIP1559Burn
contract burns the native token on the rootchain as an ERC-20 token. This operation is crucial for maintaining the value of the token across different chains.
Functions
initialize()
function initialize(IChildERC20Predicate newChildERC20Predicate, address newBurnDestination)
This is the initialization function for the EIP1559Burn
contract. It sets the childERC20Predicate
and burnDestination
state variables. This function can only be called once due to the initializer modifier.
Parameters:
newChildERC20Predicate
: Address of the ERC20 predicate on the childchainnewBurnDestination
: Address on the root chain to burn the tokens and send to
withdraw()
function withdraw() external {
require(address(childERC20Predicate) != address(0), "EIP1559Burn: UNINITIALIZED");
...
}
This function burns the native tokens on the childchain and sends them to the burn destination on the rootchain. It requires the childERC20Predicate
to be initialized, and takes the entire current native token balance and burns it.
Events
NativeTokenBurnt()
This event is emitted when native tokens are burnt. It includes the address of the burner and the amount of tokens that were burnt.
Usage
The EIP1559Burn
contract is a part of the asset bridging process between the rootchain and the childchain. It interacts with the IChildERC20Predicate
contract, which is responsible for handling the token transfer process.
In the asset bridging process, users deposit ERC20 tokens from the rootchain to the childchain, transact on the childchain, and then withdraw their assets back to the rootchain when they're done. The withdraw()
function of the EIP1559Burn contract is called when users are ready to burn their tokens on the child chain and move them back to the rootchain.
Here is a high-level sequence of the bridging process:
-
Deposit: Users deposit ERC20 tokens from the root chain to the childchain. The tokens are approved for transfer by the rootchain's ERC20 contract, and then deposited in the root chain's ERC20 predicate contract. The state of the deposit is synced to the childchain, and the tokens are minted on the child chain1
-
Withdraw: When users want to move their assets back to the root chain, they initiate a withdrawal. The childchain's ERC20 predicate contract calls the
withdrawTo()
function, which burns the tokens on the childchain and syncs the state of the withdrawal back to the rootchain. -
Exit: The withdrawal is finalized on the root chain. The root chain's ERC20 predicate contract transfers the tokens back to the user.