Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hardhat-nodejs-basic-config

deploy a solidity smart contract with hardhat and interact with it in nodejs.

install yarn (synthax depend of your distrib).

create a folder for the project and go into:

mkdir project_name
cd project_name
# init yarn project and install hardhat
yarn init
yarn add --dev hardhat
# 
yarn hardhat

Delete the Lock.sol contract, create a new file ContractExemple.sol, write your own smart contract

Go into scripts/deploys.sol and modify the file (code in the repo at scripts/deploy.ts)

# compile your contract:
yarn hardhat compile
# run the hardhat node:
yarn hardhat node

Open a new terminal window

# deploy the contract:
yarn hardhat run scripts/deploy.ts --network localhost

now the nodejs part

# Install nodemon, web3, ws and express
yarn add --dev nodemon
yarn add web3 ws express

write your nodejs script in server.mjs to interact with your smart contract and use his function

run the nodejs script :

npm run dev

good job !

About

deploy a solidity contract with hardhat and interact with it in nodejs

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.