Hardhat Installation & Deploy your First L1X EVM FT Contract

You can use Hardhat and Ethers to Compile, Deploy and Interact with Contracts on L1X EVM.

Step 1: Initialize a New Project

  1. Create a New Directory (if you're starting fresh):

    mkdir L1XEVMERC20
    cd L1XEVMERC20
    
  2. Initialize a new NPM project:

    npm init -y
    

Step 2: Install Hardhat and Set Up the Project

  1. Install Hardhat:

    npm install --save-dev hardhat
    
  2. Set up the Hardhat project: Run the setup command and choose to create a TypeScript project:

    npx hardhat
    

    When prompted, select to create a TypeScript project. Follow the prompts to add a .gitignore and install the project's dependencies.

Step 3: Install Necessary Plugins and Dependencies

  1. Install TypeScript-related dependencies:

    npm install --save-dev ts-node typescript @types/node @types/mocha
    
  2. Install OpenZeppelin Contracts:

    npm install @openzeppelin/contracts
    
  3. Install Ethers and Hardhat Ethers (ensure compatibility):

    npm install --save-dev ethers @nomicfoundation/hardhat-ethers
    

Step 4: Configure TypeScript

  1. Create a tsconfig.json file in your project root with the following content:

Step 5: Write Your Smart Contract

  1. Create an ERC20 token using OpenZeppelin: Create a contracts/Token.sol file:

Step 7: Compile Your Contracts

  1. Compile your project:

  2. Write deployment scripts or tests as needed, using the setup you've created. Example Provided below.

Sample Hardhat Config TS File

-- Check Endpoint for L1X TestNet Faucet Before Deployment

Deployment Bash

Deployment Result

Last updated