This is a guide on how to deploy [Ethernaut](https://github.com/OpenZeppelin/ethernaut) on ZkSync using the Yul Evm Interperter
# Prerequisites
Install [zksolc](https://github.com/matter-labs/zksolc-bin/releases/tag/v1.4.1)
Move it to usr/local/bin and give it permissions
```jsx
sudo mv zksolc-macosx-arm64-v1.4.1 /usr/local/bin/zksolc
chmod a+x /usr/local/bin/zksolc
```
# Running Zksync server
Clone [zksync-era](https://github.com/matter-labs/zksync-era/)
```jsx
git clone git@github.com:matter-labs/zksync-era.git
cd zksync-era
```
Checkout `evm-equivalence-yul` branch
```jsx
git checkout evm-equivalence-yul
```
Compile the interpreter
```jsx
git submodule update --init
npm install -g preprocess-cli-tool
./recompile_interpreter.sh
```
Run the server
```jsx
export ZKSYNC_HOME=$(pwd)
export PATH=$ZKSYNC_HOME/bin:$PATH
zk
zk env dev
zk config compile dev
zk init && zk server
```
If you don’t have balance on your account you can run the following on a separate terminal
```jsx
zk test i server
```
# Adding the Network to Metamask
Open Metamask and go to the network selection, click Add network
Fill up the form fields:
`Network name` : `Zksync local`
`New RPC URL` : `http:/localhost:3050`
`Chain ID` : `270`
`Currency Symbol` : `ETH`
Change to the new network
If you don’t have funds on your account, you can use one of the zksync rich accounts
Go to your account on metamask, click add account or hardware wallet, import account, and put the private key, then connect to the new account.
Private key: `0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110`
# Running Ethernaut
On a separate terminal
- Clone the repo and install dependencies:
```jsx
git clone git@github.com:OpenZeppelin/ethernaut.git
cd ethernaut
yarn install
```
- You’ll need to change line 44 from file
`ethernaut/node_modules/@truffle/contract/lib/utils/ens.js` .
To this:
```jsx
ensAddress: registryAddress != null ? registryAddress : getEnsAddress(networkId)
```
- Compile contracts:
```jsx
yarn compile:contracts
```
- Run
```jsx
export NODE_OPTIONS=--openssl-legacy-provider
```
Apply this diff patch:
Just copy the snippet below and then apply the patch like this: `pbpaste | git apply`
```diff
diff --git a/client/src/constants.js b/client/src/constants.js
index ff8c55e..3f1a489 100644
--- a/client/src/constants.js
+++ b/client/src/constants.js
@@ -18,9 +18,9 @@ export const NETWORKS = {
},
SEPOLIA: {
name: "sepolia",
- id: "11155111",
- url: `${process.env.SEPOLIA_HOST}`,
- privKey: `${process.env.PRIV_KEY}`,
+ id: "270",
+ url: `http://localhost:3050`,
+ privKey: `7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110`,
},
OPTIMISM_SEPOLIA: {
name: "sepolia-optimism",
@@ -59,7 +59,7 @@ export const NETWORKS_INGAME = {
},
SEPOLIA: {
name: "sepolia",
- id: "11155111",
+ id: "270",
currencyName: "Sepolia-ETH",
currencySymbol: "SEP",
rpcUrl: `https://rpc.sepolia.org`,
@@ -150,7 +150,7 @@ export const GOOGLE_ANALYTICS_ID = "UA-85043059-4";
// Owner addresses
export const ADDRESSES = {
[NETWORKS.LOCAL.name]: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
- [NETWORKS.SEPOLIA.name]: "0x09902A56d04a9446601a0d451E07459dC5aF0820",
+ [NETWORKS.SEPOLIA.name]: "0x36615Cf349d7F6344891B1e7CA7C72883F5dc049",
[NETWORKS.OPTIMISM_SEPOLIA.name]:
"0x09902A56d04a9446601a0d451E07459dC5aF0820",
[NETWORKS.ARBITRUM_SEPOLIA.name]:
@@ -195,7 +195,7 @@ export const CUSTOM_LOGGING = true; /* TRUE on production */
export const SHOW_ALL_COMPLETE_DESCRIPTIONS = false; /* FALSE on production */
export const SHOW_VERSION = true;
-// export const ACTIVE_NETWORK = NETWORKS.SEPOLIA
+export const ACTIVE_NETWORK = NETWORKS.SEPOLIA
// export const ACTIVE_NETWORK = NETWORKS.MUMBAI
// export const ACTIVE_NETWORK = NETWORKS.OPTIMISM_SEPOLIA
// export const ACTIVE_NETWORK = NETWORKS.ARBITRUM_SEPOLIA
diff --git a/client/src/gamedata/deploy.sepolia.json b/client/src/gamedata/deploy.sepolia.json
index 0c062a0..0967ef4 100644
--- a/client/src/gamedata/deploy.sepolia.json
+++ b/client/src/gamedata/deploy.sepolia.json
@@ -1,48 +1 @@
-{
- "0": "0x7E0f53981657345B31C59aC44e9c21631Ce710c7",
- "1": "0x3c34A342b2aF5e885FcaA3800dB5B205fEfa3ffB",
- "2": "0x676e57FdBbd8e5fE1A7A3f4Bb1296dAC880aa639",
- "3": "0xA62fE5344FE62AdC1F356447B669E9E6D10abaaF",
- "4": "0x2C2307bb8824a0AbBf2CC7D76d8e63374D2f8446",
- "5": "0x478f3476358Eb166Cb7adE4666d04fbdDB56C407",
- "6": "0x73379d8B82Fda494ee59555f333DF7D44483fD58",
- "7": "0xb6c2Ec883DaAac76D8922519E63f875c2ec65575",
- "8": "0xB7257D8Ba61BD1b3Fb7249DCd9330a023a5F3670",
- "9": "0x3049C00639E6dfC269ED1451764a046f7aE500c6",
- "10": "0x2a24869323C0B13Dff24E196Ba072dC790D52479",
- "11": "0x6DcE47e94Fa22F8E2d8A7FDf538602B1F86aBFd2",
- "12": "0x131c3249e115491E83De375171767Af07906eA36",
- "13": "0xb5858B8EDE0030e46C0Ac1aaAedea8Fb71EF423C",
- "14": "0x0C791D1923c738AC8c4ACFD0A60382eE5FF08a23",
- "15": "0x80934BE6B8B872B364b470Ca30EaAd8AEAC4f63F",
- "16": "0x7ae0655F0Ee1e7752D7C62493CEa1E69A810e2ed",
- "17": "0xAF98ab8F2e2B24F42C661ed023237f5B7acAB048",
- "18": "0x2132C7bc11De7A90B87375f282d36100a29f97a9",
- "19": "0x0BC04aa6aaC163A6B3667636D798FA053D43BD11",
- "20": "0x2427aF06f748A6adb651aCaB0cA8FbC7EaF802e6",
- "21": "0x691eeA9286124c043B82997201E805646b76351a",
- "22": "0xB468f8e42AC0fAe675B56bc6FDa9C0563B61A52F",
- "23": "0xf59112032D54862E199626F55cFad4F8a3b0Fce9",
- "24": "0x725595BA16E76ED1F6cC1e1b65A88365cC494824",
- "25": "0x3A78EE8462BD2e31133de2B8f1f9CBD973D6eDd6",
- "26": "0x34bD06F195756635a10A7018568E033bC15F3FB5",
- "27": "0x36E92B2751F260D6a4749d7CA58247E7f8198284",
- "28": "0x653239b3b3E67BC0ec1Df7835DA2d38761FfD882",
- "29": "0xb2aBa0e156C905a9FAEc24805a009d99193E3E53",
- "30": "0xd459773f02e53F6e91b0f766e42E495aEf26088F",
- "31": "0xB99f27b94fCc8b9b6fF88e29E1741422DFC06224",
- "ethernaut": "0xa3e7317E591D5A0F1c605be1b3aC4D2ae56104d6",
- "implementation": "0x49662cAeF8386f84d99873c34280E24d3e742e4f",
- "proxyAdmin": "0x545d848827bD9e0E30794a9E53f5ab04EA71d78a",
- "proxyStats": "0x57d122d0355973dA78acF5138aE664548bB2CA2b",
- "supersededAddresses": [
- {
- "oldAddress": "0x27bC920e7C426500a0e7D63Bb037800A7288abC1",
- "newAddress": "0x0BC04aa6aaC163A6B3667636D798FA053D43BD11"
- },
- {
- "oldAddress": "0x5B50F1F5fE2Bef0a0429fD27B8214d856066F45e",
- "newAddress": "0x653239b3b3E67BC0ec1Df7835DA2d38761FfD882"
- }
- ]
-}
\ No newline at end of file
+{}
diff --git a/client/src/middlewares/loadLevelInstance.js b/client/src/middlewares/loadLevelInstance.js
index 817cf4f..5117847 100644
--- a/client/src/middlewares/loadLevelInstance.js
+++ b/client/src/middlewares/loadLevelInstance.js
@@ -38,22 +38,19 @@ const loadLevelInstance = (store) => (next) => (action) => {
error || ''
);
};
-
- const estimate = parseInt(action.level.instanceGas, 10) || 2000000;
- const deployFunds = state.network.web3.utils.toWei(
- parseFloat(action.level.deployFunds, 10).toString(),
- 'ether'
- );
getGasFeeDetails(state.network, 2).then(gasFeeDetails => {
- state.contracts.ethernaut
- .createLevelInstance(action.level.deployedAddress, {
- // 2.5 * estimate is required for level creation to succeed in arbitrum goerli
- gas: 2.5 * estimate.toString(),
+ state.contracts.ethernaut.createLevelInstance.estimateGas(
+ action.level.deployedAddress, {
+ // 2.5 * estimate is required for level creation to succeed in arbitrum goerli
+ ...gasFeeDetails,
+ from: state.player.address,
+ }).then(estimation => {
+ state.contracts.ethernaut.createLevelInstance(
+ action.level.deployedAddress, {
+ gas: estimation,
...gasFeeDetails,
from: state.player.address,
- value: deployFunds,
- })
- .then((tx) => {
+ }).then((tx) => {
for (var i = 0; i < tx.logs.length; i++) {
if (tx.logs[i].event === "LevelInstanceCreatedLog") {
instanceAddress = tx.logs[i].args.instance;
@@ -64,7 +61,6 @@ const loadLevelInstance = (store) => (next) => (action) => {
if (!instanceAddress) {
showErr(strings.transactionNoLogsMessage)
} else {
- // Wait for the contract to index in the explorer
setTimeout(() => {
verifyContract(instanceAddress, action.level, state.network.networkId);
}, 30000);
@@ -72,7 +68,10 @@ const loadLevelInstance = (store) => (next) => (action) => {
}).catch((error) => {
showErr(error)
});
- })
+ });
+ }).catch((error) => {
+ showErr(error)
+ });
}
// Get instance from address
```
Deploy contracts:
```jsx
yarn deploy:contracts
```
Build ethernaut:
```jsx
yarn build:ethernaut
```
Run ethernaut:
```jsx
yarn start:ethernaut
```
Try to solve the first level