Security News
JSR Working Group Kicks Off with Ambitious Roadmap andΒ Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software. It helps developers manage and automate the recurring tasks that are inherent to the process of building smart contracts and dApps, as well as easily introducing more functionality around this workflow.
Compiling Smart Contracts
Hardhat can compile your smart contracts using the Solidity compiler. You can specify the version of Solidity you want to use in the configuration file.
module.exports = {
solidity: "0.8.4",
};
Running Tests
Hardhat allows you to write tests for your smart contracts using popular testing frameworks like Mocha and Chai. This example shows a simple test for a token contract.
const { expect } = require("chai");
describe("Token contract", function () {
it("Deployment should assign the total supply of tokens to the owner", async function () {
const [owner] = await ethers.getSigners();
const Token = await ethers.getContractFactory("Token");
const hardhatToken = await Token.deploy();
const ownerBalance = await hardhatToken.balanceOf(owner.address);
expect(await hardhatToken.totalSupply()).to.equal(ownerBalance);
});
});
Deploying Contracts
Hardhat makes it easy to deploy your smart contracts to the Ethereum network. This script deploys a token contract and logs the address to which it was deployed.
async function main() {
const [deployer] = await ethers.getSigners();
console.log("Deploying contracts with the account:", deployer.address);
const Token = await ethers.getContractFactory("Token");
const token = await Token.deploy();
console.log("Token deployed to:", token.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
Debugging
Hardhat provides a powerful debugging tool that allows you to inspect the state of your contracts at any point in time. This example shows a custom task that prints the list of accounts.
const { task } = require("hardhat/config");
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const accounts = await hre.ethers.getSigners();
for (const account of accounts) {
console.log(account.address);
}
});
Truffle is a development environment, testing framework, and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. It offers similar functionalities to Hardhat, such as compiling, deploying, and testing smart contracts. However, Hardhat is often praised for its flexibility and the ease of integrating with other tools.
Embark is a framework for serverless Decentralized Applications using Ethereum, IPFS, and other platforms. It allows for easy development and deployment of smart contracts and dApps. Compared to Hardhat, Embark offers more out-of-the-box integrations with decentralized storage and communication protocols.
Brownie is a Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine. It is similar to Hardhat in terms of functionalities but is more suited for developers who prefer Python over JavaScript.
Hardhat is an Ethereum development environment for professionals. It facilitates performing frequent tasks, such as running tests, automatically checking code for mistakes or interacting with a smart contract. Check out the plugin list to use it with your existing tools.
Developed by Nomic Labs and funded by an Ethereum Foundation grant.
Join our Hardhat Support Discord server to stay up to date on new releases, plugins and tutorials.
π§ You are looking at the development branch of Hardhat. For the currently released versions of Hardhat and its plugins take a look at this repository's tags. π§
To install Hardhat, go to an empty folder, initialize an npm
project (i.e. npm init
), and run
npm install --save-dev hardhat
Once it's installed, just run this command and follow its instructions:
npx hardhat
On Hardhat's website you will find:
Contributions are always welcome! Feel free to open any issue or send a pull request.
Go to CONTRIBUTING.md to learn about how to set up Hardhat's development environment.
Hardhat Support Discord server: for questions and feedback.
π·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈπ·ββοΈ
FAQs
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
The npm package hardhat receives a total of 177,494 weekly downloads. As such, hardhat popularity was classified as popular.
We found that hardhat demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.