Skip to main content

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 remoteAsset and remoteChainID
  • Supporting bridge-controlled supply changes through crosschainMint(...) and crosschainBurn(...)
  • 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.

ParameterTypeDescription
namestringToken name
symbolstringToken symbol
decimalsuint8Token decimals

Requirements:

  • Only the contract owner can call this function
  • Metadata can only be initialized once

Process:

  1. Validates that the caller is the contract owner
  2. Validates that metadata has not already been initialized
  3. Stores the token name, symbol, and decimals

authorizeBridge(_bridge)

Description: Authorizes a bridge contract to mint and burn this token during bridge execution.

ParameterTypeDescription
bridgeaddressBridge contract address to authorize

Requirements:

  • Only the contract owner can call this function

Process:

  1. Validates that the caller is the contract owner
  2. Marks the provided bridge as authorized

Events:

  • BridgeAuthorized(address bridge)

revokeBridge(_bridge)

Description: Removes bridge authorization from a contract address.

ParameterTypeDescription
bridgeaddressBridge contract address to revoke

Requirements:

  • Only the contract owner can call this function

Process:

  1. Validates that the caller is the contract owner
  2. Removes bridge authorization for the provided address

Events:

  • BridgeRevoked(address bridge)

crosschainMint(to, amount)

Description: Mints CET to the target account during bridge execution.

ParameterTypeDescription
toaddressRecipient account
amountuint256Amount to mint

Requirements:

  • Only an authorized bridge contract can call this function

Process:

  1. Verifies that the caller is an authorized bridge
  2. 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.

ParameterTypeDescription
fromaddressAccount to burn from
amountuint256Amount to burn

Requirements:

  • Only an authorized bridge contract can call this function

Process:

  1. Verifies that the caller is an authorized bridge
  2. 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): CORE for a native canonical CET, or WRAPPED for 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.