Skip to content

Commit f19b6c8

Browse files
blukat29ian0371
authored andcommitted
Initial commit
0 parents  commit f19b6c8

40 files changed

+9488
-0
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# EditorConfig is awesome: https://EditorConfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
end_of_line = lf
7+
indent_style = space
8+
indent_size = 2
9+
insert_final_newline = true
10+
trim_trailing_whitespace = false

.gitignore

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/dist
2+
3+
# Logs
4+
logs
5+
*.log
6+
npm-debug.log*
7+
yarn-debug.log*
8+
yarn-error.log*
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# nyc test coverage
23+
.nyc_output
24+
25+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26+
.grunt
27+
28+
# Bower dependency directory (https://bower.io/)
29+
bower_components
30+
31+
# node-waf configuration
32+
.lock-wscript
33+
34+
# Compiled binary addons (https://nodejs.org/api/addons.html)
35+
build/Release
36+
37+
# Dependency directories
38+
node_modules/
39+
jspm_packages/
40+
41+
# TypeScript v1 declaration files
42+
typings/
43+
44+
# Optional npm cache directory
45+
.npm
46+
47+
# Optional eslint cache
48+
.eslintcache
49+
50+
# Optional REPL history
51+
.node_repl_history
52+
53+
# Output of 'npm pack'
54+
*.tgz
55+
56+
# Yarn Integrity file
57+
.yarn-integrity
58+
59+
# next.js build output
60+
.next
61+
62+
# environment variables
63+
.env
64+
65+
# hardhat project
66+
artifacts/
67+
cache/
68+
deployments/hardhat/
69+
deployments/localhost/

.mocharc.json

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": "ts-node/register/files",
3+
"ignore": ["test/fixture-projects/**/*"],
4+
"timeout": 6000
5+
}

.npmignore

Whitespace-only changes.

.travis.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: node_js
2+
3+
node_js:
4+
- "8"
5+
- "10"
6+
- "11"
7+
8+
install:
9+
- npm ci
10+
11+
script:
12+
- npm run test
13+
- npm run lint
14+
15+
cache: npm
16+
17+
branches:
18+
only:
19+
- master

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Nomic Labs LLC
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+78
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# hardhat-utils
2+
3+
[Hardhat](https://hardhat.org) utility tasks.
4+
5+
## Installation
6+
7+
```bash
8+
npm install @klaytn/hardhat-utils
9+
```
10+
11+
Import the plugin in your `hardhat.config.js`:
12+
13+
```js
14+
require("@klaytn/hardhat-utils");
15+
```
16+
17+
Or if you are using TypeScript, in your `hardhat.config.ts`:
18+
19+
```ts
20+
import "@klaytn/hardhat-utils";
21+
```
22+
23+
## Required plugins
24+
25+
This plugin is dependent on other plugins. Make sure to require or import them in your `hardhat.config.js`.
26+
27+
- [@nomiclabs/hardhat-ethers](https://www.npmjs.com/package/@nomiclabs/hardhat-ethers)
28+
- [hardhat-deploy](https://www.npmjs.com/package/hardhat-deploy)
29+
30+
## Tasks
31+
32+
TBD
33+
34+
## Configuration
35+
36+
TBD
37+
38+
## Usage
39+
40+
```sh
41+
# Print ABI
42+
hh abi Counter
43+
hh abi Counter --json
44+
45+
# Show addresses and balances of loaded accounts
46+
hh accounts
47+
hh accounts --from 2 --json
48+
49+
# Get address from deployments
50+
hh addr # List all addresses
51+
hh addr Counter
52+
53+
# Call contract function
54+
hh call Counter number # load address from deployments
55+
hh call Counter number --to 0xaddr # call designated address
56+
57+
# Send transaction to contract
58+
hh send Counter setNumber 123 # load address from deployments
59+
hh send Counter setNumber 123 --to 0xaddr # call designated address
60+
hh send Counter setNumber 123 --from 0xaddr --unsigned # print unsigned tx
61+
62+
# Flatten and print compilation info and sort out multiple licenses
63+
hh smart-flatten Counter
64+
65+
# Work with keystore and mnemonic
66+
hh mnemonic --index 2
67+
hh keystore-decrypt k.json --password 1111
68+
hh keystore-encrypt 0xprivatekey --password 1111 > k.json
69+
hh keystore-kip3 v4.json v3.json
70+
find ./keys/*.json -exec hh keystore-kip3 {} {}_v3.json \; # batch convert
71+
find ./keys/*.json -exec hh keystore-kip3 {} {} \; # batch convert in-place
72+
73+
# Launch blockscout explorer for local network
74+
# Requires docker-compose and docker
75+
hh explorer
76+
hh explorer --restart
77+
hh explorer --stop
78+
```

contracts/Counter.sol

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// SPDX-License-Identifier: UNLICENSED
2+
pragma solidity ^0.8.13;
3+
4+
contract Counter {
5+
uint256 public number;
6+
7+
function setNumber(uint256 newNumber) public {
8+
number = newNumber;
9+
}
10+
11+
function increment() public {
12+
number++;
13+
}
14+
}

deploy/deploy.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {HardhatRuntimeEnvironment} from 'hardhat/types';
2+
import {DeployFunction} from 'hardhat-deploy/types';
3+
4+
const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
5+
const accounts = await hre.getUnnamedAccounts()
6+
await hre.deployments.deploy("Counter", {
7+
from: accounts[0],
8+
args: [],
9+
log: true,
10+
});
11+
};
12+
export default func;
+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Adopted from https://github.com/blockscout/blockscout/blob/v4.1.8-beta/docker-compose/docker-compose-no-build-hardhat-network.yml
2+
# This docker-compose only supports upto blockscout 4.x.
3+
version: '3.8'
4+
5+
services:
6+
db:
7+
image: postgres:14
8+
restart: always
9+
container_name: 'postgres'
10+
environment:
11+
POSTGRES_PASSWORD: ''
12+
POSTGRES_USER: 'postgres'
13+
POSTGRES_HOST_AUTH_METHOD: 'trust'
14+
command: ['postgres', '-c', 'max_connections=1000']
15+
16+
blockscout:
17+
depends_on:
18+
- db
19+
image: blockscout/blockscout:${DOCKER_TAG:-latest}
20+
restart: always
21+
container_name: 'blockscout'
22+
links:
23+
- db:database
24+
command: bash -c "bin/blockscout eval \"Elixir.Explorer.ReleaseTasks.create_and_migrate()\" && bin/blockscout start"
25+
extra_hosts:
26+
- 'host.docker.internal:host-gateway'
27+
env_file:
28+
- ./envs/common-blockscout.env
29+
environment:
30+
ETHEREUM_JSONRPC_VARIANT: 'geth'
31+
ETHEREUM_JSONRPC_HTTP_URL: http://host.docker.internal:8545/
32+
ETHEREUM_JSONRPC_WS_URL: ws://host.docker.internal:8545/
33+
INDEXER_DISABLE_PENDING_TRANSACTIONS_FETCHER: 'true'
34+
INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER: ${DOCKER_DISABLE_TRACER:-true}
35+
DATABASE_URL: postgresql://postgres:@db:5432/blockscout?ssl=false
36+
ECTO_USE_SSL: 'false'
37+
SECRET_KEY_BASE: '56NtB48ear7+wMSf0IQuWDAAazhpb31qyc7GiyspBP2vh7t5zlCsF5QDv76chXeN'
38+
ports:
39+
- ${DOCKER_LISTEN:-4000}:4000
40+

0 commit comments

Comments
 (0)