Hardhat Example

Work in Progress -- This guide provides a starting point for developing smart contracts with Hardhat on the Lithosphere network. Full examples and detailed walkthroughs will be added as the @lithosphere/contracts package matures.


Overview

The @lithosphere/contracts package uses Hardhat as the primary smart contract development framework. It includes the following contracts:

Contract
Description

LITHO

Native blockchain token contract

LEP100

Multi-chain token standard implementation

WLITHO

Wrapped LITHO token implementation

Lep100Access

Access control for LEP100 operations

All contracts are written in Solidity 0.8.20+ and are compiled, tested, and deployed using Hardhat.


Basic Setup

Initialize a New Project

# Create a new directory
mkdir my-litho-contracts
cd my-litho-contracts

# Initialize npm
npm init -y

# Install Hardhat
npm install --save-dev hardhat

# Initialize Hardhat project
npx hardhat init

Select "Create a TypeScript project" when prompted. This generates a project structure with sample contracts, tests, and configuration.

Install Dependencies


Hardhat Configuration

Create or modify hardhat.config.ts to include the Lithosphere network:


Compiling Contracts

Compiled artifacts are output to the artifacts/ directory and type information to typechain-types/.


Running Tests


Deploying Contracts

Deploy to Local Hardhat Network

Deploy to Lithosphere Testnet

Deploy to Lithosphere Mainnet


Gas Reporting

Install the gas reporter plugin to monitor gas consumption:

Add to hardhat.config.ts:


Security Analysis

Run Slither for static analysis of your contracts:

For more comprehensive security testing, see the Foundry Example for fuzz testing with Forge.


Further Reading

Last updated