Build with Hardhat
Hardhat is a development environment to compile, deploy, test, and debug your EVM-compatible applications. It helps developers manage and automate the recurring tasks inherent to the process of building smart contracts, as well as easily integrating with various plugins to extend its functionality. With Hardhat, you can write and run tests, script deployments, and interact with your contracts.
VeChain's SDK provides a plugin to instantly enable connectivity.
The example project is relying on hardhat version 2.22.15 and the project initiated with npx hardhat init.
Setup Hardhat
Setup
To bootstrap a hardhat project:
npm install --save-dev hardhat
npx hardhat initInstall Hardhat Plugin
To add VeChain support, install the hardhat plugin:
npm install --save-dev @vechain/sdk-hardhat-pluginConfigure
Import or require the plugin in your hardhat.config.ts file:
import '@vechain/sdk-hardhat-plugin'Add a network for TestNet or MainNet:
The Hardhat plugin requires
vechainin the network's name.Remote accounts are unsupported; therefore, provide account information.
Configure the solidity compile to Paris (or version that VeChain is compatible with)
A fully functional example configuration with:
defined accounts to use
fee delegation using vechain energy
networks for mainnet, testnet, solo and hardhard
OpenZeppelin Contracts
Bootstrap your smart contract creation with OpenZeppelin contracts. A compilation of widely used standards and patterns can significantly speed up the development process.
Install
Install contract libraries and Hardhat helpers:
Create a ERC20 Token
Create contracts/GLDToken.sol and save this example:
Run the following command to compile your contract:
https://wizard.openzeppelin.com provides an easy-to-use web interface for generating basic smart contracts.
Deployment Contract
With hardhat-deploy, deployments can be managed automatically without tracking the addresses of deployed contracts or manually upgrading contracts.
Create a deployment script in deploy/MyToken.ts:
To execute the deploy script, specifying the network to deploy to:
If a contract changes, deployment will automatically take place.
The status of deployments is stored in deployments/<network name>. Check out hardhat-deploy to learn more about its features and best practices.
Example
The above steps are available in an example project with the SDK repository: Example App
Last updated
Was this helpful?