Intro to VeChain

Set up Hardhat for VeChain

Configure Hardhat so you can build smart contracts for VeChain

Setting Up Your Hardhat Project

In this lesson, you’ll set up a Solidity development environment using Hardhat, and configure it to deploy contracts to VeChain’s testnet.

Create a contracts/ directory

In your project root, create a folder to store your Solidity code and Hardhat files:

mkdir contracts
cd contracts

Install and Initialize Hardhat

npm install hardhat
npx hardhat init

Choose:

  • TypeScript project

  • Defaults for the rest

Update hardhat.config.ts for VeChain

Add these imports:

import { HardhatUserConfig } from "hardhat/config";
import { HttpNetworkConfig } from "hardhat/types";
import "@nomicfoundation/hardhat-ethers";
import "@vechain/sdk-hardhat-plugin";

Edit the config to include:

solidity: {
  version: "0.8.20",
  settings: {
    optimizer: { enabled: true, runs: 200 },
    evmVersion: "paris", // or "shanghai" if needed
  }
},
networks: {
  vechain_testnet: {
    url: "https://testnet.vechain.org",
    accounts: {
      mnemonic: "<YOUR_MNEMONIC>",
      path: "m/44'/818'/0'/0",
      count: 3,
      initialIndex: 0,
      passphrase: "vechainthor"
    },
    gas: "auto",
    gasPrice: "auto"
  }
}

What is <YOUR_MNEMONIC>?

This is the 12-word recovery phrase you get when creating your VeWorld wallet (or any other wallet). It grants Hardhat access to your testnet account, allowing it to sign and broadcast transactions.