Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hardhat quickstart new templates #312

Merged
merged 4 commits into from
Feb 10, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ If you want to migrate an existing project, please check the [project migration

The `hardhat.config.ts` file contains some ZKsync Era specific configurations:

The ZKsync Era deployment and compiler plugin imports:

#### Solidity project

```ts
Expand All @@ -79,7 +77,7 @@ The `zkvyper` block contains the minimal configuration for the compiler.

#### Network

The default network is set to `zkSyncSepoliaTestnet`, but mainnet and local test node networks are also configured.
The default network is set to `ZKsyncEraSepolia`, but mainnet and local test node networks are also configured.

```ts
:code-import{filePath="hardhat-sol-template/hardhat.config.ts:networks"}
Expand All @@ -105,7 +103,7 @@ Your private key will be used for paying the costs of deploying the smart contra

## Compile and deploy a contract

Smart contracts belong in the `contracts` folder.
Smart contracts belong in the `contracts` folder. Both the Solidity and Vyper templates contain a simple `Greeter` contract.

#### 1. To compile the contract, run

Expand All @@ -132,7 +130,7 @@ bun compile
You'll see the following output:

```text
Compiling 1 Solidity file
Compiling contracts for ZKsync Era with zksolc v1.5.10 and zkvm-solc v0.8.28-1.0.1
Successfully compiled 1 Solidity file
// Successfully compiled 1 Vyper file - Vyper project
✨ Done in 1.09s.
Expand All @@ -145,10 +143,10 @@ These folders contain the compilation artifacts (including contract's ABIs) and
The `artifacts-zk` and `cache-zk` folders are included in the `.gitignore` file.
::

In the `deploy` folder, the `deploy.ts` script shows an example of how to deploy the `Greeter.sol`/`Greeter.vy` contract.
In the `scripts` folder, the `deploy.ts` script shows an example of how to deploy the `Greeter.sol`/`Greeter.vy` contract.

```ts
:code-import{filePath="hardhat-sol-template/deploy/deploy.ts"}
:code-import{filePath="hardhat-sol-template/scripts/deploy.ts"}
```

#### 2. To execute the deployment script run
Expand Down Expand Up @@ -178,22 +176,16 @@ This script deploys the `Greeting` contract with the message "Hi there!" to %%zk
You should see something like this:

```bash
Running deploy script for the Greeter contract
The deployment is estimated to cost 0.00579276320831943 ETH
constructor args:0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000094869207468657265210000000000000000000000000000000000000000000000
Deploying Greeter contract to ZKsyncEraSepolia
Greeter was deployed to 0x46f1d2d8A16DBD8b47e9D61175a826ac667288Be4D1293a22E8

✨ Done in 12.69s.
```

Congratulations! You have deployed a smart contract project to %%zk_testnet_name%% with Hardhat 🎉

::callout{icon="i-heroicons-exclamation-triangle" color="amber"}
**Request-Rate Exceeded message**:

- This message is caused by using the default RPC endpoints provided by ethers.
- To avoid this, use your own Sepolia RPC endpoint in the `hardhat.config.ts` file.
- Find multiple [node providers here](https://github.com/arddluma/awesome-list-rpc-nodes-providers).
::callout{icon="i-heroicons-cube-transparent-solid" color="blue"}
The Solidity template additionally contains a token and NFT contracts and deployment scripts.
::

## Interact with the contract
Expand All @@ -203,7 +195,7 @@ The template project contains another script to interact with the contract.
1. Enter the address of the deployed Greeter contract in the `CONTRACT_ADDRESS` variable of the `interact.ts` script:

```ts [interact.ts]
:code-import{filePath="hardhat-sol-template/deploy/interact.ts"}
:code-import{filePath="hardhat-sol-template/scripts/interact.ts"}
```

1. To execute the script, run:
Expand Down Expand Up @@ -237,10 +229,10 @@ The template project contains another script to interact with the contract.
You should see something like this:

```bash
Running script to interact with contract Greeter
The message is Hello there!
Transaction to change the message is 0x12f16578A16DB0f47e9D61175a823ac214288Af
The message now is Hello people!
Running script to interact with contract 0xaB387e2bf9068Ee39C76fdd16F80b2078Ff73F3D
Current message is: Hi there!
Transaction hash of setting new message: 0xe7ea1fa4041ff0d5a117d0d53c8d8934c4a9e1f4730f58ca2bae7389f428fbf2
The message now is: Hello people!

✨ Done in 14.32s.
```
Expand Down
14 changes: 0 additions & 14 deletions examples/hardhat-sol-template/deploy/deploy-greeter.ts

This file was deleted.

10 changes: 0 additions & 10 deletions examples/hardhat-sol-template/deploy/deploy.ts

This file was deleted.

36 changes: 0 additions & 36 deletions examples/hardhat-sol-template/deploy/interact.ts

This file was deleted.

175 changes: 0 additions & 175 deletions examples/hardhat-sol-template/deploy/utils.ts

This file was deleted.

10 changes: 5 additions & 5 deletions examples/hardhat-sol-template/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import '@matterlabs/hardhat-zksync';
// ANCHOR_END: zksync-import
const config: HardhatUserConfig = {
// ANCHOR: networks
defaultNetwork: 'zkSyncSepoliaTestnet',
defaultNetwork: 'ZKsyncEraSepolia',
networks: {
zkSyncSepoliaTestnet: {
ZKsyncEraSepolia: {
url: 'https://sepolia.era.zksync.dev',
ethNetwork: 'sepolia',
zksync: true,
verifyURL: 'https://explorer.sepolia.era.zksync.dev/contract_verification',
},
zkSyncMainnet: {
ZKsyncEraMainnet: {
url: 'https://mainnet.era.zksync.io',
ethNetwork: 'mainnet',
zksync: true,
Expand All @@ -23,7 +23,7 @@ const config: HardhatUserConfig = {
ethNetwork: 'http://localhost:8545',
zksync: true,
},
inMemoryNode: {
anvilZKsync: {
url: 'http://127.0.0.1:8011',
ethNetwork: 'localhost', // in-memory node doesn't support eth node; removing this line will cause an error
zksync: true,
Expand All @@ -40,7 +40,7 @@ const config: HardhatUserConfig = {
},
// ANCHOR_END: zksolc
solidity: {
version: '0.8.17',
version: '0.8.24',
},
};

Expand Down
Loading
Loading