Skip to content

CoreWriterLib

A lightweight helper library that makes it trivial to perform CoreWriter actions and bridge assets between HyperEVM and Core, while handling common foot‑guns:

  • Converts EVM decimals ⇄ HyperCore's “wei” decimals using HLConversions
  • Computes system addresses for spot/bridging
  • Performs sanity checks (e.g., zero‑amount after conversion, vault lock checks, self‑transfer guards)

Usage

Import

import {CoreWriterLib} from "@hyper-evm-lib/src/CoreWriterLib.sol";

Sample usage

/// @notice Bridges tokens to core and then sends them to another address
function bridgeToCoreAndSend(address tokenAddress, uint256 evmAmount, address recipient) external payable {
 
    // use CoreWriterLib to bridge tokens
    CoreWriterLib.bridgeToCore(tokenAddress, evmAmount);
 
    // Convert EVM amount to wei amount (used in HyperCore)
    uint64 coreAmount = HLConversions.evmToWei(tokenId, evmAmount);
 
    // use CoreWriterLib to call the spotSend CoreWriter action
    CoreWriterLib.spotSend(recipient, tokenId, coreAmount);
}

See Examples for more examples on how CoreWriterLib can be used.