Browse DIDLab Docs
Deployment · Hardhat
Compile locally and deploy to DIDLab
This public workflow uses Hardhat for compilation and a small ethers deployment script for the remote DIDLab transaction. It keeps the example transparent and avoids hiding deployment behavior behind a large project template.
Create a local project
Use a current Node.js development environment and a dedicated lab wallet. Create a project, initialize npm, and install Hardhat plus ethers.
mkdir didlab-simple-storage
cd didlab-simple-storage
npm init -y
npm pkg set type=module
npm install --save-dev hardhat
npm install ethersWallet safety
Initialize Hardhat and add the contract
Initialize a minimal Hardhat project, then place the contract below at contracts/SimpleStorage.sol.
npx hardhat --init// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
contract SimpleStorage {
uint256 private value;
event ValueChanged(uint256 value, address indexed changedBy);
function set(uint256 newValue) external {
value = newValue;
emit ValueChanged(newValue, msg.sender);
}
function get() external view returns (uint256) {
return value;
}
}Compile locally
npx hardhat compileExpected result
artifacts/contracts/SimpleStorage.sol/. The deployment script below reads that ABI and bytecode.Create the deployment script
Create scripts/deploy.mjs with the following example.
import fs from "node:fs";
import { ethers } from "ethers";
const rpcUrl = process.env.DIDLAB_RPC_URL;
const privateKey = process.env.DIDLAB_PRIVATE_KEY;
if (!rpcUrl || !privateKey) {
throw new Error("Set DIDLAB_RPC_URL and DIDLAB_PRIVATE_KEY first.");
}
const artifact = JSON.parse(
fs.readFileSync("./artifacts/contracts/SimpleStorage.sol/SimpleStorage.json", "utf8")
);
const provider = new ethers.JsonRpcProvider(rpcUrl);
const wallet = new ethers.Wallet(privateKey, provider);
const factory = new ethers.ContractFactory(artifact.abi, artifact.bytecode, wallet);
console.log("Deployer:", wallet.address);
const contract = await factory.deploy();
await contract.waitForDeployment();
const address = await contract.getAddress();
const deploymentTx = contract.deploymentTransaction();
console.log("Contract:", address);
console.log("Deployment tx:", deploymentTx?.hash);
const tx = await contract.set(42);
const receipt = await tx.wait();
console.log("set(42) tx:", receipt?.hash);
console.log("get():", (await contract.get()).toString());Set credentials without committing them
Set the DIDLab RPC URL and your disposable lab wallet key in the current shell. Do not put the key in source control.
export DIDLAB_RPC_URL=https://eth.didlab.org
export DIDLAB_PRIVATE_KEY='0xYOUR_DISPOSABLE_LAB_PRIVATE_KEY'
node scripts/deploy.mjsBefore deploying
Verify the output
The script prints the deployer address, contract address, deployment transaction hash, the set(42) transaction hash, and the final get() value. Search the addresses and hashes in Blockscout.
Public guide complete
At this point you have a reproducible source → compile → deploy → interact → verify workflow. The DIDLab Labs version extends this into testing, deployment automation, event validation, debugging, security analysis, and evidence capture.
Validation profile
Network
DIDLab Blockchain
Chain ID
252501
Client
Hyperledger Besu
Consensus
QBFT
Native asset
TRUST
Platform token
TT (ERC-20)
Solidity examples
0.8.24
Last validated
August 2026
Go deeper in DIDLab Labs
Public documentation explains the workflow and expected result. Authenticated DIDLab Labs adds managed workspaces, deeper exercises, checkpoints, evidence capture, and instructor assessment.
Open DIDLab Labs