With Hardhat

Let's go through the process of deploying a smart contract on Ethernity Chain using Hardhat and TypeScript.

Requirements

1. Initialize a Hardhat TypeScript project

Open your terminal and create a new directory for your project, then navigate into it:

mkdir hello && cd hello

Initialize an npm project:

npm init -y

Install the necessary packages for Hardhat and TypeScript:

npm install --save-dev hardhat ts-node typescript @nomiclabs/hardhat-ethers ethers

Start a new Hardhat project with TypeScript:

npx hardhat init

When prompted, make the following selections:

  • Choose "Create a TypeScript project".

  • For the .gitignore prompt, select "Yes" (or y).

  • For installing the projects dependencies select "Yes" (or y).

2. Write a Smart Contract

In the contracts directory, delete the sample smart contract Lock.sol and then create a new file named Hello.sol:

Copy

3. Configure Harhdat for Ethernity

Edit the hardhat.config.ts file to include Ethernity Chain Testnet settings:

Replace PRIVATE_KEY with your Ethereum wallet private key.

IMPORTANT: Do not push your hardhat.config.ts file to github or share your private key with anyone.

4. Compile

Compile the smart contract:

5. Deploy

In the scripts directory, create a new file named deploy.ts:

Now you can deploy the smart contract to Ethernity Testnet:

6. Check

See your smart contract's deployment on the Ethernity Testnet block explorer (ERNScan): https://testnet.ernscan.ioarrow-up-right. Enter the contract address from the command line in the search bar to see the details.

Last updated