dApp Setup

This guide covers how to configure and deploy a dApp on HyperEVM.


1. Setting Up Your Application

Before deploying contracts, your dApp needs a proper setup with wallet integration and blockchain connectivity. HyperEVM supports standard Ethereum libraries, ensuring compatibility with tools like:

  • Wagmi / Viem & Ethers – for seamless wallet connections.

  • Hyperliquid RPC endpoints – to interact with the blockchain.

For a step-by-step guide on setting up a Next.js application with Wagmi, refer to the Builder Codes Guide.


2. Deploying a Smart Contract on Hyperliquid EVM

Deploying a smart contract on Hyperliquid follows a similar workflow to Ethereum. You can use Foundry or Hardhat, two popular development frameworks.

1️⃣ Deploying with Foundry

Note: This is an old data sheet, so some details may not be accurate for HyperEVM. I haven’t tested deployment on HyperEVM yet, but an update is coming soon. For now, consider this a summary rather than a full guide.

  • Install & Update Foundry First, ensure you have Foundry installed and updated: ⚠️ Windows Users: Install WSLarrow-up-right or Git Basharrow-up-right to run these commands.

    curl -L https://foundry.paradigm.xyz | bash
    foundryup
  • Create a New Project

    forge init hello_foundry
    cd hello_foundry
  • (Optional) Link to GitHub:

    git remote add origin <REMOTE_URL>
    git remote -v
    echo "/lib/" >> .gitignore  # Ignore dependencies  
    git push -u origin main
  • Install Dependencies

    forge install openzeppelin/openzeppelin-contracts --no-commit
    • Configure remappings in foundry.toml:

      remappings = ['@openzeppelin=lib/openzeppelin-contracts']
  • Compile & Test

    forge build
    forge test -vvv
  • Deploy on a Local Devnet (Anvil) Start Anvil in a separate terminal:

    anvil
  • Deploy the contract: Create a Script and run this command:

    forge script script/Token.s.sol --rpc-url http://127.0.0.1:8545 --broadcast --private-key <PRIVATE_KEY>
  • Deploy on Testnet Add your testnet credentials to .env:

    SEPOLIA_RPC_URL=https://sepolia.infura.io/v3/YOUR_PROJECT_ID
    SEPOLIA_PRIVATE_KEY=YOUR_PRIVATE_KEY
    • Deploy on Sepolia:

      source .env
      forge script script/Token.s.sol --rpc-url $SEPOLIA_RPC_URL --private-key $SEPOLIA_PRIVATE_KEY --broadcast
    • Verify the contract automatically:

      ETHERSCAN_API_KEY=YOUR_KEY
      forge script script/Token.s.sol --rpc-url $SEPOLIA_RPC_URL --private-key $SEPOLIA_PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY
    • Check deployment on Etherscan: Take the transaction hash from the deployment output and search for it on Etherscanarrow-up-right to view your contract.

    • Verify an already deployed contract:

      forge verify-contract
      --chain-id 11155111
      --num-of-optimizations 1000000
      --watch
      --constructor-args $(cast abi-encode "constructor(string,string,uint256,uint256)" "ForgeUSD" "FUSD" 18 1000000000000000000000)
      --etherscan-api-key <your_etherscan_api_key>
      --compiler-version v0.8.10+commit.fc410830
      <the_contract_address>
      src/MyToken.sol:MyToken

2️⃣ Interacting with a Smart Contract

You can use Cast for direct terminal interaction or leverage Etherscan’s UI to read contract data and interact with smart contracts.

  • Managing Wallets

    • Import a wallet:

    • List available wallets:

    • Delete a wallet:

  • Calling Smart Contract Functions:

    • Read function:

    • Convert hex to decimal:

  • Write function

    • Send a transaction:

    • Send a transaction with multiple arguments:

    • Call a contract function and retrieve a stored value:

3️⃣ Understanding the Dual-Block Architecture

Hyperliquid EVM uses a dual-block system for transaction processing. By default, transactions go to small blocks, but deploying contracts efficiently may require big blocks. To enable this, submit an L1 action.

💡 For a deep dive into Dual-Block transactions, visit this guide.


3. dApp <--> Blockchain

To interact with a smart contract from your dApp’s frontend, you can use Ethers.js, Viem, or Wagmi. These tools allow you to read and write blockchain data, handle transactions, and manage wallet connections.

1️⃣ Setting Up the Contract ABI & Address

  • Extract the ABI from Foundry output: The ABI is located in out/ContractName.sol/ContractName.json.

  • Store the contract address as a constant:


2️⃣ Using Ethers.js

📌 Documentation: Ethers.js Docsarrow-up-right

🔹 Read Data (Call a View Function)

🔹 Write Data (Send a Transaction)


3️⃣ Using Viem

📌 Documentation: Viem Docsarrow-up-right

🔹 Read Data (Call a View Function)

🔹 Write Data (Send a Transaction)


4️⃣ Using Wagmi

📌 Documentation: Wagmi Docsarrow-up-right

🔹 Setting Up Wagmi Config - here

🔹 Read Data (Use Wagmi Hook)

🔹 Write Data (Use Wagmi Hook)

You can use Wagmi Core instead of React hooks. Hooks must follow React rules (e.g., they cannot be called inside functions or conditionally).

🔗 Learn more: Wagmi Core Documentationarrow-up-right

Last updated