Hardhat Installation & Deploy Liquidity Provision Contract that integrates with X-Talk Swap

Liquidity Provision Contract integrates with X-Talk Swap Contract to provide liquidity for swaps. Liquidity provision contracts are one of the examples of the use case of X-Talk Swaps.

Step 1: Initialize a New Project

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

    mkdir stake-contract
    cd stake-contract
  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 init

    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 @nomiclabs/hardhat-ethers ethers
    npm install hardhat-gas-reporter
    npm install @nomicfoundation/hardhat-toolbox
    npm install hardhat/config

At this stage, you project structure would look like this.

Step 4: Write your smart contract

Create the Contract: Create StakeContract.sol inside the contracts directory and paste your contract code there.

Step 5: General and Network configuration

Create a config folder inside your project and create two configurations files viz. general.json and networkWise.json as shown below.

List of predefined evm-compatible blockchain networks are listed in networkWise.json. You can get the list of authentic XTALK_GATEWAY_CONTRACT_ADDRESS from the table.

Step 6: Compile and Deploy Your Contracts

  1. Compile your project:

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

At this stage, your project structure looks like this:

  1. Sample Hardhat Config JS File: Configure your Hardhat project by editing hardhat.config.js. Add your network in this file with relevant details. Ensure it looks like this:

-- Check Endpoint for L1X TestNet Faucet Before Deployment

  1. Deployment Bash

Last updated