Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,27 @@ if (registeredAddress.interfaceIds.includes(knownInterfaces.IDistributor)) {

## Deployed Smart Contracts


### zkSync Mainnet

- [0x3551BA6B7b3edfF8b1c82b87D1De606270Aec24F](https://explorer.zksync.io/address/0x3551BA6B7b3edfF8b1c82b87D1De606270Aec24F)
- [0xfb563bAAaB145Bd393b36a2a76E92A1712F41f8C](https://explorer.zksync.io/address/0xfb563bAAaB145Bd393b36a2a76E92A1712F41f8C)
- [0x870C1744173498905c9a1Da624CcC9852513f90D](https://explorer.zksync.io/address/0xEaC172D6Fd56933F894176eE32Dd95b0a4abb083)
- [0xB63DC17fA834AA961aE88b6005e507Ddb60B2c53](https://explorer.zksync.io/address/0xB63DC17fA834AA961aE88b6005e507Ddb60B2c53)
- [0xc6B19D47a336d3382f57EdD768233076a27C28c2](https://explorer.zksync.io/address/0xc6B19D47a336d3382f57EdD768233076a27C28c2)
- [0xEaC172D6Fd56933F894176eE32Dd95b0a4abb083](https://explorer.zksync.io/address/0xEaC172D6Fd56933F894176eE32Dd95b0a4abb083)

### zkSync sepolia

- [0x3551BA6B7b3edfF8b1c82b87D1De606270Aec24F](https://sepolia.explorer.zksync.io/address/0x3551BA6B7b3edfF8b1c82b87D1De606270Aec24F#contract)
- [0xd1515bB65096d67895287bC180521007bc71900F](https://sepolia.explorer.zksync.io/address/0xd1515bB65096d67895287bC180521007bc71900F#contract)
- [0xf38756A27593CEd6b4bF3807b44a88908b3d8ccC](https://sepolia.explorer.zksync.io/address/0xf38756A27593CEd6b4bF3807b44a88908b3d8ccC#contract)
- [0x5CD85a2C91ba4420E0247c3bB7CEe1299EA150c8](https://sepolia.explorer.zksync.io/address/0x5CD85a2C91ba4420E0247c3bB7CEe1299EA150c8#contract)
- [0xEaC172D6Fd56933F894176eE32Dd95b0a4abb083](https://sepolia.explorer.zksync.io/address/0xEaC172D6Fd56933F894176eE32Dd95b0a4abb083#contract)
- [0x5B8a021F311BDAbE7DcA7bEf84DBF3D1FFa80846](https://sepolia.explorer.zksync.io/address/0x5B8a021F311BDAbE7DcA7bEf84DBF3D1FFa80846#contract)



### Base sepolia

- [0x4aD35755F3bC7d591CBa3D0D0Eb27C2497A73d30](https://sepolia.basescan.org/address/0x4aD35755F3bC7d591CBa3D0D0Eb27C2497A73d30)
Expand Down
1 change: 1 addition & 0 deletions packages/hardhat/zksync-hardhat/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WALLET_PRIVATE_KEY=
113 changes: 113 additions & 0 deletions packages/hardhat/zksync-hardhat/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.vscode

# hardhat artifacts
artifacts
cache

# zksync artifacts
artifacts-zk
cache-zk

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port
21 changes: 21 additions & 0 deletions packages/hardhat/zksync-hardhat/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Matter Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
51 changes: 51 additions & 0 deletions packages/hardhat/zksync-hardhat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# zkSync Hardhat project template

This project was scaffolded with [zksync-cli](https://github.com/matter-labs/zksync-cli).

## Project Layout

- `/contracts`: Contains solidity smart contracts.
- `/deploy`: Scripts for contract deployment and interaction.
- `/test`: Test files.
- `hardhat.config.ts`: Configuration settings.

## How to Use

- `npm run compile`: Compiles contracts.
- `npm run deploy`: Deploys using script `/deploy/deploy.ts`.
- `npm run interact`: Interacts with the deployed contract using `/deploy/interact.ts`.
- `npm run test`: Tests the contracts.

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`

### Environment Settings

To keep private keys safe, this project pulls in environment variables from `.env` files. Primarily, it fetches the wallet's private key.

Rename `.env.example` to `.env` and fill in your private key:

```
WALLET_PRIVATE_KEY=your_private_key_here...
```

### Network Support

`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`.

### Local Tests

Running `npm run test` by default runs the [zkSync In-memory Node](https://era.zksync.io/docs/tools/testing/era-test-node.html) provided by the [@matterlabs/hardhat-zksync-node](https://era.zksync.io/docs/tools/hardhat/hardhat-zksync-node.html) tool.

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://era.zksync.io/docs/tools/testing/) for details.

## Useful Links

- [Docs](https://era.zksync.io/docs/dev/)
- [Official Site](https://zksync.io/)
- [GitHub](https://github.com/matter-labs)
- [Twitter](https://twitter.com/zksync)
- [Discord](https://join.zksync.dev/)

## License

This project is under the [MIT](./LICENSE) license.
18 changes: 18 additions & 0 deletions packages/hardhat/zksync-hardhat/contracts/Greeter.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;

contract Greeter {
string private greeting;

constructor(string memory _greeting) {
greeting = _greeting;
}

function greet() public view returns (string memory) {
return greeting;
}

function setGreeting(string memory _greeting) public {
greeting = _greeting;
}
}
27 changes: 27 additions & 0 deletions packages/hardhat/zksync-hardhat/contracts/erc20/MyERC20Token.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";

/**
* @title MyERC20Token
* @dev This is a basic ERC20 token using the OpenZeppelin's ERC20PresetFixedSupply preset.
* You can edit the default values as needed.
*/
contract MyERC20Token is ERC20Burnable {

/**
* @dev Constructor to initialize the token with default values.
* You can edit these values as needed.
*/
constructor() ERC20("DefaultTokenName", "DTN") {
// Default initial supply of 1 million tokens (with 18 decimals)
uint256 initialSupply = 1_000_000 * (10 ** 18);

// The initial supply is minted to the deployer's address
_mint(msg.sender, initialSupply);
}

// Additional functions or overrides can be added here if needed.
}
39 changes: 39 additions & 0 deletions packages/hardhat/zksync-hardhat/contracts/nft/MyNFT.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

/**
* @title MyNFT
* @dev Basic ERC721 token with auto-incrementing token IDs.
* The owner can mint new tokens. Token URIs are autogenerated based on a base URI.
*/
contract MyNFT is ERC721Enumerable, Ownable {
using Counters for Counters.Counter;
Counters.Counter private _tokenIdTracker;
string private _baseTokenURI;

constructor(string memory name, string memory symbol, string memory baseTokenURI) ERC721(name, symbol) {
_baseTokenURI = baseTokenURI;
}

function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}

/**
* @dev Mints a new token to the specified address.
* Only the owner can mint new tokens.
* @param to The address that will receive the minted token.
*/
function mint(address to) external onlyOwner {
_tokenIdTracker.increment();
_mint(to, _tokenIdTracker.current());
}


// Additional functions or overrides can be added here if needed.
}
Loading