Skip to content

Commit 7b32ba6

Browse files
committed
apply feedback
1 parent ed371f5 commit 7b32ba6

File tree

9 files changed

+207
-137
lines changed

9 files changed

+207
-137
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<div id="termynal" data-termynal>
2+
<span data-ty="input"><span class="file-path"></span>npx hardhat node</span>
3+
<span data-ty>Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/</span>
4+
<span data-ty></span>
5+
<span data-ty>Accounts</span>
6+
<span data-ty>========</span>
7+
<span data-ty></span>
8+
<span data-ty>WARNING: These accounts, and their private keys, are publicly known.</span>
9+
<span data-ty>Any funds sent to them on Mainnet or any other live network WILL BE LOST.</span>
10+
<span data-ty></span>
11+
<span data-ty>Account #0: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000 ETH)</span>
12+
<span data-ty>Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80</span>
13+
<span data-ty></span>
14+
<span data-ty>Account #1: 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 (10000 ETH)</span>
15+
<span data-ty>Private Key: 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d</span>
16+
<span data-ty></span>
17+
<span data-ty>Account #2: 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC (10000 ETH)</span>
18+
<span data-ty>Private Key: 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a</span>
19+
<span data-ty></span>
20+
<span data-ty>Account #3: 0x90F79bf6EB2c4f870365E785982E1f101E93b906 (10000 ETH)</span>
21+
<span data-ty>Private Key: 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6</span>
22+
<span data-ty></span>
23+
<span data-ty>Account #4: 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 (10000 ETH)</span>
24+
<span data-ty>Private Key: 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a</span>
25+
<span data-ty></span>
26+
<span data-ty>Account #5: 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc (10000 ETH)</span>
27+
<span data-ty>Private Key: 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba</span>
28+
<span data-ty></span>
29+
<span data-ty>Account #6: 0x976EA74026E726554dB657fA54763abd0C3a0aa9 (10000 ETH)</span>
30+
<span data-ty>Private Key: 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e</span>
31+
<span data-ty></span>
32+
<span data-ty>Account #7: 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 (10000 ETH)</span>
33+
<span data-ty>Private Key: 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356</span>
34+
<span data-ty></span>
35+
<span data-ty>Account #8: 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f (10000 ETH)</span>
36+
<span data-ty>Private Key: 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97</span>
37+
<span data-ty></span>
38+
<span data-ty>Account #9: 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 (10000 ETH)</span>
39+
<span data-ty>Private Key: 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6</span>
40+
<span data-ty></span>
41+
<span data-ty>Account #10: 0xBcd4042DE499D14e55001CcbB24a551F3b954096 (10000 ETH)</span>
42+
<span data-ty>Private Key: 0xf214f2b2cd398c806f84e317254e0f0b801d0643303237d97a22a48e01628897</span>
43+
<span data-ty></span>
44+
<span data-ty>Account #11: 0x71bE63f3384f5fb98995898A86B02Fb2426c5788 (10000 ETH)</span>
45+
<span data-ty>Private Key: 0x701b615bbdfb9de65240bc28bd21bbc0d996645a3dd57e7b12bc2bdf6f192c82</span>
46+
<span data-ty></span>
47+
<span data-ty>Account #12: 0xFABB0ac9d68B0B445fB7357272Ff202C5651694a (10000 ETH)</span>
48+
<span data-ty>Private Key: 0xa267530f49f8280200edf313ee7af6b827f2a8bce2897751d06a843f644967b1</span>
49+
<span data-ty></span>
50+
<span data-ty>Account #13: 0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec (10000 ETH)</span>
51+
<span data-ty>Private Key: 0x47c99abed3324a2707c28affff1267e45918ec8c3f20b8aa892e8b065d2942dd</span>
52+
<span data-ty></span>
53+
<span data-ty>Account #14: 0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097 (10000 ETH)</span>
54+
<span data-ty>Private Key: 0xc526ee95bf44d8fc405a158bb884d9d1238d99f0612e9f33d006bb0789009aaa</span>
55+
<span data-ty></span>
56+
<span data-ty>Account #15: 0xcd3B766CCDd6AE721141F452C550Ca635964ce71 (10000 ETH)</span>
57+
<span data-ty>Private Key: 0x8166f546bab6da521a8369cab06c5d2b9e46670292d85c875ee9ec20e84ffb61</span>
58+
<span data-ty></span>
59+
<span data-ty>Account #16: 0x2546BcD3c84621e976D8185a91A922aE77ECEc30 (10000 ETH)</span>
60+
<span data-ty>Private Key: 0xea6c44ac03bff858b476bba40716402b03e41b8e97e276d1baec7c37d42484a0</span>
61+
<span data-ty></span>
62+
<span data-ty>Account #17: 0xbDA5747bFD65F08deb54cb465eB87D40e51B197E (10000 ETH)</span>
63+
<span data-ty>Private Key: 0x689af8efa8c651a91ad287602527f3af6b827f2a8bce2897751d06a843f64496</span>
64+
<span data-ty></span>
65+
<span data-ty>Account #18: 0xdD2FD4581271e230360230F9337D5c0430Bf44C0 (10000 ETH)</span>
66+
<span data-ty>Private Key: 0xde9be858da4a475276426320d5e9262ecfc3ba460bfac56360bfa6c4c28b4ee0</span>
67+
<span data-ty></span>
68+
<span data-ty>Account #19: 0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199 (10000 ETH)</span>
69+
<span data-ty>Private Key: 0xdf57089febbacf7ba0bc227dafbffa9fc08a93fdc68e1e42411a14efcf23656e</span>
70+
<span data-ty></span>
71+
<span data-ty>WARNING: These accounts, and their private keys, are publicly known.</span>
72+
<span data-ty>Any funds sent to them on Mainnet or any other live network WILL BE LOST.</span>
73+
</div>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<div id="termynal" data-termynal class="table-termynal">
2+
<span data-ty="input"><span class="file-path"></span>npx hardhat test</span>
3+
<span data-ty></span>
4+
<span data-ty> Lock</span>
5+
<span data-ty> Deployment</span>
6+
<span data-ty> ✔ Should set the right unlockTime (38ms)</span>
7+
<span data-ty> ✔ Should set the right owner</span>
8+
<span data-ty> ✔ Should receive and store the funds to lock</span>
9+
<span data-ty> ✔ Should fail if the unlockTime is not in the future</span>
10+
<span data-ty> Withdrawals</span>
11+
<span data-ty> Validations</span>
12+
<span data-ty> ✔ Should revert with the right error if called too soon</span>
13+
<span data-ty> ✔ Should revert with the right error if called from another account</span>
14+
<span data-ty> ✔ Shouldn't fail if the unlockTime has arrived and the owner calls it</span>
15+
<span data-ty> Events</span>
16+
<span data-ty> ✔ Should emit an event on withdrawals</span>
17+
<span data-ty> Transfers</span>
18+
<span data-ty> ✔ Should transfer the funds to the owner</span>
19+
<span data-ty></span>
20+
<span data-ty></span>
21+
<span data-ty> 9 passing (66ms)</span>
22+
<span data-ty></span>
23+
<span data-ty>·············································································································</span>
24+
<span data-ty>| Solidity and Network Configuration │</span>
25+
<span data-ty>························|·················|···············|·················|································</span>
26+
<span data-ty>| Solidity: 0.8.28 · Optim: false · Runs: 200 · viaIR: false · Block: 30,000,000 gas │</span>
27+
<span data-ty>························|·················|···············|·················|································</span>
28+
<span data-ty>| Methods │</span>
29+
<span data-ty>························|·················|···············|·················|················|···············</span>
30+
<span data-ty>| Contracts / Methods · Min · Max · Avg · # calls · usd (avg) │</span>
31+
<span data-ty>························|·················|···············|·················|················|···············</span>
32+
<span data-ty>| Lock · │</span>
33+
<span data-ty>························|·················|···············|·················|················|···············</span>
34+
<span data-ty>| withdraw · - · - · 34,096 · 7 · - │</span>
35+
<span data-ty>························|·················|···············|·················|················|···············</span>
36+
<span data-ty>| Deployments · · % of limit · │</span>
37+
<span data-ty>························|·················|···············|·················|················|···············</span>
38+
<span data-ty>| Lock · - · - · 326,112 · 1.1 % · - │</span>
39+
<span data-ty>························|·················|···············|·················|················|···············</span>
40+
<span data-ty>| Key │</span>
41+
<span data-ty>·············································································································</span>
42+
<span data-ty>| ◯ Execution gas for this method does not include intrinsic gas overhead │</span>
43+
<span data-ty>·············································································································</span>
44+
<span data-ty>| △ Cost was non-zero but below the precision setting for the currency display (see options) │</span>
45+
<span data-ty>·············································································································</span>
46+
<span data-ty>| Toolchain: hardhat │</span>
47+
<span data-ty>·············································································································</span>
48+
</div>

.snippets/code/smart-contracts/dev-environments/hardhat/deploy-a-contract/deploy.html

Whitespace-only changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const hre = require('hardhat');
2+
3+
async function main() {
4+
// Get the contract factory
5+
const Lock = await hre.ethers.getContractFactory('Lock');
6+
7+
// Replace with your deployed contract address
8+
const contractAddress = '0xc01Ee7f10EA4aF4673cFff62710E1D7792aBa8f3';
9+
10+
// Attach to existing contract
11+
const lock = await Lock.attach(contractAddress);
12+
13+
// Get signers
14+
const [deployer] = await hre.ethers.getSigners();
15+
16+
// Read contract state
17+
const unlockTime = await lock.unlockTime();
18+
console.log(`Unlock time: ${unlockTime}`);
19+
20+
const balance = await lock.owner();
21+
console.log(`Owner: ${balance}`);
22+
}
23+
24+
main().catch((error) => {
25+
console.error(error);
26+
process.exitCode = 1;
27+
});

.snippets/code/smart-contracts/dev-environments/hardhat/get-started/hardhat-node-output.html

Lines changed: 0 additions & 73 deletions
This file was deleted.

.snippets/code/smart-contracts/dev-environments/hardhat/get-started/interact.js

Lines changed: 0 additions & 34 deletions
This file was deleted.

smart-contracts/dev-environments/hardhat/compile-and-test.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Hardhat compiles your Solidity contracts using the Solidity compiler (solc). The
1212

1313
To compile your project, follow these instructions:
1414

15-
1. Modify your Hardhat configuration file to specify the Solidity compiler version and optimization settings:
15+
1. Make sure that your Hardhat configuration file matches the Solidity compiler version shown in the code snippet below:
1616

1717
```javascript title="hardhat.config.js"
1818
require("@nomicfoundation/hardhat-toolbox");
@@ -51,20 +51,36 @@ This command will launch a local Ethereum network on `http://127.0.0.1:8545` wit
5151

5252
The output will be something like this:
5353

54-
--8<-- 'code/smart-contracts/dev-environments/hardhat/get-started/hardhat-node-output.html'
54+
--8<-- 'code/smart-contracts/dev-environments/hardhat/compile-and-test/hardhat-node-output.html'
5555

5656
## Test Your Contract
5757

5858
Hardhat uses Mocha as its testing framework and Chai for assertions, both included in the Hardhat Toolbox.
5959

60-
To run your tests:
61-
62-
1. Ensure your `hardhat.config.js` file is properly configured with the Solidity compiler settings as shown in the [Compile Your Contract](#compile-your-contract) section
63-
64-
2. Execute the following command to run your tests:
60+
To run your tests execute the following command to run your tests:
6561

6662
```bash
6763
npx hardhat test
6864
```
6965

70-
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.
66+
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.
67+
68+
If you are testing `Lock.sol` contract, output should look like this:
69+
70+
--8<-- 'code/smart-contracts/dev-environments/hardhat/compile-and-test/test.html'
71+
72+
## Where to Go Next
73+
74+
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.
75+
76+
<div class="grid cards" markdown>
77+
78+
- <span class="badge guide">Guide</span> __Deploy a Contract__
79+
80+
---
81+
82+
Learn how to deploy your compiled smart contract to Polkadot Hub TestNet and interact with it using deployment scripts.
83+
84+
[:octicons-arrow-right-24: Get Started](/smart-contracts/dev-environments/hardhat/deploy-a-contract)
85+
86+
</div>

0 commit comments

Comments
 (0)