Code Examples
Smart Contract Patterns
Tested Solidity patterns for the HyperEVM. These examples demonstrate how to leverage L1-native features from within your contracts.
1. Basic ERC-20 on HyperEVM
StandardHyperEVM is fully EVM-compatible, meaning you can deploy standard OpenZeppelin contracts without modification.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract HypeToken is ERC20 {
constructor() ERC20("HypeToken", "HYPE") {
_mint(msg.sender, 1000000 * 10 ** decimals());
}
}2. Interacting with L1 Precompiles
Native FeatureUse the L1_Orderbook precompile to query orderbook state directly from your contract.
interface IL1Orderbook {
function getMidPrice(string calldata asset) external view returns (uint256);
}
contract PriceConsumer {
IL1Orderbook public constant orderbook = IL1Orderbook(0x0000000000000000000000000000000000000101);
function getHypePrice() public view returns (uint256) {
return orderbook.getMidPrice("HYPE");
}
}Security Reminder
Always use the latest version of Solidity and perform audits on any contract handling significant user funds. HyperEVM's performance does not eliminate the need for standard smart contract security practices.