Overview
Hardhat is a development environment for Ethereum software that provides tools for editing, compiling, debugging, and deploying smart contracts and dApps.
The Fireblocks Hardhat Plugin integrates Fireblocks' secure transaction features into your Hardhat workflow, enabling secure deployment and transaction signing.
Using Hardhat
To use the Fireblocks Hardhat Plugin, you must have Hardhat installed.
You can follow our abridged Hardhat installation steps below or skip to the Fireblocks Hardhat Plugin section if you already have Hardhat installed.
Install Hardhat
If you need to install Hardhat, you can use our abridged installation guide below. For a complete guide, refer to the official Hardhat installation guide.
Abridged Hardhat installation guide
- Install the Hardhat package:
npm install --save-dev hardhat
- Initialize a new Hardhat project:
npx hardhat
This generates the following Hardhat menu display:
888 888 888 888 888
888 888 888 888 888
888 888 888 888 888
8888888888 8888b. 888d888 .d88888 88888b. 8888b. 888888
888 888 "88b 888P" d88" 888 888 "88b "88b 888
888 888 .d888888 888 888 888 888 888 .d888888 888
888 888 888 888 888 Y88b 888 888 888 888 888 Y88b.
888 888 "Y888888 888 "Y88888 888 888 "Y888888 "Y888
👷 Welcome to Hardhat v2.10.1 👷
? What do you want to do? …
❯ Create a JavaScript project
Create a TypeScript project
Create an empty hardhat.config.js
- Select Create a JavaScript project and press Enter.
- Follow the proceeding setup prompts.
Complete these steps to generate a new JavaScript Hardhat project in your current directory.
Fireblocks Plugin
The Fireblocks Hardhat Plugin helps seamlessly integrate Fireblocks into your Hardhat development stack. You can use it to deploy contracts, sign messages, and send transactions securely through Fireblocks.
Installing the Hardhat plugin
- Install the plugin package:
npm install @fireblocks/hardhat-fireblocks
- Import the plugin into your
hardhat.config.js
file:
require("@fireblocks/hardhat-fireblocks");
const { ApiBaseUrl } = require("@fireblocks/fireblocks-web3-provider");
require('dotenv').config();
Configuring the Hardhat plugin
This plugin extends the HttpNetworkUserConfig
object with an optional fireblocks
field.
- For this example, copy the code sample below into your
hardhat.config.js
configuration file:
module.exports = {
solidity: "0.8.17",
networks: {
sepolia: {
url: "https://sepolia.drpc.org",
fireblocks: {
apiBaseUrl: ApiBaseUrl.Sandbox, // Only use in a Sandbox workspace
privateKey: process.env.FIREBLOCKS_API_PRIVATE_KEY_PATH,
apiKey: process.env.FIREBLOCKS_API_KEY,
vaultAccountIds: process.env.FIREBLOCKS_VAULT_ACCOUNT_IDS,
}
},
},
};
Working in Sandbox
If you are not using a Sandbox workspace, remove the
apiBaseUrl
line.
- Delete the
Lock.sol
file that came with your generated Hardhat environment:
rm contracts/Lock.sol
Deploy a contract using Hardhat Ignition
Now that your Hardhat plugin has been configured to work with Fireblocks, you can begin deploying a smart contract to the Sepolia Ethereum Testnet.
Create and compile the Solidity file
- Create a Solidity file in your project folder:
touch contracts/HelloWorld.sol
- Copy the following code sample into your
HelloWorld.sol
file:
pragma solidity ^0.8.17;
contract HelloWorld {
string public greet = "Hello World!";
}
- Run the following command to compile the project:
npx hardhat compile
Update and deploy the script
- Create a new file
ignition/modules/HelloWorld.js
and add the following module definition:
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");
module.exports = buildModule("HelloWorld", (m) => {
const helloWorld = m.contract("HelloWorld");
return { helloWorld };
});
- Deploy your contract to the Ethereum Sepolia Testnet using Hardhat Ignition:
npx hardhat ignition deploy ignition/modules/HelloWorld.js --network sepolia
This should take a couple of minutes to run if everything was configured correctly.
Once the deploy script has finished running successfully, the following message will appear:
Hardhat Ignition 🚀
Deploying [ HelloWorld ]
Batch #1
Executed HelloWorld#HelloWorld
[ HelloWorld ] successfully deployed 🚀
Deployed Addresses
HelloWorld#HelloWorld - <contract_address>
Post-deployment
Hardhat Ignition creates an ignition/deployments/chain-11155111
folder for Sepolia that contains all the deployment details. This data enables Hardhat Ignition to recover from errors, resume interrupted deployments, and manage deployment states.
Summary
You have now integrated the Fireblocks Hardhat Plugin into your Ethereum development workflow and deployed a smart contract to the Sepolia Testnet using Hardhat Ignition! This setup enables you to securely deploy contracts and manage transactions with Fireblocks’ infrastructure.