Skip to main content

setExternalChainAddress

Function Type: external
Function Signature: setExternalChainAddress(bytes32,string)
Access Control: onlyAdmin
Returns: void

Configures the external chain station address for all supported cross-chain protocols. This administrative function establishes the connection between the host chain station and its counterpart on external blockchains.

Parameters

ParameterTypeDescription
externalChainStationAddressBytes32bytes32External station address in bytes32 format (for Hyperlane and LayerZero)
externalChainStationAddressStringstringExternal station address in string format (for Axelar)

Access Control

modifier onlyAdmin() {
if (msg.sender != admin.current) {
revert();
}
_;
}

Only the current admin can call this function.

Workflow

1. Hyperlane Configuration

hyperlane.externalChainStationAddress = externalChainStationAddressBytes32;

Sets the external chain station address for Hyperlane protocol communication.

2. LayerZero Configuration

layerZero.externalChainStationAddress = externalChainStationAddressBytes32;

Sets the external chain station address for LayerZero protocol communication.

3. Axelar Configuration

axelar.externalChainStationAddress = externalChainStationAddressString;

Sets the external chain station address for Axelar protocol communication using string format.

4. LayerZero Peer Setup

_setPeer(
layerZero.externalChainStationEid,
layerZero.externalChainStationAddress
);

Establishes the peer relationship in LayerZero's OApp framework for secure message passing.

Protocol-Specific Address Formats

Hyperlane & LayerZero

  • Format: bytes32
  • Usage: Direct address representation for protocol routing
  • Example: 0x742d35Cc6634C0532925a3b8D43C1C16bE8c91234567... (truncated to 32 bytes)

Axelar

  • Format: string
  • Usage: Human-readable address for Axelar gateway calls
  • Example: "0x742d35Cc6634C0532925a3b8D43C1C16bE8c91234567"

Configuration Requirements

Before calling this function, ensure:

  1. External Station Deployment: The external chain station contract is deployed on the target blockchain
  2. Address Verification: Both address formats represent the same deployed contract
  3. Protocol Compatibility: The external station supports all three protocols (Hyperlane, LayerZero, Axelar)

Security Considerations

Address Validation

  • Critical Setup: Incorrect addresses will break cross-chain communication
  • No Reversal: Once set, addresses affect all future cross-chain operations
  • Format Consistency: Both bytes32 and string parameters must represent the same contract

Admin Control

  • Single Point: Only current admin can modify these addresses
  • Time Delay: Admin changes follow 1-day time delay governance (see Admin Functions)

Configuration Dependencies

This function configures addresses but relies on constructor initialization for:

  • Domain/Chain IDs: Set during contract deployment
  • Protocol Endpoints: Hyperlane mailbox, LayerZero endpoint, Axelar gateway addresses
  • Gas Service: Axelar gas service configuration

Protocol Integration Effects

Hyperlane

  • Messages sent to hyperlane.externalChainStationDomainId
  • Delivered to hyperlane.externalChainStationAddress
  • Authenticated by domain and address validation

LayerZero

  • Messages sent to layerZero.externalChainStationEid
  • Peer relationship established with layerZero.externalChainStationAddress
  • OApp security through trusted peer configuration

Axelar

  • Contract calls to axelar.externalChainStationChainName
  • Target address axelar.externalChainStationAddress
  • Gateway routing and execution validation

Error Conditions

ErrorCondition
Access Control RevertCalled by non-admin address
LayerZero Peer ErrorInvalid EID or address format for _setPeer

Usage Example

// Example configuration call
setExternalChainAddress(
0x742d35Cc6634C0532925a3b8D43C1C16bE8c9123456789abcdef123456789abcd, // bytes32 format
"0x742d35Cc6634C0532925a3b8D43C1C16bE8c91234567" // string format
);

Post-Configuration Verification

After calling this function, verify configuration through getter functions:

  • getHyperlaneConfig(): Confirm Hyperlane address setting
  • getLayerZeroConfig(): Confirm LayerZero address and peer setup
  • getAxelarConfig(): Confirm Axelar address setting
Critical Configuration

This function establishes the foundation for all cross-chain communication. Incorrect addresses will result in failed transfers and potential loss of funds. Always verify external station deployment and address accuracy before configuration.