Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4e87e17

Browse files
committedMar 20, 2025
feat: initial setup
0 parents  commit 4e87e17

22 files changed

+8786
-0
lines changed
 

‎.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WALLET_PRIVATE_KEY=

‎.gitignore

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.vscode
9+
10+
# hardhat artifacts
11+
artifacts
12+
cache
13+
14+
# zksync artifacts
15+
artifacts-zk
16+
cache-zk
17+
18+
# Diagnostic reports (https://nodejs.org/api/report.html)
19+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
20+
21+
# Runtime data
22+
pids
23+
*.pid
24+
*.seed
25+
*.pid.lock
26+
27+
# Directory for instrumented libs generated by jscoverage/JSCover
28+
lib-cov
29+
30+
# Coverage directory used by tools like istanbul
31+
coverage
32+
*.lcov
33+
34+
# nyc test coverage
35+
.nyc_output
36+
37+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
bower_components
42+
43+
# node-waf configuration
44+
.lock-wscript
45+
46+
# Compiled binary addons (https://nodejs.org/api/addons.html)
47+
build/Release
48+
49+
# Dependency directories
50+
node_modules/
51+
jspm_packages/
52+
53+
# TypeScript v1 declaration files
54+
typings/
55+
56+
# TypeScript cache
57+
*.tsbuildinfo
58+
59+
# Optional npm cache directory
60+
.npm
61+
62+
# Optional eslint cache
63+
.eslintcache
64+
65+
# Microbundle cache
66+
.rpt2_cache/
67+
.rts2_cache_cjs/
68+
.rts2_cache_es/
69+
.rts2_cache_umd/
70+
71+
# Optional REPL history
72+
.node_repl_history
73+
74+
# Output of 'npm pack'
75+
*.tgz
76+
77+
# Yarn Integrity file
78+
.yarn-integrity
79+
80+
# dotenv environment variables file
81+
.env
82+
.env.test
83+
84+
# parcel-bundler cache (https://parceljs.org/)
85+
.cache
86+
87+
# Next.js build output
88+
.next
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# Serverless directories
104+
.serverless/
105+
106+
# FuseBox cache
107+
.fusebox/
108+
109+
# DynamoDB Local files
110+
.dynamodb/
111+
112+
# TernJS port file
113+
.tern-port
114+
115+
# Deployment files
116+
deployments-zk
117+
118+
era_test_node.log
119+
anvil_zksync.log

‎.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

‎LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Matter Labs
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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# ZKsync Hardhat project template
2+
3+
This project was scaffolded with [zksync-cli](https://github.com/matter-labs/zksync-cli).
4+
5+
## Project Layout
6+
7+
- `/contracts`: Contains solidity smart contracts.
8+
- `/deploy`: Scripts for contract deployment and interaction.
9+
- `/test`: Test files.
10+
- `hardhat.config.ts`: Configuration settings.
11+
12+
## How to Use
13+
14+
- `npm run compile`: Compiles contracts.
15+
- `npm run deploy`: Deploys using script `/deploy/deploy.ts`.
16+
- `npm run interact`: Interacts with the deployed contract using `/deploy/interact.ts`.
17+
- `npm run test`: Tests the contracts.
18+
19+
Note: Both `npm run deploy` and `npm run interact` are set in the `package.json`. You can also run your files directly, for example: `npx hardhat deploy-zksync --script deploy.ts`
20+
21+
### Environment Settings
22+
23+
To keep private keys safe, this project pulls in environment variables from `.env` files. Primarily, it fetches the wallet's private key.
24+
25+
Rename `.env.example` to `.env` and fill in your private key:
26+
27+
```
28+
WALLET_PRIVATE_KEY=your_private_key_here...
29+
```
30+
31+
### Network Support
32+
33+
`hardhat.config.ts` comes with a list of networks to deploy and test contracts. Add more by adjusting the `networks` section in the `hardhat.config.ts`. To make a network the default, set the `defaultNetwork` to its name. You can also override the default using the `--network` option, like: `hardhat test --network dockerizedNode`.
34+
35+
### Local Tests
36+
37+
Running `npm run test` by default runs the [ZKsync In-memory Node](https://docs.zksync.io/build/test-and-debug/in-memory-node) provided by the [@matterlabs/hardhat-zksync-node](https://docs.zksync.io/build/tooling/hardhat/hardhat-zksync-node) tool.
38+
39+
Important: ZKsync In-memory Node currently supports only the L2 node. If contracts also need L1, use another testing environment like Dockerized Node. Refer to [test documentation](https://docs.zksync.io/build/test-and-debug) for details.
40+
41+
## Useful Links
42+
43+
- [Docs](https://docs.zksync.io/build)
44+
- [Official Site](https://zksync.io/)
45+
- [GitHub](https://github.com/matter-labs)
46+
- [Twitter](https://twitter.com/zksync)
47+
- [Discord](https://join.zksync.dev/)
48+
49+
## License
50+
51+
This project is under the [MIT](./LICENSE) license.

‎bun.lockb

260 KB
Binary file not shown.

‎contracts/Greeter.sol

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
contract Greeter {
5+
string private greeting;
6+
7+
constructor(string memory _greeting) {
8+
greeting = _greeting;
9+
}
10+
11+
function greet() public view returns (string memory) {
12+
return greeting;
13+
}
14+
15+
function setGreeting(string memory _greeting) public {
16+
greeting = _greeting;
17+
}
18+
}

‎contracts/erc20/MyERC20Token.sol

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
6+
7+
/**
8+
* @title MyERC20Token
9+
* @dev This is a basic ERC20 token using the OpenZeppelin's ERC20PresetFixedSupply preset.
10+
* You can edit the default values as needed.
11+
*/
12+
contract MyERC20Token is ERC20Burnable {
13+
14+
/**
15+
* @dev Constructor to initialize the token with default values.
16+
* You can edit these values as needed.
17+
*/
18+
constructor() ERC20("DefaultTokenName", "DTN") {
19+
// Default initial supply of 1 million tokens (with 18 decimals)
20+
uint256 initialSupply = 1_000_000 * (10 ** 18);
21+
22+
// The initial supply is minted to the deployer's address
23+
_mint(msg.sender, initialSupply);
24+
}
25+
26+
// Additional functions or overrides can be added here if needed.
27+
}

‎contracts/nft/MyNFT.sol

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: MIT
2+
3+
pragma solidity ^0.8.0;
4+
5+
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
6+
import "@openzeppelin/contracts/access/Ownable.sol";
7+
8+
/**
9+
* @title MyNFT
10+
* @dev Basic ERC721 token with auto-incrementing token IDs.
11+
* The owner can mint new tokens. Token URIs are autogenerated based on a base URI.
12+
*/
13+
contract MyNFT is ERC721Enumerable, Ownable {
14+
uint256 private _currentTokenId;
15+
string private _baseTokenURI;
16+
17+
constructor(
18+
string memory name,
19+
string memory symbol,
20+
string memory baseTokenURI,
21+
address initialOwner
22+
) ERC721(name, symbol) Ownable(initialOwner) {
23+
_baseTokenURI = baseTokenURI;
24+
}
25+
26+
function _baseURI() internal view virtual override returns (string memory) {
27+
return _baseTokenURI;
28+
}
29+
30+
function mint(address to) external onlyOwner {
31+
uint256 tokenId = _currentTokenId;
32+
_mint(to, tokenId);
33+
_currentTokenId += 1;
34+
}
35+
}

0 commit comments

Comments
 (0)
Please sign in to comment.