|
| 1 | +This quickstart guides you through the process of setting up a CDK validium on your local machine. |
1 | 2 |
|
| 3 | +!!! danger "Is it true?" |
| 4 | + Please note that the current Data Availability (DA) configuration in Polygon CDK is using a Data Availability Committee (DAC) node with a local Geth client as the L1. However, the integration with Layer 1 testnets, including Sepoilla, is actively being pursued. |
2 | 5 |
|
3 | | -!!! info |
4 | | - Please view the third-party content disclaimer [<ins>here</ins>](https://github.com/0xPolygon/wiki/blob/master/CONTENT_DISCLAIMER.md). |
5 | | - |
6 | | -This tutorial will guide you through the process of setting up a CDK Validium on your local machine using the deployment guidance of [<ins>Snapchain</ins>](https://www.snapchain.dev/). |
7 | | - |
8 | | -Please note that the current Data Availability (DA) configuration in Polygon CDK is using a Data Availability Committee (DAC) node with a local Geth client as the L1. However, the integration with Layer 1 testnets, including Sepoilla, is actively being pursued. |
9 | | - |
10 | | -The CDK Validium is actively being developed, with ongoing feature enhancements and issue resolutions. For the latest updates, follow our official GitHub repositories. |
11 | | - |
12 | | -- [<ins>Node</ins>](https://github.com/0xPolygon/cdk-validium-node) |
13 | | -- [<ins>Data availability</ins>](https://github.com/0xPolygon/cdk-data-availability) |
14 | | -- [<ins>Contracts</ins>](https://github.com/0xPolygon/cdk-validium-contracts) |
15 | | - |
16 | | -New features and refinements are designed to enhance user experience without disrupting ongoing activities. |
17 | | - |
18 | | -::: |
19 | | - |
20 | | -## What you'll learn |
21 | | - |
22 | | -In this tutorial, you'll quickly dive into the world of Polygon CDK. You'll learn to set up and run a local CDK-based chain, enabling you to: |
23 | | - |
24 | | -- Gain a rapid understanding of Polygon CDK. |
25 | | -- Test smart contracts. |
26 | | -- Execute web3 transactions. |
27 | | -- Investigate network capabilities. |
28 | | - |
29 | | -## What you'll need |
30 | | - |
31 | | -This tutorial requires Docker and Docker Compose. They allow you to run multiple services in separate environments. If you haven't installed these tools yet, you can do so by following the guides at the following links: |
| 6 | +## Prerequisites |
32 | 7 |
|
33 | | -- [<ins>Docker</ins>](https://www.docker.com/get-started) |
34 | | -- [<ins>Docker Compose</ins>](https://docs.docker.com/compose/install/) |
| 8 | +### System requirements |
35 | 9 |
|
36 | | -### Recommended System Requirements |
| 10 | +- A Linux-based OS (e.g., Ubuntu Server 22.04 LTS). |
| 11 | +- At least 16GB RAM with a 4-core CPU. |
| 12 | +- An AMD64 architecture system. |
37 | 13 |
|
38 | | -Ensure that your system meets the following recommended specifications before starting this tutorial: |
| 14 | +!!! warning |
| 15 | + CDK does not support ARM-based Macs |
39 | 16 |
|
40 | | -- A Linux-based OS (e.g., Ubuntu Server 22.04 LTS) |
41 | | -- At least 16GB RAM with a 4-core CPU |
42 | | -- An AMD64 architecture system |
| 17 | +### Software requirements |
43 | 18 |
|
44 | | -:::caution Does not yet support ARM-based Macs |
| 19 | +- [Docker](https://www.docker.com/get-started) |
| 20 | +- [Docker Compose](https://docs.docker.com/compose/install/) |
45 | 21 |
|
46 | | -::: |
| 22 | +## 1. Clone the repo |
47 | 23 |
|
48 | | -## What You'll Do |
49 | | - |
50 | | -In this tutorial, you'll go through the following steps. Make sure to follow each section in order if this is your first time setting up a zkValidium. |
51 | | - |
52 | | -1. [<ins>Download Configuration Files</ins>](#step-1-download-configuration-files): You'll start by downloading necessary configuration files from our repository. |
53 | | -2. [<ins>Launch the Validium Locally</ins>](#step-2-launch-the-validium-locally): After setting up your workspace, you'll launch the zkValidium on your local machine and ensure all services are running properly. |
54 | | -3. [<ins>Test the Validium</ins>](#step-3-test-the-validium): With your local CDK Validium running, you'll verify its functionalities, including testing block explorers and making transactions. |
55 | | -4. [<ins>Test the Bridge</ins>](#step-4-test-the-bridge): In this section, you will test using the native bridges to transfer assets between the L1 and L2. |
56 | | - |
57 | | -## Step 1: Download Configuration Files |
58 | | - |
59 | | -The first step involves downloading the necessary configuration files from our repository. Run the following commands in your terminal to clone the repository and navigate into it: |
| 24 | +Run the following commands: |
60 | 25 |
|
61 | 26 | ```bash |
62 | 27 | git clone https://github.com/Snapchain/zkValidium-quickstart.git |
63 | 28 | cd zkValidium-quickstart |
64 | 29 | ``` |
65 | 30 |
|
66 | | -Create the `.env` file by copying from the example: |
| 31 | +Create the `.env` file by copying the example: |
67 | 32 | ```bash |
68 | 33 | cp .env.example .env |
69 | 34 | ``` |
70 | 35 |
|
71 | | -The repository includes these key files: |
72 | | - |
73 | | -- `Docker-compose.yml`: This Docker Compose file defines all the necessary containers to set up the CDK Validium. |
74 | | -- `Makefile`: This file includes a series of commands that will help you manage your CDK Validium node. |
75 | | -- `config`: This folder contains configuration files required for the CDK Validium. |
76 | | - |
77 | | -## Step 2: Launch the Validium Locally |
| 36 | +## 2. Launch validium locally |
78 | 37 |
|
79 | | -With the repository cloned and your working directory set, let's start up the CDK Validium. First, you'll need to pull the necessary Docker images from Docker Hub: |
| 38 | +2.1 Pull the required Docker images from Docker Hub: |
80 | 39 |
|
81 | 40 | ```bash |
82 | | -docker-compose pull |
| 41 | +sudo docker-compose pull |
83 | 42 | ``` |
84 | 43 |
|
85 | | -After pulling the images, you can start your local CDK Validium: |
| 44 | +2.2 After pulling the images, start your local CDK Validium: |
86 | 45 |
|
87 | 46 | ```bash |
88 | | -make run |
| 47 | +sudo make run |
89 | 48 | ``` |
90 | 49 |
|
91 | | -To ensure all services are running properly, check the status of each container: |
| 50 | +2.3 To ensure all services are running properly, check the status of each container: |
92 | 51 |
|
93 | 52 | ```bash |
94 | 53 | docker-compose ps |
95 | 54 | ``` |
96 | 55 |
|
97 | | -You will see results similar to the following: |
| 56 | +You should see the following output: |
98 | 57 |
|
99 | 58 | <details> |
100 | 59 | <summary>Container status details ↓</summary> |
@@ -139,156 +98,154 @@ zkevm-bridge-ui /bin/sh /app/scripts/deploy.sh Up |
139 | 98 | ``` |
140 | 99 | </details> |
141 | 100 |
|
142 | | -If any service isn't running (i.e., in Exit 1 state), you can investigate further using the logs: |
| 101 | +2.3.1 If a service isn't running (i.e. it is in Exit 1 state), investigate further using the logs: |
143 | 102 |
|
144 | 103 | ```bash |
145 | | -docker-compose logs <container_name> |
| 104 | +sudo docker-compose logs <container_name> |
146 | 105 | ``` |
147 | 106 |
|
148 | | -Note: `<container_name>` can be found in results above. |
| 107 | +!!! info |
| 108 | + Find the `<container_name>` in the log output. |
149 | 109 |
|
| 110 | +2.4 Useful commands |
150 | 111 |
|
151 | | -To stop the zkValidium, use: |
| 112 | +To stop CDK validium, use: |
152 | 113 |
|
153 | 114 | ```bash |
154 | | -make stop |
| 115 | +sudo make stop |
155 | 116 | ``` |
156 | 117 |
|
157 | | -And to restart all the services: |
| 118 | +To restart all services: |
158 | 119 |
|
159 | 120 | ```bash |
160 | | -make restart |
| 121 | +sudo make restart |
161 | 122 | ``` |
162 | 123 |
|
163 | | -## Step 3: Test the Validium |
| 124 | +## 3. Test validium |
164 | 125 |
|
165 | | -Congratulations! Your local zkValidium is now up and running. Let's test its functionalities. |
| 126 | +3.1 Verify the block explorer is running by navigating to [localhost:4001](http://localhost:4001/). |
166 | 127 |
|
167 | | -First, verify the block explorer by navigating to [localhost:4001](http://localhost:4001/). You should see a page similar to this: |
| 128 | +You should see a page similar to this: |
168 | 129 |
|
169 | 130 | <div align="center"> |
170 | 131 | <img src="/img/cdk/cdk-block-explorer-empty.png" alt="bridge" width="90%" height="30%" /> |
171 | 132 | </div> |
172 | 133 |
|
173 | | -<br/> |
| 134 | +### 4. Add the network to a Web3 wallet |
174 | 135 |
|
175 | | -Now, let's add the network to your Web3 wallet by populating the necessary fields. |
176 | | -> **We'll use MetaMask for our example.** |
| 136 | +4.1 Follow MetaMask's instructions on [how to set up a network manually](https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC). |
177 | 137 |
|
178 | | -- Set the chain ID to be **1001**. |
| 138 | +- Set the chain ID to **1001**. |
179 | 139 | - The currency symbol can be anything but we will use **POL** by default. |
180 | 140 | - The RPC node and block explorer containers can be found at ports **8123** and **4001**, respectively. |
181 | 141 |
|
182 | 142 | <div align="center"> |
183 | 143 | <img src="/img/cdk/cdk-metamask-add-network.png" alt="bridge" width="90%" height="30%" /> |
184 | 144 | </div> |
185 | 145 |
|
186 | | -Next, switch to the new network: |
| 146 | +4.2 Switch to the new network: |
187 | 147 |
|
188 | 148 | <div align="center"> |
189 | 149 | <img src="/img/cdk/cdk-metamask-switch-network.png" alt="bridge" width="90%" height="30%" /> |
190 | 150 | </div> |
191 | 151 |
|
192 | | -By default, an account with private key `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80` has been preloaded with tokens. |
193 | | - |
194 | | -:::caution NEVER transfer real assets to the address associated with the above private key |
195 | | -::: |
| 152 | +!!! danger "Important" |
| 153 | + - An account with test funds is available with private key `0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80`. |
| 154 | + - NEVER transfer real assets to the address associated with this private key. |
196 | 155 |
|
197 | | -Import this account and you will see the balance shown up as 100000 POL: |
| 156 | +4.3 [Import the account to MetaMask](https://support.metamask.io/hc/en-us/articles/360015489331-How-to-import-an-account). The balance shows up as 100000 POL: |
198 | 157 |
|
199 | 158 | <div align="center"> |
200 | 159 | <img src="/img/cdk/cdk-metamask-import-account.png" alt="bridge" width="90%" height="30%" /> |
201 | 160 | </div> |
202 | 161 |
|
203 | | -You can now try a transaction by transferring some tokens to another account: |
| 162 | +4.4 Transfer some tokens to another account: |
204 | 163 |
|
205 | 164 | <div align="center"> |
206 | 165 | <img src="/img/cdk/cdk-metamask-transfer.gif" alt="bridge" width="90%" height="30%" /> |
207 | 166 | </div> |
208 | 167 |
|
209 | | -After confirming the transaction, check the updated balances: |
| 168 | +4.5 After confirming the transaction, check the updated balances: |
210 | 169 |
|
211 | 170 | <div align="center"> |
212 | 171 | <img src="/img/cdk/cdk-metamask-transfer-result.gif" alt="bridge" width="90%" height="30%" /> |
213 | 172 | </div> |
214 | 173 |
|
215 | | -You can also view the transaction details in the block explorer by clicking on the transaction details in MetaMask: |
| 174 | +4.6 You can also view the transaction details in the block explorer by clicking on the transaction details in MetaMask: |
216 | 175 |
|
217 | 176 | <div align="center"> |
218 | 177 | <img src="/img/cdk/cdk-tx-view-on-block-explorer.png" alt="bridge" width="90%" height="30%" /> |
219 | 178 | </div> |
220 | 179 |
|
221 | | -## Step 4: Test the bridge |
| 180 | +## 5. Test the bridge |
222 | 181 |
|
223 | | -The CDK stack comes with a native bridge with UI to allow you to transfer fund between the L1 and the L2 validium. |
| 182 | +CDK has a native bridge with UI that allows you to transfer funds between the L1 and the L2 validium. |
224 | 183 |
|
225 | | -In this section, you will learn how to bridge fund from the L1 to the validium L2 and then bridge it back from the validium to the L1. |
| 184 | +### L1 to L2 |
226 | 185 |
|
227 | | -Before you can bridge any fund from the L1 to the validium L2, you also need to add the L1 RPC to MetaMask similar to what you have done in previous steps: |
| 186 | +5.1 Add the L1 RPC to MetaMask: |
228 | 187 |
|
229 | 188 | <div align="center"> |
230 | 189 | <img src="/img/cdk/cdk-metamask-add-l1.png" alt="bridge" width="90%" height="30%" /> |
231 | 190 | </div> |
232 | 191 |
|
233 | | -<br/> |
| 192 | +5.2 Switch to the L1 network and you will see the previously imported account with ~999 POL on the L1 chain. |
234 | 193 |
|
235 | | -Switch to the L1 network and you will see the previously imported account already with ~999 POL on the L1 chain. |
| 194 | +5.3 Verify the bridge UI by navigating to [localhost:8088](http://localhost:8088/). |
236 | 195 |
|
237 | | -First, verify the bridge UI by navigating to [localhost:8088](http://localhost:8088/). You should see a page similar to this and click on "Connect a wallet > MetaMask": |
| 196 | +5.4 Click on **Connect a wallet > MetaMask**. |
238 | 197 |
|
239 | 198 | <div align="center"> |
240 | 199 | <img src="/img/cdk/cdk-bridge.png" alt="bridge" width="90%" height="30%" /> |
241 | 200 | </div> |
242 | 201 |
|
243 | | -<br/> |
244 | | - |
245 | | -Select the previously imported account (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) to connect and once you are connected, you should see a page like this: |
| 202 | +5.5 Select the previously imported account (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266). Once you are connected, you should see a page like this: |
246 | 203 |
|
247 | 204 | <div align="center"> |
248 | 205 | <img src="/img/cdk/cdk-bridge-connected.png" alt="bridge" width="90%" height="30%" /> |
249 | 206 | </div> |
250 | 207 |
|
251 | | -<br/> |
| 208 | +5.6 Enter the amount (e.g. 5) to bridge and click **Continue**, you will see the **Confirm Bridge** page. |
252 | 209 |
|
253 | | -Enter the amount (e.g. 5) to bridge and click "Continue", you will see the "Confirm Bridge" page. Click "Bridge" and approve the transaction on the MetaMask pop-up: |
| 210 | +5.7 Click **Bridge** and approve the transaction on the MetaMask pop-up: |
254 | 211 |
|
255 | 212 | <div align="center"> |
256 | 213 | <img src="/img/cdk/cdk-bridge-confirm.png" alt="bridge" width="90%" height="30%" /> |
257 | 214 | </div> |
258 | 215 |
|
259 | | -<br/> |
260 | | - |
261 | | -Once the bridging is completed, you should see the "Activity" page like this: |
| 216 | +5.8 Once bridging is complete, you should see the **Activity** page: |
262 | 217 |
|
263 | 218 | <div align="center"> |
264 | 219 | <img src="/img/cdk/cdk-bridge-completed-l1-to-l2.png" alt="bridge" width="90%" height="30%" /> |
265 | 220 | </div> |
266 | 221 |
|
267 | | -<br/> |
| 222 | +### L2 to L1 |
| 223 | + |
| 224 | +5.9 Switch network on MetaMask to your validium chain and navigate back to [localhost:8088](http://localhost:8088/). |
268 | 225 |
|
269 | | -Now let's bridge back the fund from the validium L2 to the L1 chain. Switch network on MetaMask to your validium chain and navigate back to [localhost:8088](http://localhost:8088/). You should see both the updated L1 and L2 balances: |
| 226 | +5.10 You should see both the updated L1 and L2 balances: |
270 | 227 |
|
271 | 228 | <div align="center"> |
272 | 229 | <img src="/img/cdk/cdk-bridge-l2-to-l1.png" alt="bridge" width="90%" height="30%" /> |
273 | 230 | </div> |
274 | | -<br/> |
275 | 231 |
|
276 | | -Enter an amount (e.g. 1) and follow the same process to bridge the fund back to the L1. |
| 232 | +5.11 Enter an amount and follow the same process to bridge the fund back to the L1. |
277 | 233 |
|
278 | | -:::caution Note |
279 | | -You cannot bridge back fund more than what you have previously bridged from L1 to the L2. |
280 | | -::: |
| 234 | +!!! note |
| 235 | + You cannot bridge back fund more than what you have previously bridged from L1 to the L2. |
281 | 236 |
|
282 | | -The L2->L1 bridging is slightly different than L1->L2 and you will see the "Activity" page like this after the transaction is executed: |
| 237 | +The L2->L1 bridging is slightly different than L1->L2 and you will see the **Activity** page like this after the transaction is executed: |
283 | 238 |
|
284 | 239 | <div align="center"> |
285 | 240 | <img src="/img/cdk/cdk-bridge-l2-to-l1-on-hold.png" alt="bridge" width="90%" height="30%" /> |
286 | 241 | </div> |
287 | | -<br/> |
288 | 242 |
|
289 | | - Click "Finalise" and approve the transaction (Note: MetaMask will pop up a window to ask you to switch to the L1 network first). Then you will see this once the bridging is completed: |
| 243 | +5.12 Click **Finalise** and approve the transaction (Note: MetaMask will pop up a window to ask you to switch to the L1 network first). Then you will see this once the bridging is completed: |
290 | 244 |
|
291 | 245 | <div align="center"> |
292 | 246 | <img src="/img/cdk/cdk-bridge-l2-to-l1-completed.png" alt="bridge" width="90%" height="30%" /> |
293 | 247 | </div> |
294 | | -<br/> |
| 248 | + |
| 249 | +!!! urgent |
| 250 | + - First time, I had an error on step 5.12 -> cannot estimate gas. |
| 251 | + - Second time, I had an error much earlier on, but that's probably because I didn't clear the images up, even though I restarted. |
0 commit comments