Composable Token Contract
The ComposableERC20 contract is the CET token representation used by the Ethera bridge on rollups. It records the identity of the represented asset, supports bridge-controlled minting and burning, and identifies whether the deployment is a Wrapped CET or a Core CET.
Overview
ComposableERC20 is responsible for:
- Representing an asset identity through
remoteAssetandremoteChainID - Supporting bridge-controlled supply changes through
crosschainMint(...)andcrosschainBurn(...) - Distinguishing between Wrapped CET and Core CET deployments
- Allowing authorized bridge contracts to mint and burn during bridge execution
- Storing token metadata that is initialized after deployment
Wrapped CET deployments are typically created through CETFactory when a bridged asset does not yet exist on the destination rollup. Core CET deployments represent the native canonical form of an asset on its home chain.
Contract Interface
contract ComposableERC20 is ERC20, IERC7802, IComposableERC20 {
address public immutable remoteAsset;
uint256 public immutable remoteChainID;
address public immutable owner;
CetType public immutable cetType;
mapping(address => bool) public authorizedBridges;
function initializeMetadata(...) external;
function authorizeBridge(address _bridge) external;
function revokeBridge(address _bridge) external;
function crosschainMint(...) external;
function crosschainBurn(...) external;
function supportsInterface(bytes4 interfaceId) external view returns (bool);
function name() public view returns (string memory);
function symbol() public view returns (string memory);
function decimals() public view returns (uint8);
}
Functions
initializeMetadata(name_, symbol_, decimals_)
Description: Initializes the token metadata after deployment.
| Parameter | Type | Description |
|---|---|---|
| name | string | Token name |
| symbol | string | Token symbol |
| decimals | uint8 | Token decimals |
Requirements:
- Only the contract owner can call this function
- Metadata can only be initialized once
Process:
- Validates that the caller is the contract owner
- Validates that metadata has not already been initialized
- Stores the token name, symbol, and decimals
authorizeBridge(_bridge)
Description: Authorizes a bridge contract to mint and burn this token during bridge execution.
| Parameter | Type | Description |
|---|---|---|
| bridge | address | Bridge contract address to authorize |
Requirements:
- Only the contract owner can call this function
Process:
- Validates that the caller is the contract owner
- Marks the provided bridge as authorized
Events:
BridgeAuthorized(address bridge)
revokeBridge(_bridge)
Description: Removes bridge authorization from a contract address.
| Parameter | Type | Description |
|---|---|---|
| bridge | address | Bridge contract address to revoke |
Requirements:
- Only the contract owner can call this function
Process:
- Validates that the caller is the contract owner
- Removes bridge authorization for the provided address
Events:
BridgeRevoked(address bridge)
crosschainMint(to, amount)
Description: Mints CET to the target account during bridge execution.
| Parameter | Type | Description |
|---|---|---|
| to | address | Recipient account |
| amount | uint256 | Amount to mint |
Requirements:
- Only an authorized bridge contract can call this function
Process:
- Verifies that the caller is an authorized bridge
- Mints CET to the target account
Events:
CrosschainMint(address indexed to, uint256 amount, address indexed sender)
crosschainBurn(from, amount)
Description: Burns CET from the target account during bridge execution.
| Parameter | Type | Description |
|---|---|---|
| from | address | Account to burn from |
| amount | uint256 | Amount to burn |
Requirements:
- Only an authorized bridge contract can call this function
Process:
- Verifies that the caller is an authorized bridge
- Burns CET from the target account
Events:
CrosschainBurn(address indexed from, uint256 amount, address indexed sender)
remoteAsset()
Description: Returns the asset address represented by this token.
Returns:
remoteAsset(address): Asset identity associated with this CET deployment
remoteChainID()
Description: Returns the chain ID associated with the represented asset identity.
Returns:
remoteChainID(uint256): Chain ID associated with the represented asset
cetType()
Description: Returns the CET type for this deployment.
Returns:
cetType(CetType):COREfor a native canonical CET, orWRAPPEDfor a bridge-deployed representation
Events
BridgeAuthorized
event BridgeAuthorized(address bridge)
Emitted when a bridge contract is authorized.
BridgeRevoked
event BridgeRevoked(address bridge)
Emitted when a bridge contract is revoked.
CrosschainMint
event CrosschainMint(address indexed to, uint256 amount, address indexed sender)
Emitted when an authorized bridge contract mints CET.
CrosschainBurn
event CrosschainBurn(address indexed from, uint256 amount, address indexed sender)
Emitted when an authorized bridge contract burns CET.
Transfer
event Transfer(address indexed from, address indexed to, uint256 value)
Inherited from ERC20.
Approval
event Approval(address indexed owner, address indexed spender, uint256 value)
Inherited from ERC20.