# HyperEVM

HyperEVM is Hyperliquid's EVM-compatible chain that runs alongside the L1. It supports smart contract deployment, DeFi composability, and standard EVM transactions while leveraging Hyperliquid's high-performance order book.

## Chain configuration

| Property | Mainnet | Testnet |
|----------|---------|---------|
| Chain ID | 998 | 998 |
| RPC URL | `https://rpc.hyperliquid.xyz/evm` | `https://rpc.hyperliquid-testnet.xyz/evm` |
| Block explorer | `https://explorer.hyperliquid.xyz` | `https://explorer.hyperliquid-testnet.xyz` |
| Native token | HYPE | HYPE |

## Send a transaction

Use a backend wallet with viem to send transactions on HyperEVM:

```ts
import Openfort from '@openfort/openfort-node'
import { createWalletClient, http, defineChain } from 'viem'

const openfort = new Openfort(process.env.OPENFORT_SECRET_KEY!, {
  walletSecret: process.env.OPENFORT_WALLET_SECRET!,
})
const account = await openfort.accounts.evm.backend.create()

const hyperEvmTestnet = defineChain({
  id: 998,
  name: 'Hyperliquid EVM Testnet',
  nativeCurrency: { name: 'HYPE', symbol: 'HYPE', decimals: 18 },
  rpcUrls: {
    default: { http: ['https://rpc.hyperliquid-testnet.xyz/evm'] },
  },
  blockExplorers: {
    default: {
      name: 'Hyperliquid Explorer',
      url: 'https://explorer.hyperliquid-testnet.xyz',
    },
  },
})

const walletClient = createWalletClient({
  account,
  chain: hyperEvmTestnet,
  transport: http(),
})

const hash = await walletClient.sendTransaction({
  to: '0x...',
  value: 1000000000000000n, // 0.001 HYPE
})

console.log('Transaction hash:', hash)
```

## Deploy a contract

Deploy a smart contract using the same wallet client:

```ts
import { createWalletClient, http } from 'viem'

const walletClient = createWalletClient({
  account,
  chain: hyperEvmTestnet,
  transport: http(),
})

const hash = await walletClient.deployContract({
  abi: contractAbi,
  bytecode: contractBytecode,
  args: [/* constructor args */],
})

console.log('Deploy tx:', hash)
```

## Read contract state

Use a public client to read from deployed contracts:

```ts
import { createPublicClient, http } from 'viem'

const publicClient = createPublicClient({
  chain: hyperEvmTestnet,
  transport: http(),
})

const result = await publicClient.readContract({
  address: '0x...',
  abi: contractAbi,
  functionName: 'balanceOf',
  args: [account.address],
})
```

## Gas on HyperEVM

HyperEVM transactions require HYPE for gas. You can transfer HYPE to your backend wallet from an existing HyperEVM account.

:::info
For gas sponsorship on other EVM chains supported by Openfort, see [Gas sponsorship](/docs/configuration/gas-sponsorship). HyperEVM doesn't support ERC-4337 paymasters.
:::

## L1 to HyperEVM bridging

Hyperliquid provides native bridging between the L1 (trading) and HyperEVM layers. Use the `spotSend` action to transfer assets:

```ts
import * as hl from '@nktkas/hyperliquid'

const transport = new hl.HttpTransport({ isTestnet: true })
const exchange = new hl.ExchangeClient({ wallet: account, transport })

// Transfer USDC from L1 to HyperEVM
await exchange.spotSend({
  destination: account.address,
  token: 'USDC:0x...',
  amount: '100',
  toPerp: false,
})
```

## Best practices

* **Keep HyperEVM and L1 wallets separate** — use one backend wallet for trading (L1) and another for smart contract interactions (HyperEVM) to isolate risk
* **Fund HYPE for gas ahead of time** — HyperEVM transactions fail without HYPE; ensure your wallet has a buffer for gas spikes
* **Use public clients for reads** — only create a `walletClient` when you need to sign transactions; use `publicClient` for all read operations
* **Test contract deployments on testnet first** — HyperEVM testnet uses the same chain ID (998), so verify your contracts work before deploying to mainnet
