Skip to content

Commit 68c5d08

Browse files
authored
feat: Replace hardhat-deploy with ignition, upgrade dependencies and update documentation (#126)
* chore: Update deps * feat: Implement BasicERC20Module * feat: Implement BasicERC721Module * feat: Implement BasicERC1155Module * feat: Use parameters file for config * feat: Use parameters file for config * feat: Use parameters file for config * chore: Update test BasicERC20 * chore: Add from owner to tests * chore: Update test BasicERC721 * chore: Update test BasicERC1155 * chore: Format * chore: Remove hardhat deploy * chore: Remove named accounts * chore: Update solidity version * chore: Rename paramters json * chore: Update license * docs: Update docs to match latest changes * chore: Bump deps and add contributors * chore: Re-organise erc20 imports * chore: Migrate to eslint 9.x
1 parent 802cc92 commit 68c5d08

38 files changed

+2727
-2909
lines changed

.eslintrc.json

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

.prettierrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
{
1111
"files": "*.sol",
1212
"options": {
13-
"parser": "solidity-parse",
14-
"printWidth": 80,
13+
"parser": "slang",
14+
"printWidth": 120,
1515
"tabWidth": 4,
1616
"useTabs": true,
1717
"singleQuote": false,

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Protokol
3+
Copyright (c) 2025 Protokol
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 62 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ All you have to do is create a new repository from the template and start coding
77

88
## Hardhat Configuration
99

10-
- [Typechain](https://github.com/dethcrypto/TypeChain) plugin enabled (typescript type bindings for smart contracts)
11-
- [hardhat-deploy](https://github.com/wighawag/hardhat-deploy) plugin enabled
12-
- Testing environment configured and operational, with test coverage
13-
- Prettier and eslint configured for project files and solidity smart contract
14-
- [Solhint](https://github.com/protofire/solhint) configured for enforcing best practices
15-
- Github actions workflows prepared for CI/CD
16-
- Prepared Smart Contract Examples, Tests, Deployments and Tasks for Common ERC Standards (ERC20, ERC721, ERC1155)
10+
- [Typechain](https://github.com/dethcrypto/TypeChain) plugin enabled (typescript type bindings for smart contracts)
11+
- [Ignition](https://hardhat.org/ignition/docs/getting-started) for contract deployment
12+
- Testing environment configured and operational, with test coverage
13+
- Prettier and eslint configured for project files and solidity smart contract
14+
- [Solhint](https://github.com/protofire/solhint) configured for enforcing best practices
15+
- Github actions workflows prepared for CI/CD
16+
- Prepared Smart Contract Examples, Tests, Deployments and Tasks for Common ERC Standards (ERC20, ERC721, ERC1155)
1717

1818
Check the Hardhat documentation for more information.
1919

@@ -27,30 +27,44 @@ https://hardhat.org/getting-started/
2727
│   ├── BasicERC1155.sol
2828
│   ├── BasicERC20.sol
2929
│   └── BasicERC721.sol
30-
├── deploy
31-
│   ├── Deploy_BasicERC1155.ts
32-
│   ├── Deploy_BasicERC20.ts
33-
│   └── Deploy_BasicERC721.ts
34-
├── deployments
35-
├── hardhat.config.ts
30+
├── ignition
31+
│   ├── deployments
32+
│   ├── modules
33+
│   │   ├── BasicERC1155Module.ts
34+
│   │   ├── BasicERC20Module.ts
35+
│   │   └── BasicERC721Module.ts
36+
│   └── parameters
37+
│   └── custom.json
3638
├── tasks
3739
│   ├── erc1155
40+
│   │   ├── base-uri.ts
41+
│   │   ├── contract-uri.ts
42+
│   │   └── mint.ts
3843
│   ├── erc20
44+
│   │   └── mint.ts
3945
│   ├── erc721
46+
│   │   ├── base-uri.ts
47+
│   │   ├── contract-uri.ts
48+
│   │   └── mint.ts
4049
│   └── utils
41-
└── test
42-
├── BasicERC1155.ts
43-
├── BasicERC20.ts
44-
└── BasicERC721.ts
50+
│   ├── accounts.ts
51+
│   ├── balance.ts
52+
│   ├── block-number.ts
53+
│   └── send-eth.ts
54+
├── test
55+
│   ├── BasicERC1155.ts
56+
│   ├── BasicERC20.ts
57+
│   └── BasicERC721.ts
58+
└── hardhat.config.ts
4559
```
4660

4761
## Supported Networks
4862

49-
- Hardhat Network (localhost)
50-
- Ethereum Mainnet
51-
- Ethereum Sepolia Testnet
52-
- Polygon Mainnet
53-
- Polygon Mumbai Testnet
63+
- Hardhat Network (localhost)
64+
- Ethereum Mainnet
65+
- Ethereum Sepolia Testnet
66+
- Polygon Mainnet
67+
- Polygon Mumbai Testnet
5468

5569
Feel free to add more networks in `hardhat.config.ts` file.
5670

@@ -66,12 +80,12 @@ https://hardhat.org/guides/shorthand.html
6680

6781
### Common Shorthand Commands
6882

69-
- `hh compile` - to compile smart contract and generate typechain ts bindings
70-
- `hh test` - to run tests
71-
- `hh deploy` - to deploy to local network (see options for more)
72-
- `hh node` - to run a localhost node
73-
- `hh help` - to see all available commands
74-
- `hh TABTAB` - to use autocomplete
83+
- `hh compile` - to compile smart contract and generate typechain ts bindings
84+
- `hh test` - to run tests
85+
- `hh igntion` - to deploy smart contracts
86+
- `hh node` - to run a localhost node
87+
- `hh help` - to see all available commands
88+
- `hh TABTAB` - to use autocomplete
7589

7690
## Usage
7791

@@ -101,23 +115,37 @@ Make sure you include either `MNEMONIC` or `PRIVATE_KEY` in your `.env` file.
101115

102116
> This is an example flow to deploy an ERC721 token to a public network and interact with it.
103117
104-
#### 1. Deploy BasicERC721 Contract
118+
#### 1.1 Deploy BasicERC721 Contract
105119

106120
```shell
107-
hh deploy --network sepolia --tags BasicERC721
121+
hh ignition deploy ignition/modules/BasicERC721Module.ts --network sepolia
108122
```
109123

110-
#### 2. Verify Contract
124+
**Verify contract**
111125

112126
```shell
113-
hh --network sepolia etherscan-verify
127+
hh ignition verify chain-11155111
114128
```
115129

116-
#### 3. Interact With Contract - Mint
130+
#### 1.2 Deploy and Verify
131+
132+
```shell
133+
hh ignition deploy ignition/modules/BasicERC721Module.ts --network sepolia --verify
134+
```
135+
136+
#### 1.3 Deploy and Verify with Custom Parameters
137+
138+
Look at `ignition/parameters/custom.json` to see how to adjust contract parameters
139+
140+
```shell
141+
hh ignition deploy ignition/modules/BasicERC721Module.ts --network sepolia --verify --parameters ignition/parameters/custom.json
142+
```
143+
144+
#### 2. Interact With Contract - Mint
117145

118146
```shell
119147
hh erc721-mint \
120-
--contract 0x77337983A7D1699FaF51a5f43b9907fB7B614097 \
148+
--contract 0x1FEB5675Be6F256c4680BE447D6C353E02e04fb9 \
121149
--recipient 0x73faDd7E476a9Bc2dA6D1512A528366A3E50c3cF \
122150
--network sepolia
123151
```

contracts/BasicERC1155.sol

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.20;
2+
pragma solidity 0.8.28;
33

44
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
55
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
@@ -12,13 +12,7 @@ import { ERC1155Supply } from "@openzeppelin/contracts/token/ERC1155/extensions/
1212
* This file was generated with Openzeppelin Wizard and later modified.
1313
* GO TO: https://wizard.openzeppelin.com/#erc1155
1414
*/
15-
contract BasicERC1155 is
16-
ERC1155,
17-
Ownable,
18-
ERC1155Pausable,
19-
ERC1155Burnable,
20-
ERC1155Supply
21-
{
15+
contract BasicERC1155 is ERC1155, Ownable, ERC1155Pausable, ERC1155Burnable, ERC1155Supply {
2216
using Strings for uint256;
2317

2418
string public name;
@@ -54,19 +48,11 @@ contract BasicERC1155 is
5448
_unpause();
5549
}
5650

57-
function mint(
58-
address account,
59-
uint256 id,
60-
uint256 amount
61-
) external onlyOwner {
51+
function mint(address account, uint256 id, uint256 amount) external onlyOwner {
6252
_mint(account, id, amount, "");
6353
}
6454

65-
function mintBatch(
66-
address to,
67-
uint256[] memory ids,
68-
uint256[] memory amounts
69-
) external onlyOwner {
55+
function mintBatch(address to, uint256[] memory ids, uint256[] memory amounts) external onlyOwner {
7056
_mintBatch(to, ids, amounts, "");
7157
}
7258

@@ -79,12 +65,7 @@ contract BasicERC1155 is
7965
* This is useful for metadata published on ipfs where files have .json suffix
8066
*/
8167
function uri(uint256 id) public view override returns (string memory) {
82-
return
83-
bytes(super.uri(id)).length > 0
84-
? string(
85-
abi.encodePacked(super.uri(id), id.toString(), ".json")
86-
)
87-
: "";
68+
return bytes(super.uri(id)).length > 0 ? string(abi.encodePacked(super.uri(id), id.toString(), ".json")) : "";
8869
}
8970

9071
function _update(

contracts/BasicERC20.sol

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.20;
2+
pragma solidity 0.8.28;
33

44
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
55
import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
@@ -29,11 +29,7 @@ contract BasicERC20 is ERC20, ERC20Burnable, ERC20Pausable, Ownable {
2929
_mint(to, amount);
3030
}
3131

32-
function _update(
33-
address from,
34-
address to,
35-
uint256 value
36-
) internal override(ERC20, ERC20Pausable) {
32+
function _update(address from, address to, uint256 value) internal override(ERC20, ERC20Pausable) {
3733
super._update(from, to, value);
3834
}
3935
}

contracts/BasicERC721.sol

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
pragma solidity 0.8.20;
2+
pragma solidity 0.8.28;
33

44
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";
55
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
@@ -12,13 +12,7 @@ import { ERC721Burnable } from "@openzeppelin/contracts/token/ERC721/extensions/
1212
* This file was generated with Openzeppelin Wizard and later modified.
1313
* GO TO: https://wizard.openzeppelin.com/#erc721
1414
*/
15-
contract BasicERC721 is
16-
ERC721,
17-
ERC721Enumerable,
18-
ERC721Pausable,
19-
Ownable,
20-
ERC721Burnable
21-
{
15+
contract BasicERC721 is ERC721, ERC721Enumerable, ERC721Pausable, Ownable, ERC721Burnable {
2216
using Strings for uint256;
2317

2418
uint256 private _nextTokenId;
@@ -71,42 +65,25 @@ contract BasicERC721 is
7165
* @dev Returns base uri and adds .json suffix
7266
* This is useful for metadata published on ipfs where files have .json suffix
7367
*/
74-
function tokenURI(
75-
uint256 tokenId
76-
) public view override returns (string memory) {
77-
if (ownerOf(tokenId) == address(0))
78-
revert ERC721NonexistentToken(tokenId);
79-
80-
return
81-
bytes(_baseURI()).length > 0
82-
? string(
83-
abi.encodePacked(_baseURI(), tokenId.toString(), ".json")
84-
)
85-
: "";
68+
function tokenURI(uint256 tokenId) public view override returns (string memory) {
69+
if (ownerOf(tokenId) == address(0)) revert ERC721NonexistentToken(tokenId);
70+
71+
return bytes(_baseURI()).length > 0 ? string(abi.encodePacked(_baseURI(), tokenId.toString(), ".json")) : "";
8672
}
8773

8874
function _update(
8975
address to,
9076
uint256 tokenId,
9177
address auth
92-
)
93-
internal
94-
override(ERC721, ERC721Enumerable, ERC721Pausable)
95-
returns (address)
96-
{
78+
) internal override(ERC721, ERC721Enumerable, ERC721Pausable) returns (address) {
9779
return super._update(to, tokenId, auth);
9880
}
9981

100-
function _increaseBalance(
101-
address account,
102-
uint128 value
103-
) internal override(ERC721, ERC721Enumerable) {
82+
function _increaseBalance(address account, uint128 value) internal override(ERC721, ERC721Enumerable) {
10483
super._increaseBalance(account, value);
10584
}
10685

107-
function supportsInterface(
108-
bytes4 interfaceId
109-
) public view override(ERC721, ERC721Enumerable) returns (bool) {
86+
function supportsInterface(bytes4 interfaceId) public view override(ERC721, ERC721Enumerable) returns (bool) {
11087
return super.supportsInterface(interfaceId);
11188
}
11289
}

deploy/Deploy_BasicERC1155.ts

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

deploy/Deploy_BasicERC20.ts

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

deploy/Deploy_BasicERC721.ts

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

0 commit comments

Comments
 (0)