@klaytn/hardhat-utils
Advanced tools
Comparing version 0.0.11 to 0.0.12
{ | ||
"name": "@klaytn/hardhat-utils", | ||
"version": "0.0.11", | ||
"version": "0.0.12", | ||
"description": "Hardhat utility tasks", | ||
@@ -8,4 +8,2 @@ "repository": "github:klaytn/hardhat-utils", | ||
"license": "MIT", | ||
"main": "dist/src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"keywords": [ | ||
@@ -17,2 +15,26 @@ "ethereum", | ||
], | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
}, | ||
"./helpers": { | ||
"types": "./dist/helpers/index.d.ts", | ||
"default": "./dist/helpers/index.js" | ||
}, | ||
"./helpers/*": { | ||
"types": "./dist/helpers/*.d.ts", | ||
"default": "./dist/helpers/*.js" | ||
}, | ||
"./tasks": { | ||
"types": "./dist/tasks/index.d.ts", | ||
"default": "./dist/tasks/index.js" | ||
}, | ||
"./tasks/*": { | ||
"types": "./dist/tasks/*.d.ts", | ||
"default": "./dist/tasks/*.js" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -35,3 +57,3 @@ "lint:fix": "prettier --write 'src/**/*.{js,ts}' 'test/**/*.{js,ts}' && tslint --fix --config tslint.json --project tsconfig.json", | ||
"devDependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.2.2", | ||
"@nomiclabs/hardhat-ethers": "^2.2.3", | ||
"@types/chai": "^4.1.7", | ||
@@ -48,5 +70,5 @@ "@types/fs-extra": "^5.0.4", | ||
"chai": "^4.2.0", | ||
"hardhat": "^2.0.0", | ||
"hardhat-deploy": "^0.11.25", | ||
"mocha": "^7.1.2", | ||
"hardhat": "^2.17.1", | ||
"hardhat-deploy": "0.11.44", | ||
"mocha": "^10.2.0", | ||
"prettier": "2.0.5", | ||
@@ -61,16 +83,11 @@ "shx": "^0.3.4", | ||
"peerDependencies": { | ||
"@nomiclabs/hardhat-ethers": "^2.2.2", | ||
"hardhat": "^2.0.0", | ||
"hardhat-deploy": "^0.11.25" | ||
"@nomiclabs/hardhat-ethers": "^2.2.3", | ||
"hardhat": "^2.17.1", | ||
"hardhat-deploy": "^0.11.44" | ||
}, | ||
"dependencies": { | ||
"@koa/router": "^12.0.0", | ||
"axios": "^1.3.4", | ||
"koa": "^2.14.1", | ||
"koa-static": "^5.0.0", | ||
"@klaytn/js-ext-core": "^0.9.7-beta", | ||
"lodash": "^4.17.21", | ||
"readline-sync": "^1.4.10", | ||
"shelljs": "^0.8.5", | ||
"squirrelly": "^8.0.8" | ||
"readline-sync": "^1.4.10" | ||
} | ||
} |
555
README.md
# hardhat-utils | ||
[Hardhat](https://hardhat.org) utility tasks. | ||
[Hardhat](https://hardhat.org) utility tasks and helper functions. | ||
## Installation | ||
## <a name='Installation'></a>Installation | ||
@@ -11,202 +11,489 @@ ```bash | ||
Import the plugin in your `hardhat.config.js`: | ||
## <a name='Tableofcontents'></a>Table of contents | ||
```js | ||
require("@klaytn/hardhat-utils"); | ||
``` | ||
<!-- https://marketplace.visualstudio.com/items?itemName=joffreykern.markdown-toc --> | ||
<!-- vscode-markdown-toc --> | ||
* [Installation](#Installation) | ||
* [Table of contents](#Tableofcontents) | ||
* [Import the tasks](#Importthetasks) | ||
* [Import the helper functions](#Importthehelperfunctions) | ||
* [Required plugins](#Requiredplugins) | ||
* [Tasks](#Tasks) | ||
* [Before using tasks](#Beforeusingtasks) | ||
* [Account tasks](#Accounttasks) | ||
* [`hh accounts`](#hhaccounts) | ||
* [`hh decrypt-keystore`](#hhdecrypt-keystore) | ||
* [`hh faucet`](#hhfaucet) | ||
* [`hh mnemonic`](#hhmnemonic) | ||
* [Contract tasks](#Contracttasks) | ||
* [`hh abi`](#hhabi) | ||
* [`hh addr`](#hhaddr) | ||
* [`hh call`](#hhcall) | ||
* [`hh deploy`](#hhdeploy) | ||
* [`hh import`](#hhimport) | ||
* [`hh send`](#hhsend) | ||
* [`hh upload-abi`](#hhupload-abi) | ||
* [`hh verify`](#hhverify) | ||
* [Server launching tasks](#Serverlaunchingtasks) | ||
* [`hh aa-bundler`](#hhaa-bundler) | ||
* [`hh explorer`](#hhexplorer) | ||
* [`hh klaytn-node`](#hhklaytn-node) | ||
* [Helper functions](#Helperfunctions) | ||
Or if you are using TypeScript, in your `hardhat.config.ts`: | ||
<!-- vscode-markdown-toc-config | ||
numbering=false | ||
autoSave=false | ||
/vscode-markdown-toc-config --> | ||
<!-- /vscode-markdown-toc --> | ||
```ts | ||
import "@klaytn/hardhat-utils"; | ||
``` | ||
## <a name='Importthetasks'></a>Import the tasks | ||
## Required plugins | ||
- In `hardhat.config.js` | ||
- Import all tasks | ||
```js | ||
require("@klaytn/hardhat-utils"); | ||
``` | ||
- Import selectively (see [src/tasks/](./src/tasks) for the list) | ||
```js | ||
require("@klaytn/hardhat-utils/tasks/accounts"); | ||
require("@klaytn/hardhat-utils/tasks/klaytnNode"); | ||
``` | ||
- In `hardhat.config.ts` | ||
- Import all tasks | ||
```ts | ||
import "@klaytn/hardhat-utils"; | ||
``` | ||
- Import selectively (see [src/tasks/](./src/tasks) for the list) | ||
```ts | ||
import "@klaytn/hardhat-utils/tasks/accounts"; | ||
import "@klaytn/hardhat-utils/tasks/klaytnNode"; | ||
``` | ||
This plugin is dependent on other plugins. Make sure to require or import them in your `hardhat.config.js`. | ||
## <a name='Importthehelperfunctions'></a>Import the helper functions | ||
- In your `.js` script | ||
```js | ||
const { deriveAccounts } = require("@klaytn/hardhat-utils/helpers"); | ||
``` | ||
- In your `.ts` script | ||
```ts | ||
import { deriveAccounts } from "@klaytn/hardhat-utils/helpers"; | ||
``` | ||
## <a name='Requiredplugins'></a>Required plugins | ||
This plugin depends on other plugins. Make sure to require or import them in your `hardhat.config.js` or `hardhat.config.ts`. | ||
- [@nomiclabs/hardhat-ethers](https://www.npmjs.com/package/@nomiclabs/hardhat-ethers) | ||
- [hardhat-deploy](https://www.npmjs.com/package/hardhat-deploy) | ||
## Tasks | ||
``` | ||
npm install @nomiclabs/hardhat-ethers hardhat-deploy | ||
``` | ||
```ts | ||
// hardhat.config.js | ||
require("@nomiclabs/hardhat-ethers"); | ||
require("hardhat-deploy"); | ||
// hardhat.config.ts | ||
import "@nomiclabs/hardhat-ethers"; | ||
import "hardhat-deploy"; | ||
``` | ||
## <a name='Tasks'></a>Tasks | ||
Type `hh <task name> --help` for detailed help. Below paragraphs outlines notable use cases. | ||
### `abi` | ||
### <a name='Beforeusingtasks'></a>Before using tasks | ||
Print ABI of a contract. See also: `call`, `docs`, `send`, `smart-flatten` and `upload-abi` . | ||
- `hh abi` prints ABIs of all contracts in your project | ||
- `hh abi Counter` prints the ABI of a specific contract | ||
(Recommended) Install hardhat shorthand. Below paragraphs assumes hardhat-shorthand is installed, but you can still use the tasks | ||
with `npx hardhat`. | ||
You can choose output formats | ||
- `hh abi` by default prints in human-readable string format. | ||
- `hh abi --json` prints in JSON format to be used in other apps. | ||
``` | ||
npm install --global hardhat-shorthand | ||
``` | ||
``` | ||
npx hardhat --version | ||
hh --version | ||
``` | ||
### `accounts` | ||
Choose the network via | ||
Print account address and balance. Useful for checking the curent hardhat network. See also: `faucet` and `mnemonic` | ||
- Configure the `HARDHAT_NETWORK` environment | ||
```sh | ||
export HARDHAT_NETWORK=localhost | ||
hh accounts | ||
``` | ||
- Attach the `--network` option at each command | ||
```sh | ||
hh --network localhost accounts | ||
``` | ||
- `hh accounts` prints the address and balance of the default accounts for current network. | ||
- `hh accounts --from 0` prints for one specific account. Can be address or index. | ||
### <a name='Accounttasks'></a>Account tasks | ||
### `addr` | ||
#### <a name='hhaccounts'></a>`hh accounts` | ||
Print the address of deployed contracts. See also: `call`, `deploy`, `import` and `send`. | ||
- `hh addr` prints all deployed contracts on the current network. | ||
- `hh addr Counter` prints the addrees of the specific contracg. | ||
Print account addresses and balances. Useful for checking the curent hardhat network. | ||
### `call` | ||
``` | ||
hh accounts | ||
``` | ||
``` | ||
address balance | ||
0 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 10000000.0 | ||
1 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 10000000.0 | ||
2 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC 10000000.0 | ||
3 0x90F79bf6EB2c4f870365E785982E1f101E93b906 10000000.0 | ||
4 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 10000000.0 | ||
5 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc 10000000.0 | ||
6 0x976EA74026E726554dB657fA54763abd0C3a0aa9 10000000.0 | ||
7 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 10000000.0 | ||
8 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f 10000000.0 | ||
9 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 10000000.0 | ||
``` | ||
Call a read-only function of a deployed contract. See also: `abi`, `addr`, `deploy` and `send`. | ||
#### <a name='hhdecrypt-keystore'></a>`hh decrypt-keystore` | ||
- `hh call Counter number` calls the `number()` function of the Counter contract deployed on current network. | ||
- `hh call MyToken "balanceOf(address)" 0xarg` calls the exact function. When multiple functions have the same name, or somehow hardhat does not recognize the function, specify exact function signature including argument types. | ||
- `hh call --from 1 Counter number` overrides sender address. | ||
- `hh call --to <addr> Counter number` overrides the contract address. Use it when the contract is deployed but not saved in `deployments/`. | ||
Decrypt JSON keystore file to print the address and private key. | ||
It also accepts the [KIP-3](https://kips.klaytn.foundation/KIPs/kip-3) (Klaytn keystore v4) in which case | ||
multiple addresses and private keys are printed. | ||
### `deploy` | ||
``` | ||
hh decrypt-keystore keystore.json --password "mypass" | ||
``` | ||
``` | ||
address private key | ||
0 0x0cc57a3c4E276A37AB0A98ba6899CAf6037996fB 278c3d035328daf04ab2597da96dd2d8868fd61a8837030f7d8a85f27b7f1bad | ||
``` | ||
Deploy contracts by running scripts in `deploy/`. As a result, addresses and ABI will be saved under `deployments/<network>`. See also: `addr`, `call`, `explorer`, `import` and `send` | ||
- `hh deploy` runs all deploy scripts. | ||
- `hh deploy --tags` selectivly run deploy scripts with specific tags. | ||
- `hh deploy --reset` deletes existing `deployments/<network>` and re-deployes. | ||
- `hh deploy --export out.json` exports all contracts addresses and ABI for current network. | ||
- `hh deploy --export-all all.json` exports all contracts addresses and ABI for every networks. | ||
- See [hardhat-deploy plugin docs](https://github.com/wighawag/hardhat-deploy) for details. | ||
#### <a name='hhfaucet'></a>`hh faucet` | ||
### `docs` | ||
Transfer native coins in batch. Useful when you top up balances for gas fee. | ||
Generate HTML and markdown docs describing the compiled contracts. See also: `abi`. | ||
``` | ||
hh faucet --from 0 --to 1,2,3 | ||
``` | ||
``` | ||
Send from 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 to 3 accounts 1 ETH each | ||
to 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 txid 0x9574b62242f7d7f4b2ba040b775345aad8e4bfe38d588c783590298d861cc52f | ||
to 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC txid 0xf594661765fcf2f7b17994661818d256af4db84aac4c518e3fd2e775790844c0 | ||
to 0x90F79bf6EB2c4f870365E785982E1f101E93b906 txid 0xe4e41e5750cdb5a25fd41f75f19e9feef96cc1ea7445fe503b17d9a44e5d4cda | ||
``` | ||
- `hh docs` generates docs `docs/*.md` and `docs/www/*.html` | ||
- `hh docs --coverage ./coverage` copies coverage [solidity-coverage](https://github.com/sc-forks/solidity-coverage) report from the specified location into the output docs. | ||
#### <a name='hhmnemonic'></a>`hh mnemonic` | ||
### `explorer` | ||
Print addresses and private keys derived from a [BIP-39 mnemonic](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) and [BIP-32 path](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). | ||
By default, the Hardhat default mnemonic (`test test test test test test test test test test test junk`) and Ethereum deriation path (`m/44'/60'/0'/0/i`) is used. | ||
Launch the [BlockScout](https://github.com/blockscout/blockscout) block explorer for current network. See also: `deploy`. | ||
- `hh explorer` launches the BlockScout container that fetches block data from the JSON-RPC. | ||
``` | ||
hh mnemonic | ||
``` | ||
``` | ||
address private key | ||
0 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
1 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d | ||
2 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC 5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a | ||
3 0x90F79bf6EB2c4f870365E785982E1f101E93b906 7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 | ||
4 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a | ||
5 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc 8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba | ||
6 0x976EA74026E726554dB657fA54763abd0C3a0aa9 92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e | ||
7 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 | ||
8 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f dbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 | ||
9 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 | ||
``` | ||
### `faucet` | ||
### <a name='Contracttasks'></a>Contract tasks | ||
Transfer native coins in batch. Intended to fill balances for gas fee. See also: `accounts` and `mnemonic`. | ||
- `hh faucet` sends by default 1 ETH to all accounts on current network. | ||
- `hh --from 1 --to 2` sends 1 ETH from account[1] to account[2]. | ||
- `hh --amount 0.1` sends 0.1 ETH instead. | ||
#### <a name='hhabi'></a>`hh abi` | ||
### `import` | ||
Print ABIs of compiled or deployed contracts. | ||
Import a deployment, i.e. address and ABI, of an existing contract. As a result, addresses and ABI will be saved under `deployments/<network>`. See also: `addr` and `deploy`. | ||
- `hh import Counter <addr>` saves the contract address and ABI | ||
- `hh import Counter <addr> <deployTxHash>` saves the contract address, ABI and deploy transaction receipt. | ||
``` | ||
hh abi | ||
``` | ||
``` | ||
# contracts/Counter.sol:Counter | ||
function increment() // 0xd09de08a | ||
function number() view returns (uint256) // 0x8381f58a | ||
function setNumber(uint256 newNumber) // 0x3fb5c1cb | ||
``` | ||
### `keystore-decrypt` | ||
You can customize the output. | ||
Decrypt a JSON keystore to get private key. See also: `keystore-encrypt`, `keystore-kip3`, and `mnemonic`. | ||
- `hh keystore-decrypt keystore.json --password 1234` prints the private key. | ||
``` | ||
# Print in JSON | ||
hh abi --json | ||
### `keystore-encrypt` | ||
# Specify a contract | ||
hh abi Counter | ||
``` | ||
Encrypt a private key to a keystore.json. See also: `keystore-decrypt` and `mnemonic`. | ||
- `hh keystore-encrypt <privHex> --password 1234` prints a JSON keystore v3. | ||
#### <a name='hhaddr'></a>`hh addr` | ||
### `keystore-kip3` | ||
Print the deployed contract addresses. | ||
Convert [KIP-3 v4 keystore](https://github.com/klaytn/kips/blob/main/KIPs/kip-3.md) to v3 keystore. See also: `keystore-decrypt`. | ||
- `hh keystore-kip3 v4.json` prints a JSON keystore v4. | ||
``` | ||
hh addr | ||
``` | ||
``` | ||
{ | ||
"Counter": "0x39dD11C243Ac4Ac250980FA3AEa016f73C509f37" | ||
} | ||
``` | ||
### `klaytn-node` | ||
#### <a name='hhcall'></a>`hh call` | ||
Launch a klaytn consensus node. See also: `deploy`. | ||
- `hh klaytn-node` starts a klaytn private chain. Other scripts can refer to this node via `--network localhost`. | ||
- `hh klaytn-node --base-fee` sets the gas fee to 0, allowing any account to send transactions without the native coin. | ||
- `hh --docker-image-id klaytn/klaytn:v1.10.0` launches the specific version of klaytn container image from https://hub.docker.com/r/klaytn/klaytn or from local images. | ||
Call a read-only function of a deployed contract. | ||
### `mnemonic` | ||
``` | ||
hh call Counter number | ||
``` | ||
``` | ||
[ | ||
"0x00" | ||
] | ||
``` | ||
Print addresses and private keys derived from a [BIP-39 mnemonic](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) and [BIP-32 path](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki). See also: `accounts`, `faucet`, `keystore-decrypt` and `keystore-encrypt`. | ||
- `hh mnemonic` prints 10 accounts derived from the junk mnemonic (`test test test test test test test test test test test junk`) and the Ethereum wallet path (`m/44'/60'/0'/0/`). | ||
- `hh --index 0-4 --path "m/44'/60'/0'/1234/" "<mnemonic words>"` prints a customized result. | ||
You can customize the call. | ||
### `send` | ||
```sh | ||
# specify the function signature (in case the ABI is broken or nonexistent) | ||
hh call MyToken "balanceOf(address)" 0x1234 | ||
Call a read-only function of a deployed contract. See also: `abi`, `addr`, `call` and `deploy`. | ||
# specify 'from' address (in case the result differs by msg.sender) | ||
hh call --from 1 Counter number | ||
- `hh send Counter increment` calls the `increment()` function of the Counter contract deployed on current network. | ||
- `hh send WKLAY "withdraw(uint256)" 1000` calls the exact function. When multiple functions have the same name, or somehow hardhat does not recognize the function, specify exact function signature including argument types. | ||
- `hh send --from 1 Counter increment` overrides sender address. | ||
- `hh send --to <addr> Counter increment` overrides the contract address. Use it when the contract is deployed but not saved in `deployments/`. | ||
- `hh send Counter increment --unsigned` prints an unsigned transaction JSON. | ||
- `hh send Counter increment --browser` launches a simple web page for browser wallets like MetaMask to sign and send the transaction. | ||
# override contract address (in case the contract is not saved in 'deployments/') | ||
hh call --to 0xaddr Counter number | ||
``` | ||
### `smart-flatten` | ||
#### <a name='hhdeploy'></a>`hh deploy` | ||
Flatten source code to be submitted to block explorers. If there are multiple license identifiers (i.e. `// SPDX-License-Identifier: ..`), only keep the license from the last file. See also: `abi` and `upload-abi`. | ||
Deploy tasks is not part of hardhat-utils, but describing it here because it is essential for the contract tasks. See [hardhat-deploy plugin docs](https://github.com/wighawag/hardhat-deploy) for details. | ||
- `hh smart-flatten Counter` flattens required sources for Counter contract and writes Counter.flat.sol file. | ||
- `hh smart-flatten contracts/Counter.sol` flattens required sources to compile the spefieid source. | ||
- `hh smart-flatten --force-license MIT` overrides the final license identifier. | ||
- `hh smart-flatten --include-dev` allows debugging libraries like hardhat/console.sol to be flattened. | ||
Deploys contracts according to the scripts under the `deploy/` directory. | ||
### `upload-abi` | ||
``` | ||
hh deploy | ||
``` | ||
``` | ||
deploying "Counter" (tx: 0x2f15606c21060c20a60ea6a251f031de61cb143b6c64b6eeb9b52d9d2421939b)...: deployed at 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 with 185065 gas | ||
``` | ||
Upload ABI to online database sites. See also: `abi` and `smart-flatten`. | ||
#### <a name='hhimport'></a>`hh import` | ||
- `hh upload-abi --byte4` submits ABIs of all compiled contracts to https://www.4byte.directory/ | ||
- `hh upload-abi --sigdb` submits ABIs of all compiled contracts to https://openchain.xyz/signatures | ||
- `hh upload-abi --sigdb Counter` submits ABI for a specific contract. | ||
Import a deployment (i.e. address and ABI) of an existing contract. As a result, addresses and ABI will be saved under `deployments/<network>`. | ||
Use it when the contract is deployed by other party but you want to reference it. | ||
## Usage | ||
``` | ||
hh import Counter 0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512 | ||
``` | ||
#### <a name='hhsend'></a>`hh send` | ||
Send a function invoking transaction to a deployed contract. | ||
``` | ||
hh send Counter increment | ||
``` | ||
``` | ||
sent Counter#increment (tx: 0xd9624e9d5a711812cb77169b3467761eb4952a9656aea970b64dba5102a84a9c)...ok (block 3, gas used: 44778) | ||
emit SetNumber(uint256) [ | ||
"0x01" | ||
] | ||
``` | ||
You can customize the transaction. | ||
```sh | ||
# Print ABI | ||
hh abi Counter | ||
hh abi Counter --json | ||
# specify the function signature (in case the ABI is broken or nonexistent) | ||
hh send WKLAY "withdraw(uint256)" 1000 | ||
# Show addresses and balances of loaded accounts | ||
hh accounts | ||
hh accounts --from 2 --json | ||
# specify 'from' address (in case the result differs by msg.sender) | ||
hh send --from 1 Counter increment | ||
# Send coins for gas fee | ||
hh faucet --from 0 --to 1-8 --amount 0.1 | ||
# override contract address (in case the contract is not saved in 'deployments/') | ||
hh send --to 0xaddr Counter increment | ||
# Deploy contracts | ||
hh deploy | ||
# print unsigned transaction (in case private key is in another machine) | ||
hh send --unsigned Counter increment | ||
``` | ||
# Save deployed contract addreses | ||
hh import Counter 0xaddr | ||
#### <a name='hhupload-abi'></a>`hh upload-abi` | ||
# Get address from deployments | ||
hh addr # List all addresses | ||
hh addr Counter | ||
Upload ABI to online database services. | ||
# Call contract function | ||
hh call Counter number # load address from deployments | ||
hh call Counter number --to 0xaddr # call designated address | ||
``` | ||
hh upload-abi --byte4 | ||
``` | ||
``` | ||
Uploading 8 function and event signatures.. | ||
POST https://www.4byte.directory/api/v1/import-abi/ 201 Created | ||
{ | ||
"num_processed": 8, | ||
"num_imported": 0, | ||
"num_duplicates": 8, | ||
"num_ignored": 0 | ||
} | ||
``` | ||
# Send transaction to contract | ||
hh send Counter setNumber 123 # load address from deployments | ||
hh send Counter setNumber 123 --to 0xaddr # call designated address | ||
hh send Counter increment--unsigned # print unsigned tx | ||
hh send Counter increment --browser # launch web page for browser wallet | ||
Type `hh upload-abi --help` to see list of supported services. | ||
# Flatten and print compilation info and sort out multiple licenses | ||
hh smart-flatten Counter | ||
``` | ||
hh upload-abi --help | ||
``` | ||
``` | ||
OPTIONS: | ||
# Upload ABI to online database | ||
hh upload-abi Counter --byte4 --sigdb | ||
--byte4 Upload to https://www.4byte.directory/ | ||
--sigdb Upload to https://openchain.xyz/signatures | ||
``` | ||
# Work with keystore and mnemonic | ||
hh mnemonic --index 2 | ||
hh keystore-decrypt k.json --password 1111 | ||
hh keystore-encrypt 0xprivatekey --password 1111 > k.json | ||
hh keystore-kip3 v4.json v3.json | ||
find ./keys/*.json -exec hh keystore-kip3 {} {}_v3.json \; # batch convert | ||
find ./keys/*.json -exec hh keystore-kip3 {} {} \; # batch convert in-place | ||
#### <a name='hhverify'></a>`hh verify` | ||
# Launch blockscout explorer for local network | ||
# Requires docker-compose and docker | ||
TODO | ||
### <a name='Serverlaunchingtasks'></a>Server launching tasks | ||
#### <a name='hhaa-bundler'></a>`hh aa-bundler` | ||
Launch the ERC-4337 bundler for the current network. Do not use with public endpoints since bundler generates a lot of RPC traffic. | ||
Supports [stackup-bundler](https://github.com/stackup-wallet/stackup-bundler). | ||
``` | ||
hh aa-bundler | ||
``` | ||
``` | ||
[+] Using env: { | ||
DOCKER_IMAGE: 'stackupwallet/stackup-bundler:latest', | ||
DOCKER_LISTEN: '0.0.0.0:4337', | ||
BUNDLER_NODE_RPC: 'http://host.docker.internal:8545/', | ||
BUNDLER_PRIVATE_KEY: 'ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80', | ||
BUNDLER_ENTRYPOINT: '0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789' | ||
} | ||
[+] Starting ERC-4337 bundler at http://0.0.0.0:4337/ | ||
[+] Building 0.0s (0/0) docker:desktop-linux | ||
[+] Running 2/0 | ||
✔ Network bundler_default Created 0.0s | ||
✔ Container bundler-stackup-1 Created 0.0s | ||
Attaching to bundler-stackup-1 | ||
bundler-stackup-1 | debconf: delaying package configuration, since apt-utils is not installed | ||
bundler-stackup-1 | checking eth_chainId... {"jsonrpc":"2.0","id":1,"result":"0x7a69"}connected to RPC 'http://host.docker.internal:8545/' | ||
bundler-stackup-1 | badger 2023/11/28 06:48:00 INFO: All 0 tables opened in 0s | ||
bundler-stackup-1 | badger 2023/11/28 06:48:00 INFO: Discard stats nextEmptySlot: 0 | ||
bundler-stackup-1 | badger 2023/11/28 06:48:00 INFO: Set nextTxnTs to 0 | ||
``` | ||
You can customize the instance. | ||
```sh | ||
# Use specific version | ||
hh aa-bundler --docker-image-id stackupwallet/stackup-bundler:latest | ||
# Use different sender account | ||
hh aa-bundler --index 10 | ||
# Use different RPC port | ||
hh aa-bundler --port 4000 | ||
``` | ||
#### <a name='hhexplorer'></a>`hh explorer` | ||
Launch the [BlockScout](https://github.com/blockscout/blockscout) block explorer for current network. Do not use with public endpoints since explorer generates a lot of RPC traffic. Supports BlockScout v5.x with only a few services enabled (including smart-contract-verifier). | ||
After running the task, go to http://localhost:4000. | ||
``` | ||
hh explorer | ||
hh explorer --restart | ||
hh explorer --stop | ||
``` | ||
``` | ||
[+] Using env: { | ||
DOCKER_RPC_HTTP_URL: 'http://host.docker.internal:8545/', DOCKER_TAG: '4.1.8', DOCKER_LISTEN: '0.0.0.0:4000', | ||
DOCKER_DISABLE_TRACER: 'true', DOCKER_DEBUG: '0' } | ||
[+] Open in the browser: http://localhost:4000 [+] Building 0.0s (0/0) docker:desktop-linux [+] Running 6/6 | ||
✔ Network blockscout_default Created 0.0s ✔ Container blockscout-db-1 Started 0.0s | ||
✔ Container blockscout-frontend-1 Started 0.0s ✔ Container blockscout-redis_db-1 Started 0.0s | ||
✔ Container blockscout-smart-contract-verifier-1 Started 0.0s ✔ Container blockscout-backend-1 Started 0.0s | ||
[+] Building 0.0s (0/0) docker:desktop-linux [+] Running 6/0 | ||
✔ Container blockscout-frontend-1 Running 0.0s | ||
✔ Container blockscout-smart-contract-verifier-1 Running 0.0s | ||
✔ Container blockscout-redis_db-1 Running 0.0s | ||
✔ Container blockscout-db-1 Running 0.0s | ||
✔ Container blockscout-backend-1 Running 0.0s | ||
✔ Container blockscout-proxy-1 Created 0.0s | ||
Attaching to blockscout-proxy-1 | ||
``` | ||
#### <a name='hhklaytn-node'></a>`hh klaytn-node` | ||
Launch a [Klaytn](https://github.com/klaytn/klaytn) consensus node. Analogous to `hh node` or `anvil`. | ||
``` | ||
hh klaytn-node | ||
``` | ||
``` | ||
[+] Using nodekey: ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
[+] Available accounts (each having ${balance} KLAY): | ||
address private key | ||
0 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
1 0x70997970C51812dc3A010C7d01b50e0d17dc79C8 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d | ||
2 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC 0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a | ||
3 0x90F79bf6EB2c4f870365E785982E1f101E93b906 0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6 | ||
4 0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65 0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a | ||
5 0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc 0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba | ||
6 0x976EA74026E726554dB657fA54763abd0C3a0aa9 0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e | ||
7 0x14dC79964da2C08b23698B3D3cc7Ca32193d9955 0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356 | ||
8 0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f 0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97 | ||
9 0xa0Ee7A142d267C1f36714E4a8F75612F20a79720 0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6 | ||
[+] Using env: { | ||
DOCKER_IMAGE: 'klaytn/klaytn:latest', | ||
DOCKER_LISTEN: '0.0.0.0:8545', | ||
DOCKER_DEBUG: '0' | ||
} | ||
[+] Starting JSON-RPC server at http://0.0.0.0:8545/ | ||
To attach to the console, | ||
npx hardhat klaytn-node --attach | ||
Press Ctrl+C to stop | ||
``` | ||
After running the task, type `hh klaytn-node --attach` to use the console. | ||
``` | ||
hh klaytn-node --attach | ||
``` | ||
``` | ||
Welcome to the Klaytn JavaScript console! | ||
instance: Klaytn/v1.11.1/linux-amd64/go1.20.6 | ||
datadir: /klaytn | ||
modules: admin:1.0 debug:1.0 eth:1.0 governance:1.0 istanbul:1.0 klay:1.0 net:1.0 personal:1.0 rpc:1.0 txpool:1.0 web3:1.0 | ||
> | ||
``` | ||
You can customize the instance. | ||
```sh | ||
# Use specific version | ||
hh klaytn-node --docker-image-id klaytn/klaytn:dev | ||
# Configure fork level | ||
hh klaytn-node --hardfork cancun | ||
# Configure zero fee network | ||
hh klaytn-node --base-fee 0 --unit-price 0 | ||
``` | ||
## <a name='Helperfunctions'></a>Helper functions | ||
See [src/helpers/](./src/helpers) for full list. | ||
```ts | ||
import { deriveAccounts } from "@klaytn/hardhat-utils/helpers"; | ||
const accounts = deriveAccounts(); | ||
console.log(accounts[0].address); | ||
// 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 | ||
``` | ||
@@ -14,3 +14,2 @@ import { extendEnvironment } from "hardhat/config"; | ||
} | ||
// Because hardhat-dodoc is a non-critical feature, don't check here. | ||
@@ -21,9 +20,2 @@ // Lazy extend the `hre.ethers` object using the ES6 object Proxy | ||
export * from "./abi"; | ||
export * from "./accounts"; | ||
export * from "./blockscout"; | ||
export * from "./bundler"; | ||
export * from "./deployments"; | ||
export * from "./docs"; | ||
export * from "./flat"; | ||
export * from "./klaytn"; | ||
export * from "./tasks"; |
@@ -11,12 +11,2 @@ import "@nomiclabs/hardhat-ethers/internal/type-extensions"; | ||
export interface HardhatConfig { | ||
dodoc: { | ||
include: string[]; | ||
exclude: string[]; | ||
runOnCompile: boolean; | ||
debugMode: boolean; | ||
templatePath: string; | ||
outputDir: string; | ||
keepFileStructure: boolean; | ||
freshOutput: boolean; | ||
} | ||
} | ||
@@ -23,0 +13,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
6
499
1
87188
37
1223
+ Added@colors/colors@1.6.0(transitive)
+ Added@dabh/diagnostics@2.0.3(transitive)
+ Added@klaytn/js-ext-core@0.9.7-beta(transitive)
+ Added@types/triple-beam@1.3.5(transitive)
+ Addedasync@3.2.5(transitive)
+ Addedbuild@0.1.4(transitive)
+ Addedcolor@3.2.1(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addedcolorspace@1.1.4(transitive)
+ Addedcssmin@0.3.2(transitive)
+ Addedelliptic@6.5.5(transitive)
+ Addedenabled@2.0.0(transitive)
+ Addedfecha@4.2.3(transitive)
+ Addedfn.name@1.1.0(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addedjs-yaml@0.3.7(transitive)
+ Addedjsmin@1.0.1(transitive)
+ AddedjxLoader@0.1.1(transitive)
+ Addedkuler@2.0.0(transitive)
+ Addedlogform@2.6.0(transitive)
+ Addedmakeerror@1.0.12(transitive)
+ Addedmoo-server@1.3.0(transitive)
+ Addedone-time@1.0.0(transitive)
+ Addedpromised-io@0.3.6(transitive)
+ Addedsafe-stable-stringify@2.4.3(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedstack-trace@0.0.10(transitive)
+ Addedtext-hex@1.0.0(transitive)
+ Addedtimespan@2.3.0(transitive)
+ Addedtmpl@1.0.5(transitive)
+ Addedtriple-beam@1.4.1(transitive)
+ Addeduglify-js@1.3.5(transitive)
+ Addedwalker@1.0.8(transitive)
+ Addedwinston@3.13.0(transitive)
+ Addedwinston-transport@4.7.0(transitive)
+ Addedwrench@1.3.9(transitive)
- Removed@koa/router@^12.0.0
- Removedaxios@^1.3.4
- Removedkoa@^2.14.1
- Removedkoa-static@^5.0.0
- Removedshelljs@^0.8.5
- Removedsquirrelly@^8.0.8
- Removed@koa/router@12.0.1(transitive)
- Removedaccepts@1.3.8(transitive)
- Removedaxios@1.7.2(transitive)
- Removedcache-content-type@1.0.1(transitive)
- Removedco@4.6.0(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcontent-type@1.0.5(transitive)
- Removedcookies@0.9.1(transitive)
- Removeddebug@3.2.7(transitive)
- Removeddeep-equal@1.0.1(transitive)
- Removeddelegates@1.0.0(transitive)
- Removeddepd@1.1.2(transitive)
- Removeddestroy@1.2.0(transitive)
- Removedee-first@1.1.1(transitive)
- Removedencodeurl@1.0.2(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedfresh@0.5.2(transitive)
- Removedhas-tostringtag@1.0.2(transitive)
- Removedhttp-assert@1.5.0(transitive)
- Removedhttp-errors@1.6.31.8.1(transitive)
- Removedinherits@2.0.3(transitive)
- Removedinterpret@1.4.0(transitive)
- Removedis-generator-function@1.0.10(transitive)
- Removedkeygrip@1.1.0(transitive)
- Removedkoa@2.15.3(transitive)
- Removedkoa-compose@4.2.0(transitive)
- Removedkoa-convert@2.0.0(transitive)
- Removedkoa-send@5.0.1(transitive)
- Removedkoa-static@5.0.0(transitive)
- Removedmedia-typer@0.3.0(transitive)
- Removedmethods@1.1.2(transitive)
- Removednegotiator@0.6.3(transitive)
- Removedon-finished@2.4.1(transitive)
- Removedonly@0.0.2(transitive)
- Removedparseurl@1.3.3(transitive)
- Removedpath-to-regexp@6.2.2(transitive)
- Removedproxy-from-env@1.1.0(transitive)
- Removedrechoir@0.6.2(transitive)
- Removedresolve-path@1.4.0(transitive)
- Removedsetprototypeof@1.1.0(transitive)
- Removedshelljs@0.8.5(transitive)
- Removedsquirrelly@8.0.8(transitive)
- Removedstatuses@1.5.0(transitive)
- Removedtsscmp@1.0.6(transitive)
- Removedtype-is@1.6.18(transitive)
- Removedvary@1.1.2(transitive)
- Removedylru@1.4.0(transitive)