Skip to content
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
f0db4ee
create compile, deploy and install and config pages
kapetan3sid Oct 28, 2025
5db7554
Update smart-contracts/dev-environments/hardhat/install-and-config.md
kapetan3sid Oct 28, 2025
0b2b8d7
Update smart-contracts/dev-environments/hardhat/deploy-a-contract.md
kapetan3sid Oct 28, 2025
46cce6c
Update smart-contracts/dev-environments/hardhat/compile-and-test.md
kapetan3sid Oct 28, 2025
bc21b7d
Update smart-contracts/dev-environments/hardhat/compile-and-test.md
kapetan3sid Oct 28, 2025
1101f0f
Update smart-contracts/dev-environments/hardhat/compile-and-test.md
kapetan3sid Oct 28, 2025
d69928e
Update smart-contracts/dev-environments/hardhat/compile-and-test.md
kapetan3sid Oct 28, 2025
f16844e
Update smart-contracts/dev-environments/hardhat/compile-and-test.md
kapetan3sid Oct 28, 2025
166a957
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
f9c843e
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
5fa53d2
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
f5263ad
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
1e36a3f
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
359acf0
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
4ad3a8d
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
87cd478
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
3ee75a9
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
c0e2739
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
9a86f5f
Apply suggestion from @github-actions[bot]
kapetan3sid Oct 28, 2025
010c0a5
Refactor Hardhat docs from hardhat-polkadot to standard Hardhat
kapetan3sid Nov 7, 2025
46636ac
add install and config page
kapetan3sid Nov 7, 2025
0ce2082
add compile and test page
kapetan3sid Nov 7, 2025
c018369
add code snipped for local node
kapetan3sid Nov 7, 2025
f6aa9ef
add deploy page fixes
kapetan3sid Nov 7, 2025
0b9a271
Update smart-contracts/dev-environments/hardhat/install-and-config.md
kapetan3sid Nov 7, 2025
f3f7e10
minor snippet fix
kapetan3sid Nov 7, 2025
6c6d5c9
Apply suggestions from code review
kapetan3sid Nov 7, 2025
ed371f5
correct syntax issue
kapetan3sid Nov 7, 2025
7b32ba6
apply feedback
kapetan3sid Nov 10, 2025
2a547ae
Apply suggestions from code review
kapetan3sid Nov 10, 2025
a8ce5c9
Update smart-contracts/dev-environments/hardhat/deploy-a-contract.md
kapetan3sid Nov 10, 2025
f7b8fd2
Update smart-contracts/dev-environments/hardhat/deploy-a-contract.md
kapetan3sid Nov 10, 2025
2a064d8
Update smart-contracts/dev-environments/hardhat/deploy-a-contract.md
kapetan3sid Nov 10, 2025
133bbbf
fix code snippet formatting
eshaben Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<div id="termynal" data-termynal>
<span data-ty="input"><span class="file-path"></span>npx hardhat node</span>
<span data-ty>Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/</span>
<span data-ty></span>
<span data-ty>Accounts</span>
<span data-ty>========</span>
<span data-ty></span>
<span data-ty>WARNING: These accounts, and their private keys, are publicly known.</span>
<span data-ty>Any funds sent to them on Mainnet or any other live network WILL BE LOST.</span>
<span data-ty></span>
<span data-ty>Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH)</span>
<span data-ty>Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80</span>
<span data-ty></span>
<span data-ty>Account #1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 (10000 ETH)</span>
<span data-ty>Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d</span>
<span data-ty></span>
<span data-ty>Account #2: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC (10000 ETH)</span>
<span data-ty>Private Key: 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a</span>
<span data-ty></span>
<span data-ty>Account #3: 0x90F79bf6EB2c4f870365E785982E1f101E93b906 (10000 ETH)</span>
<span data-ty>Private Key: 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6</span>
<span data-ty></span>
<span data-ty>Account #4: 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 (10000 ETH)</span>
<span data-ty>Private Key: 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a</span>
<span data-ty></span>
<span data-ty>Account #5: 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc (10000 ETH)</span>
<span data-ty>Private Key: 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba</span>
<span data-ty></span>
<span data-ty>Account #6: 0x976EA74026E726554dB657fA54763abd0C3a0aa9 (10000 ETH)</span>
<span data-ty>Private Key: 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e</span>
<span data-ty></span>
<span data-ty>Account #7: 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 (10000 ETH)</span>
<span data-ty>Private Key: 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356</span>
<span data-ty></span>
<span data-ty>Account #8: 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f (10000 ETH)</span>
<span data-ty>Private Key: 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97</span>
<span data-ty></span>
<span data-ty>Account #9: 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 (10000 ETH)</span>
<span data-ty>Private Key: 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6</span>
<span data-ty></span>
<span data-ty>Account #10: 0xBcd4042DE499D14e55001CcbB24a551F3b954096 (10000 ETH)</span>
<span data-ty>Private Key: 0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897</span>
<span data-ty></span>
<span data-ty>Account #11: 0x71bE63f3384f5fb98995898A86B02Fb2426c5788 (10000 ETH)</span>
<span data-ty>Private Key: 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82</span>
<span data-ty></span>
<span data-ty>Account #12: 0xFABB0ac9d68B0B445fB7357272Ff202C5651694a (10000 ETH)</span>
<span data-ty>Private Key: 0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1</span>
<span data-ty></span>
<span data-ty>Account #13: 0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec (10000 ETH)</span>
<span data-ty>Private Key: 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd</span>
<span data-ty></span>
<span data-ty>Account #14: 0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097 (10000 ETH)</span>
<span data-ty>Private Key: 0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa</span>
<span data-ty></span>
<span data-ty>Account #15: 0xcd3B766CCDd6AE721141F452C550Ca635964ce71 (10000 ETH)</span>
<span data-ty>Private Key: 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61</span>
<span data-ty></span>
<span data-ty>Account #16: 0x2546BcD3c84621e976D8185a91A922aE77ECEc30 (10000 ETH)</span>
<span data-ty>Private Key: 0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0</span>
<span data-ty></span>
<span data-ty>Account #17: 0xbDA5747bFD65F08deb54cb465eB87D40e51B197E (10000 ETH)</span>
<span data-ty>Private Key: 0x689af8efa8c651a91ad287602527f3af6b827f2a8bce2897751d06a843f64496</span>
<span data-ty></span>
<span data-ty>Account #18: 0xdD2FD4581271e230360230F9337D5c0430Bf44C0 (10000 ETH)</span>
<span data-ty>Private Key: 0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0</span>
<span data-ty></span>
<span data-ty>Account #19: 0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 (10000 ETH)</span>
<span data-ty>Private Key: 0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e</span>
<span data-ty></span>
<span data-ty>WARNING: These accounts, and their private keys, are publicly known.</span>
<span data-ty>Any funds sent to them on Mainnet or any other live network WILL BE LOST.</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<div id="termynal" data-termynal class="table-termynal">
<span data-ty="input"><span class="file-path"></span>npx hardhat test</span>
<span data-ty></span>
<span data-ty> Lock</span>
<span data-ty> Deployment</span>
<span data-ty> ✔ Should set the right unlockTime (38ms)</span>
<span data-ty> ✔ Should set the right owner</span>
<span data-ty> ✔ Should receive and store the funds to lock</span>
<span data-ty> ✔ Should fail if the unlockTime is not in the future</span>
<span data-ty> Withdrawals</span>
<span data-ty> Validations</span>
<span data-ty> ✔ Should revert with the right error if called too soon</span>
<span data-ty> ✔ Should revert with the right error if called from another account</span>
<span data-ty> ✔ Shouldn't fail if the unlockTime has arrived and the owner calls it</span>
<span data-ty> Events</span>
<span data-ty> ✔ Should emit an event on withdrawals</span>
<span data-ty> Transfers</span>
<span data-ty> ✔ Should transfer the funds to the owner</span>
<span data-ty></span>
<span data-ty></span>
<span data-ty> 9 passing (66ms)</span>
<span data-ty></span>
<span data-ty>·············································································································</span>
<span data-ty>| Solidity and Network Configuration │</span>
<span data-ty>························|·················|···············|·················|································</span>
<span data-ty>| Solidity: 0.8.28 · Optim: false · Runs: 200 · viaIR: false · Block: 30,000,000 gas │</span>
<span data-ty>························|·················|···············|·················|································</span>
<span data-ty>| Methods │</span>
<span data-ty>························|·················|···············|·················|················|···············</span>
<span data-ty>| Contracts / Methods · Min · Max · Avg · # calls · usd (avg) │</span>
<span data-ty>························|·················|···············|·················|················|···············</span>
<span data-ty>| Lock · │</span>
<span data-ty>························|·················|···············|·················|················|···············</span>
<span data-ty>| withdraw · - · - · 34,096 · 7 · - │</span>
<span data-ty>························|·················|···············|·················|················|···············</span>
<span data-ty>| Deployments · · % of limit · │</span>
<span data-ty>························|·················|···············|·················|················|···············</span>
<span data-ty>| Lock · - · - · 326,112 · 1.1 % · - │</span>
<span data-ty>························|·················|···············|·················|················|···············</span>
<span data-ty>| Key │</span>
<span data-ty>·············································································································</span>
<span data-ty>| ◯ Execution gas for this method does not include intrinsic gas overhead │</span>
<span data-ty>·············································································································</span>
<span data-ty>| △ Cost was non-zero but below the precision setting for the currency display (see options) │</span>
<span data-ty>·············································································································</span>
<span data-ty>| Toolchain: hardhat │</span>
<span data-ty>·············································································································</span>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const hre = require('hardhat');

async function main() {
// Get the contract factory
const Lock = await hre.ethers.getContractFactory('Lock');

// Replace with your deployed contract address
const contractAddress = '0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3';

// Attach to existing contract
const lock = await Lock.attach(contractAddress);

// Get signers
const [deployer] = await hre.ethers.getSigners();

// Read contract state
const unlockTime = await lock.unlockTime();
console.log(`Unlock time: ${unlockTime}`);

const balance = await lock.owner();
console.log(`Owner: ${balance}`);
}

main().catch((error) => {
console.error(error);
process.exitCode = 1;
});

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

87 changes: 86 additions & 1 deletion smart-contracts/dev-environments/hardhat/compile-and-test.md
Original file line number Diff line number Diff line change
@@ -1 +1,86 @@
TODO
---
title: Compile and Test Smart Contracts with Hardhat
description: Learn how to compile Solidity contracts for PolkaVM compatibility and test them using Hardhat's testing framework on the Polkadot Hub.
categories: Smart Contracts, Tooling
---

# Compile and Test Smart Contracts

## Compile Your Contract

Hardhat compiles your Solidity contracts using the Solidity compiler (solc). The compilation process generates the ABI and bytecode needed for deployment and interaction.

To compile your project, follow these instructions:

1. Make sure that your Hardhat configuration file matches the Solidity compiler version shown in the code snippet below:

```javascript title="hardhat.config.js"
require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
solidity: "0.8.28",
};
```

2. Compile the contract with Hardhat:

```bash
npx hardhat compile
```

After successful compilation, you will see the artifacts generated in the `artifacts` directory:

```bash
ls artifacts/contracts/*.sol/
```

You should see JSON files containing the contract ABI and bytecode of the contracts you compiled.

## Set Up a Testing Environment

Hardhat provides a built-in local Ethereum network for testing. You can use this network to run your tests without deploying to a live network.

Start the local Hardhat network with:

```bash
npx hardhat node
```

This command will launch a local Ethereum network on `http://127.0.0.1:8545` with 19 test accounts, each pre-funded with 10,000 ETH. The network will display all RPC calls and contract deployments in real-time.

The output will be something like this:

--8<-- 'code/smart-contracts/dev-environments/hardhat/compile-and-test/hardhat-node-output.html'

## Test Your Contract

Hardhat uses [Mocha](https://mochajs.org/){target=\_blank} as its testing framework and [Chai](https://www.chaijs.com/){target=\_blank} for assertions, both included in the [Hardhat Toolbox](https://v2.hardhat.org/hardhat-runner/plugins/nomicfoundation-hardhat-toolbox){target=\_blank}.

To run your tests execute the following command to run your tests:

```bash
npx hardhat test
```

This will run all test files in the `test` directory. Hardhat automatically manages the test network lifecycle, so you don't need to run `npx hardhat node` separately for testing.

If you are testing `Lock.sol` contract, output should look like this:

--8<-- 'code/smart-contracts/dev-environments/hardhat/compile-and-test/test.html'

## Where to Go Next

Now that you've successfully compiled and tested your smart contracts, you're ready to deploy them to a live network. The deployment guide will walk you through deploying your contract to Local Development Network, interacting with it using Hardhat scripts, and verifying your deployment.

<div class="grid cards" markdown>

- <span class="badge guide">Guide</span> __Deploy a Contract__

---

Learn how to deploy your compiled smart contract to Polkadot Hub TestNet and interact with it using deployment scripts.

[:octicons-arrow-right-24: Get Started](/smart-contracts/dev-environments/hardhat/deploy-a-contract)

</div>
Loading
Loading