diff --git a/doc-drafts/bridge-manual-claim.sh b/doc-drafts/bridge-manual-claim.sh deleted file mode 100755 index dce65d97e..000000000 --- a/doc-drafts/bridge-manual-claim.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash -set -e - -# Setup some vars for use later on -# The private key used to send transactions -private_key="0903a9a721167e2abaa0a33553cbeb209dc9300d28e4e4d6d2fac2452f93e357" -# The destination network (zero corresponds to L1/Ethereum) -destination_net="0" -# The address of the recipient -destination_addr="0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6" -# The bridge address -bridge_addr="$(kurtosis service exec cdk-v1 contracts-001 "cat /opt/zkevm/combined.json" | tail -n +2 | jq -r .polygonZkEVMBridgeAddress)" - -# Grab the endpoints for l1 and the bridge service -l1_rpc_url=http://$(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc) -bridge_api_url="$(kurtosis port print cdk-v1 zkevm-bridge-service-001 bridge-rpc)" - -# The signature for claiming is long - just putting it into a var -claim_sig="claimAsset(bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes)" - -# Get the list of deposits for the destination address -echo "Getting the list of deposits..." -curl -s "$bridge_api_url/bridges/$destination_addr?limit=100&offset=0" | jq > bridge-deposits.json -cat bridge-deposits.json - -# Filter the list of deposits down to the claimable txs that hasn't already been claimed and are destined for L1 -echo "Filtering the list of deposits..." -jq '[.deposits[] | select(.ready_for_claim == true and .claim_tx_hash == "" and .dest_net == '$destination_net')]' bridge-deposits.json > claimable-txs.json -cat claimable-txs.json - -# Process all the claimable txs -jq -c '.[]' claimable-txs.json | while IFS= read -r tx; do - echo "Processing claimable tx..." - echo "$tx" - - # Use the bridge service to get the merkle proof of our deposit - echo "Getting the merkle proof of our deposit..." - curr_deposit_cnt="$(echo "$tx" | jq -r '.deposit_cnt')" - curr_network_id="$(echo "$tx" | jq -r '.network_id')" - curl -s "$bridge_api_url/merkle-proof?deposit_cnt=$curr_deposit_cnt&net_id=$curr_network_id" | jq '.' > proof.json - cat proof.json - - # Get our variables organized - in_merkle_proof="$(jq -r -c '.proof.merkle_proof' proof.json | tr -d '"')" - in_rollup_merkle_proof="$(jq -r -c '.proof.rollup_merkle_proof' proof.json | tr -d '"')" - in_global_index="$(echo "$tx" | jq -r '.global_index')" - in_main_exit_root="$(jq -r '.proof.main_exit_root' proof.json)" - in_rollup_exit_root="$(jq -r '.proof.rollup_exit_root' proof.json)" - in_orig_net="$(echo "$tx" | jq -r '.orig_net')" - in_orig_addr="$(echo "$tx" | jq -r '.orig_addr')" - in_dest_net="$(echo "$tx" | jq -r '.dest_net')" - in_dest_addr="$(echo "$tx" | jq -r '.dest_addr')" - in_amount="$(echo "$tx" | jq -r '.amount')" - in_metadata="$(echo "$tx" | jq -r '.metadata')" - - # Generate the call data, this is useful just to examine what the call will look loke - echo "Generating the call data for the bridge claim tx..." - cast calldata "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" "$in_global_index" "$in_main_exit_root" "$in_rollup_exit_root" "$in_orig_net" "$in_orig_addr" "$in_dest_net" "$in_dest_addr" "$in_amount" "$in_metadata" - - # Perform an eth_call to make sure the tx will work - echo "Performing an eth call to make sure the bridge claim tx will work..." - cast call --rpc-url "$l1_rpc_url" "$bridge_addr" "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" "$in_global_index" "$in_main_exit_root" "$in_rollup_exit_root" "$in_orig_net" "$in_orig_addr" "$in_dest_net" "$in_dest_addr" "$in_amount" "$in_metadata" - - # Publish the actual transaction! - echo "Publishing the bridge claim tx..." - cast send --rpc-url "$l1_rpc_url" --private-key "$private_key" "$bridge_addr" "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" "$in_global_index" "$in_main_exit_root" "$in_rollup_exit_root" "$in_orig_net" "$in_orig_addr" "$in_dest_net" "$in_dest_addr" "$in_amount" "$in_metadata" -done diff --git a/doc-drafts/gas-token-img/13_bridge.png b/doc-drafts/gas-token-img/13_bridge.png deleted file mode 100644 index e42ebd257..000000000 Binary files a/doc-drafts/gas-token-img/13_bridge.png and /dev/null differ diff --git a/doc-drafts/gas-token.org b/doc-drafts/gas-token.org deleted file mode 100644 index bb13bd606..000000000 --- a/doc-drafts/gas-token.org +++ /dev/null @@ -1,199 +0,0 @@ -* Gas Token Setup - -Let's walk through how you can use this package to test a CDK that -uses a gas token. There is a lot of detailed information about this -architecture in the [[https://github.com/0xPolygonHermez/zkevm-techdocs/blob/a6d46da98ad32ace544e5dbc31d34831f9cc1bdd/knowledge-layer/architecture/PDFs/ulxly.pdf][knowledge layer docs]]. The following section from -the docs is a helpful explanation of the Gas Token: - -#+begin_quote -When a token is utilized to cover gas expenses within a layer, we refer to it as the gas token for that specific layer. - -Even when employing a gas token within a layer, it remains feasible to transfer L1 ETH to that layer. In such instances, the ETH is recorded within an ERC20 contract known as W-ETH, functioning as another instance of an ERC20 token. -#+end_quote - -#+CAPTION: Diagram illustrating the interchange of assets between layers, focusing on LY as a layer of interest. It depicts several scenarios, such as bridging a ERC20 token from mainnet to another ERC20 token in LY, bridging L1 ETH to the LY gas token or bridging a wrapped ERC20 token living on LX to LY ETH. -[[file:gas-token-img/ulxly-exchanges.drawio.png]] - -In order to try the gas token out in your local environment, first -edit the [[../params.yml][params.yml]] file to set ~zkevm_use_gas_token_contract~ as -~true~. When you make this change a few things will happen during -setup: - -1. During contract deployment, an ERC20 token will be deployed on L1. -2. The [[../templates/contract-deploy/create_rollup_parameters.json][rollup creation parameters]] will be modified to set the - ~gasTokenAddress~ to the address of the L1 ERC20. - -After setting the ~zkevm_use_gas_token_contract~, you should be all -set to run Kurtosis. - -#+begin_src bash -kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . -#+end_src - -This will take a few minutes as the full set of contracts will be -compiled and deployed. When this is finished you should see the full -set of services that were deployed. - -[[file:gas-token-img/services.png]] - -For the rest of this guide you'll probably only be interested in three -of these mapped services: the bridge UI, the L1 RPC, and the L2 RPC. - -To get started let's extract the generated files and take a look at -the ~gasTokenAddress~: - -#+begin_src bash -kurtosis service exec cdk-v1 contracts-001 "cat /opt/zkevm/create_rollup_parameters.json" -#+end_src - -Running this command will give us the address of our ERC20 token. In -order to bridge, we should mint some of this token. To run this command, -you'll also need to have the [[https://book.getfoundry.sh/getting-started/installation][Foundry toolchain]] -installed (note: you'll need to have [[https://jqlang.github.io/jq/][jq]] and [[https://github.com/mikefarah/yq/#install][yq]] installed): - -#+begin_src bash -export gta=$(kurtosis service exec cdk-v1 contracts-001 "cat /opt/zkevm/create_rollup_parameters.json" | tail -n +2 | jq -r .gasTokenAddress) -export l1_rpc_url=http://$(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc) -cast send \ - --mnemonic "code code code code code code code code code code code quality" \ - --rpc-url "$l1_rpc_url" \ - "$gta" \ - "mint(address,uint256)" \ - 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6 \ - 1000000000000000000000000000 -#+end_src - -Assuming that worked we can check our token balance as well: -#+begin_src bash -cast call --rpc-url "$l1_rpc_url" "$gta" "balanceOf(address)(uint256)" 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6 -#+end_src - -Now that we have some L1 Gas Token, let's open up the bridge -UI. You'll need to open your browser to the address of of the bridge -UI service. Run this command to get the URL easily and then open the -URL in your browser. Please be aware that running the CDK setup on a -Mac might result in issues, such as encountering a blank bridge UI. -To resolve this problem, refer to the troubleshooting section in the -main README. - -#+begin_src bash -kurtosis port print cdk-v1 zkevm-bridge-ui-001 bridge-ui -#+end_src - -You'll need to need to add RPCs for L1 and L2 to your browser -wallet. Because the URLs are using HTTP instead of HTTPS, you'll need -to [[https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC][add the RPCs]] manually to Metamask. - -The config for the L1 RPC can be retrieved with this command: - -#+begin_src bash -echo \{\"network_name\": \"kurtosis_cdk_l1\", \"new_rpc_url\": \"$l1_rpc_url\", \"chain_id\": $(yq .l1_chain_id params.yml), \"currency_symbol\": \"ETH\"\} | jq -#+end_src - -Same thing for the L2 RPC config: - -#+begin_src bash -echo \{\"network_name\": \"kurtosis_cdk_rollup\", \"new_rpc_url\": \"$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)\", \"chain_id\": $(yq .zkevm_rollup_chain_id params.yml), \"currency_symbol\": \"CDK\"\} | jq -#+end_src - -Additionally, if you used the mnemonic ~code...quality~, you'll also -want to [[https://support.metamask.io/hc/en-us/articles/360015489331-How-to-import-an-account#h_01G01W07NV7Q94M7P1EBD5BYM4][import an account]] using a private key. The first derived -private key from the ~code...quality~ mnemonic is -~42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa~. - -Now we'll need to add the gas token to the bridge interface and -attempt to bridge. First, you'll need to click the token dropdown -menu: - -[[file:gas-token-img/01_bridge.png]] - -In the modal, you'll want to paste the ERC 20 Gas Token address that -we found earlier with this command: - -#+begin_src bash -echo "$gta" -#+end_src - -In my case, it's ~0xBDF337Ae0209B33285034c476f35733BFC890707~ - -[[file:gas-token-img/02_bridge.png]] - -Confirm the details of your token and then click the add button. - -[[file:gas-token-img/03_bridge.png]] - -Now that the token has been added, you'll need to select the token for -bridging. - -[[file:gas-token-img/04_bridge.png]] - -At this point you should be all set to actually make the bridge - -[[file:gas-token-img/05_bridge.png]] - -Now your bridge deposit should be pending. -[[file:gas-token-img/06_bridge.png]] - -After some time, your transaction should show as claimed. If it -doesn't, it's possible the autoclaiming service on L2 is not -funded. You should be able to send it some ether on L2 by running a -command like this: - -#+begin_src bash -cast send --legacy \ - --value 10ether \ - --private-key 0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ - --rpc-url "$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)" \ - "$(yq -r .zkevm_l2_claimtxmanager_address params.yml)" -#+end_src - -[[file:gas-token-img/07_bridge.png]] - -At this point if you switch Metamask to your L2 network, you should -see the bridge value as native value on L2. - -[[file:gas-token-img/08_bridge.png]] - -To complete the test here, lets transfer some of the value on L2 to -another address. In my case, I'll send some value to this address -~0x125fb391ba829e0865963d3b91711610049a9e78~: - -[[file:gas-token-img/09_bridge.png]] - -After importing the private key -~0903a9a721167e2abaa0a33553cbeb209dc9300d28e4e4d6d2fac2452f93e357~ for -this account, I can see the balance in metamask. - -[[file:gas-token-img/10_bridge.png]] - -Now let's try to withdraw it! After initiating the withdraw -transaction, we'll have to wait for our tx's data to be proven on L1. - -[[file:gas-token-img/11_bridge.png]] - -As of 2024-03-27, there might be a small bug in the bridge UI which -causes the transaction not to be claimable on L1 with the -UI. Essentially the bridge UI is selecting the wrong destination -network so the proof will not validate. That being said, it's possible -to claim directly using the smart contracts. - -[[file:gas-token-img/12_bridge.png]] - -We'll put together a more comprehensive script later, but if you -wanted to see how to use ~cast~ and the bridge service to do a bridge -claim, it would look something like this. If you want to run this -yourself, I'd recommend going line by line and tweaking as needed. - -#+begin_src bash -./docs/bridge-manual-claim.sh -#+end_src - -This worked! - -[[file:gas-token-img/14_bridge.png]] - -Now we can confirm the claim went through using Metamask and the -bridge UI. Even though the bridge UI didn't allow me to claim, it does -correctly show that a claim was executed! - -[[file:gas-token-img/15_bridge.png]] diff --git a/docs/how-to/use-native-token.md b/docs/how-to/use-native-token.md new file mode 100644 index 000000000..b90f849fc --- /dev/null +++ b/docs/how-to/use-native-token.md @@ -0,0 +1,269 @@ +This document show you how you to set up and test a native token in a CDK stack. + +## Summary + +!!! quote "From the [Unified bridge documentation](https://github.com/0xPolygonHermez/zkevm-techdocs/blob/a6d46da98ad32ace544e5dbc31d34831f9cc1bdd/knowledge-layer/architecture/PDFs/ulxly.pdf)" + When a token is utilized to cover gas expenses within a layer, we refer to it as the gas token for that specific layer. + + Even when employing a gas token within a layer, it remains feasible to transfer L1 ETH to that layer. In such instances, the ETH is recorded within an ERC20 contract known as W-ETH, functioning as another instance of an ERC20 token. + +The diagram below illustrates the interchange of assets between layers, focusing on LY as a layer of interest. + +It depicts several scenarios, such as bridging an ERC20 token from mainnet to another ERC20 token in LY, bridging L1 ETH to the LY gas token, or bridging a wrapped ERC20 token living on LX to LY ETH. + +![Unfied bridge exchanges](../img/how-to/gas-token-img/ulxly-exchanges.drawio.png) + +## Set up and prerequisites + +1. Edit the [params.yml](https://github.com/0xPolygon/kurtosis-cdk/blob/main/params.yml) file to set `zkevm_use_gas_token_contract` to `true`. This forces a couple of changes at setup time: + + 1. During contract deployment, an ERC20 token is deployed on L1. + 2. The [rollup creation parameters](https://github.com/0xPolygon/kurtosis-cdk/blob/main/templates/contract-deploy/create_rollup_parameters.json) file is modified to set the `gasTokenAddress` to the address of the L1 ERC20. + +2. You can now run the stack: + + ```sh + kurtosis run --enclave cdk-v1 --args-file params.yml --image-download always . + ``` + + !!! tip + For full set up and deploy instructions, check out the [quickstart](../quickstart/deploy-stack.md) documentation. + + It takes a few minutes to compile and deploy the full set of contracts. + + The screenshot below shows the full set of deployed services and highlights the bridge UI, L1 RPC, and L2 RPC services which we will focus on throughout this document. + + ![Deployed services](../img/how-to/gas-token-img/services.png) + +### Mint L1 token + +!!! tip + For this section you will need to have [Foundry](https://book.getfoundry.sh/getting-started/installation), [jq](https://jqlang.github.io/jq/), and [yq](https://github.com/mikefarah/yq/#install) installed. + +1. Extract the `gasTokenAddress` from the generated files: + + ```sh + kurtosis service exec cdk-v1 contracts-001 "cat /opt/zkevm/create_rollup_parameters.json" + ``` + +2. Run the following command to mint some L1 tokens. + + ```sh + export gta=$(kurtosis service exec cdk-v1 contracts-001 "cat /opt/zkevm/create_rollup_parameters.json" | tail -n +2 | jq -r .gasTokenAddress) + export l1_rpc_url=http://$(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc) + cast send \ + --mnemonic "code code code code code code code code code code code quality" \ + --rpc-url "$l1_rpc_url" \ + "$gta" \ + "mint(address,uint256)" \ + 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6 \ + 1000000000000000000000000000 + ``` + +3. Check the balance to make sure it worked. + + ```sh + cast call --rpc-url "$l1_rpc_url" "$gta" "balanceOf(address)(uint256)" 0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6 + ``` + +### Open the bridge UI + +Run the following command to get the bridge UI URL and then open the URL in your browser. + +```sh +kurtosis port print cdk-v1 zkevm-bridge-ui-001 bridge-ui +``` + +### Add L1 and L2 RPCs to your wallet + +As the URLs use HTTP, instead of HTTPS, you need to [manually add them to MetaMask](https://support.metamask.io/hc/en-us/articles/360043227612-How-to-add-a-custom-network-RPC). + +1. Retrieve the L1 RPC config by running the following command: + + ```sh + echo \{\"network_name\": \"kurtosis_cdk_l1\", \"new_rpc_url\": \"$l1_rpc_url\", \"chain_id\": $(yq .l1_chain_id params.yml), \"currency_symbol\": \"ETH\"\} | jq + ``` + +2. Do the same for L2: + + ```sh + echo \{\"network_name\": \"kurtosis_cdk_rollup\", \"new_rpc_url\": \"$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)\", \"chain_id\": $(yq .zkevm_rollup_chain_id params.yml), \"currency_symbol\": \"CDK\"\} | jq + ``` + +### Import an account + +If you used the [pre-allocated mnemonic](https://github.com/0xPolygon/kurtosis-cdk/blob/be17ee3ec3b67d086a0155f3deab5ad009034c8b/params.yml#L147), you need to [import an account](https://support.metamask.io/hc/en-us/articles/360015489331-How-to-import-an-account#h_01G01W07NV7Q94M7P1EBD5BYM4) using a private key. + +The first derived private key from the `code...quality` mnemonic is +`42b6e34dc21598a807dc19d7784c71b2a7a01f6480dc6f58258f78e539f1a1fa`. + +## Bridging tokens + +### Add token + +1. On the bridge UI, click the token dropdown menu: + + ![Token dropdown menu](../img/how-to/gas-token-img/01_bridge.png) + +2. Get the ERC20 gas token address from earlier and paste it in with: + + ```sh + echo "$gta" + ``` + + In my case, the gas token address is `0xBDF337Ae0209B33285034c476f35733BFC890707`. + + ![Paste token in](../img/how-to/gas-token-img/02_bridge.png) + +3. Confirm the details and click the **Add CDK Gas Token** button. + + ![Paste token in](../img/how-to/gas-token-img/03_bridge.png) + +### Bridge tokens + +1. Select the token for bridging. + + ![Select token for bridging](../img/how-to/gas-token-img/04_bridge.png) + +2. Add a value to bridge and click **Continue**. + + ![Bridging details](../img/how-to/gas-token-img/05_bridge.png) + +3. Your bridge deposit should be pending. + + ![Token bridging processing](../img/how-to/gas-token-img/06_bridge.png) + +4. After some time, the transaction should complete. + + ![Bridging complete](../img/how-to/gas-token-img/07_bridge.png) + + !!! tip + If that doesn't happen, it's possible the auto-claiming service on L2 is not funded. Send it some Ether on L2 by running a command like this: + + ```sh + cast send --legacy \ + --value 10ether \ + --private-key 0x12d7de8621a77640c9241b2595ba78ce443d05e94090365ab3bb5e19df82c625 \ + --rpc-url "$(kurtosis port print cdk-v1 zkevm-node-rpc-001 http-rpc)" \ + "$(yq -r .zkevm_l2_claimtxmanager_address params.yml)" + ``` + +5. Switch to your L2 network on Metamask to see the bridged value on L2. + + ![Check bridge success on L2 in MetaMask](../img/how-to/gas-token-img/07_bridge.png) + +### Transfer token + +1. To complete the test, lets transfer some of the value on L2 to another address. + + ![Transfer to another L2 address](../img/how-to/gas-token-img/07_bridge.png) + +2. Check the balance in MetaMask after importing the private key `0903a9a721167e2abaa0a33553cbeb209dc9300d28e4e4d6d2fac2452f93e357`. + + ![Balance of receiving account](../img/how-to/gas-token-img/07_bridge.png) + +### Withdraw the token + +1. After initiating a withdraw transaction, wait for the transaction data to be proven on L1. + + ![Balance of receiving account](../img/how-to/gas-token-img/11_bridge.png) + + !!! warning + - As of 2024-03-27, there might be a small bug in the bridge UI which causes the transaction not to be claimable on L1 with the UI. + - Essentially the bridge UI is selecting the wrong destination network so the proof will not validate. + - That being said, it's possible to claim directly using the smart contracts. + +2. Click **Finalize**. + + ![Balance of receiving account](../img/how-to/gas-token-img/12_bridge.png) + +## Using cast to do a bridge claim + +The following work-in-progress cast script processes a bridge claim. Feel free to go through line-by-line and tweak where necessary. + +```sh +#!/bin/bash +set -e + +# Setup some vars for use later on +# The private key used to send transactions +private_key="0903a9a721167e2abaa0a33553cbeb209dc9300d28e4e4d6d2fac2452f93e357" +# The destination network (zero corresponds to L1/Ethereum) +destination_net="0" +# The address of the recipient +destination_addr="0x85dA99c8a7C2C95964c8EfD687E95E632Fc533D6" +# The bridge address +bridge_addr="$(kurtosis service exec cdk-v1 contracts-001 "cat /opt/zkevm/combined.json" | tail -n +2 | jq -r .polygonZkEVMBridgeAddress)" + +# Grab the endpoints for l1 and the bridge service +l1_rpc_url=http://$(kurtosis port print cdk-v1 el-1-geth-lighthouse rpc) +bridge_api_url="$(kurtosis port print cdk-v1 zkevm-bridge-service-001 bridge-rpc)" + +# The signature for claiming is long - just putting it into a var +claim_sig="claimAsset(bytes32[32],bytes32[32],uint256,bytes32,bytes32,uint32,address,uint32,address,uint256,bytes)" + +# Get the list of deposits for the destination address +echo "Getting the list of deposits..." +curl -s "$bridge_api_url/bridges/$destination_addr?limit=100&offset=0" | jq > bridge-deposits.json +cat bridge-deposits.json + +# Filter the list of deposits down to the claimable txs that hasn't already been claimed and are destined for L1 +echo "Filtering the list of deposits..." +jq '[.deposits[] | select(.ready_for_claim == true and .claim_tx_hash == "" and .dest_net == '$destination_net')]' bridge-deposits.json > claimable-txs.json +cat claimable-txs.json + +# Process all the claimable txs +jq -c '.[]' claimable-txs.json | while IFS= read -r tx; do + echo "Processing claimable tx..." + echo "$tx" + + # Use the bridge service to get the merkle proof of our deposit + echo "Getting the merkle proof of our deposit..." + curr_deposit_cnt="$(echo "$tx" | jq -r '.deposit_cnt')" + curr_network_id="$(echo "$tx" | jq -r '.network_id')" + curl -s "$bridge_api_url/merkle-proof?deposit_cnt=$curr_deposit_cnt&net_id=$curr_network_id" | jq '.' > proof.json + cat proof.json + + # Get our variables organized + in_merkle_proof="$(jq -r -c '.proof.merkle_proof' proof.json | tr -d '"')" + in_rollup_merkle_proof="$(jq -r -c '.proof.rollup_merkle_proof' proof.json | tr -d '"')" + in_global_index="$(echo "$tx" | jq -r '.global_index')" + in_main_exit_root="$(jq -r '.proof.main_exit_root' proof.json)" + in_rollup_exit_root="$(jq -r '.proof.rollup_exit_root' proof.json)" + in_orig_net="$(echo "$tx" | jq -r '.orig_net')" + in_orig_addr="$(echo "$tx" | jq -r '.orig_addr')" + in_dest_net="$(echo "$tx" | jq -r '.dest_net')" + in_dest_addr="$(echo "$tx" | jq -r '.dest_addr')" + in_amount="$(echo "$tx" | jq -r '.amount')" + in_metadata="$(echo "$tx" | jq -r '.metadata')" + + # Generate the call data, this is useful just to examine what the call will look loke + echo "Generating the call data for the bridge claim tx..." + cast calldata "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" "$in_global_index" "$in_main_exit_root" "$in_rollup_exit_root" "$in_orig_net" "$in_orig_addr" "$in_dest_net" "$in_dest_addr" "$in_amount" "$in_metadata" + + # Perform an eth_call to make sure the tx will work + echo "Performing an eth call to make sure the bridge claim tx will work..." + cast call --rpc-url "$l1_rpc_url" "$bridge_addr" "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" "$in_global_index" "$in_main_exit_root" "$in_rollup_exit_root" "$in_orig_net" "$in_orig_addr" "$in_dest_net" "$in_dest_addr" "$in_amount" "$in_metadata" + + # Publish the actual transaction! + echo "Publishing the bridge claim tx..." + cast send --rpc-url "$l1_rpc_url" --private-key "$private_key" "$bridge_addr" "$claim_sig" "$in_merkle_proof" "$in_rollup_merkle_proof" "$in_global_index" "$in_main_exit_root" "$in_rollup_exit_root" "$in_orig_net" "$in_orig_addr" "$in_dest_net" "$in_dest_addr" "$in_amount" "$in_metadata" +done +``` + +Run the script with: + +```sh +./bridge-manual-claim.sh +``` + +You should see something like this: + +![Output from cast bridging script](../img/how-to/gas-token-img/14_bridge.png) + +Confirm the claim went through using MetaMask and the bridge UI. + +![MetaMask confirmation](../img/how-to/gas-token-img/15_bridge.png) + +!!! info + Even though the bridge UI didn't allow me to claim, it does correctly show that a claim was executed. diff --git a/doc-drafts/gas-token-img/01_bridge.png b/docs/img/how-to/gas-token-img/01_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/01_bridge.png rename to docs/img/how-to/gas-token-img/01_bridge.png diff --git a/doc-drafts/gas-token-img/02_bridge.png b/docs/img/how-to/gas-token-img/02_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/02_bridge.png rename to docs/img/how-to/gas-token-img/02_bridge.png diff --git a/doc-drafts/gas-token-img/03_bridge.png b/docs/img/how-to/gas-token-img/03_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/03_bridge.png rename to docs/img/how-to/gas-token-img/03_bridge.png diff --git a/doc-drafts/gas-token-img/04_bridge.png b/docs/img/how-to/gas-token-img/04_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/04_bridge.png rename to docs/img/how-to/gas-token-img/04_bridge.png diff --git a/doc-drafts/gas-token-img/05_bridge.png b/docs/img/how-to/gas-token-img/05_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/05_bridge.png rename to docs/img/how-to/gas-token-img/05_bridge.png diff --git a/doc-drafts/gas-token-img/06_bridge.png b/docs/img/how-to/gas-token-img/06_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/06_bridge.png rename to docs/img/how-to/gas-token-img/06_bridge.png diff --git a/doc-drafts/gas-token-img/07_bridge.png b/docs/img/how-to/gas-token-img/07_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/07_bridge.png rename to docs/img/how-to/gas-token-img/07_bridge.png diff --git a/doc-drafts/gas-token-img/08_bridge.png b/docs/img/how-to/gas-token-img/08_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/08_bridge.png rename to docs/img/how-to/gas-token-img/08_bridge.png diff --git a/doc-drafts/gas-token-img/09_bridge.png b/docs/img/how-to/gas-token-img/09_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/09_bridge.png rename to docs/img/how-to/gas-token-img/09_bridge.png diff --git a/doc-drafts/gas-token-img/10_bridge.png b/docs/img/how-to/gas-token-img/10_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/10_bridge.png rename to docs/img/how-to/gas-token-img/10_bridge.png diff --git a/doc-drafts/gas-token-img/11_bridge.png b/docs/img/how-to/gas-token-img/11_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/11_bridge.png rename to docs/img/how-to/gas-token-img/11_bridge.png diff --git a/doc-drafts/gas-token-img/12_bridge.png b/docs/img/how-to/gas-token-img/12_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/12_bridge.png rename to docs/img/how-to/gas-token-img/12_bridge.png diff --git a/doc-drafts/gas-token-img/14_bridge.png b/docs/img/how-to/gas-token-img/14_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/14_bridge.png rename to docs/img/how-to/gas-token-img/14_bridge.png diff --git a/doc-drafts/gas-token-img/15_bridge.png b/docs/img/how-to/gas-token-img/15_bridge.png similarity index 100% rename from doc-drafts/gas-token-img/15_bridge.png rename to docs/img/how-to/gas-token-img/15_bridge.png diff --git a/doc-drafts/gas-token-img/mm-cdk-l1.png b/docs/img/how-to/gas-token-img/mm-cdk-l1.png similarity index 100% rename from doc-drafts/gas-token-img/mm-cdk-l1.png rename to docs/img/how-to/gas-token-img/mm-cdk-l1.png diff --git a/doc-drafts/gas-token-img/mm-cdk-l2.png b/docs/img/how-to/gas-token-img/mm-cdk-l2.png similarity index 100% rename from doc-drafts/gas-token-img/mm-cdk-l2.png rename to docs/img/how-to/gas-token-img/mm-cdk-l2.png diff --git a/doc-drafts/gas-token-img/services.png b/docs/img/how-to/gas-token-img/services.png similarity index 100% rename from doc-drafts/gas-token-img/services.png rename to docs/img/how-to/gas-token-img/services.png diff --git a/doc-drafts/gas-token-img/ulxly-exchanges.drawio.png b/docs/img/how-to/gas-token-img/ulxly-exchanges.drawio.png similarity index 100% rename from doc-drafts/gas-token-img/ulxly-exchanges.drawio.png rename to docs/img/how-to/gas-token-img/ulxly-exchanges.drawio.png diff --git a/docs/img/monitoring.png b/docs/img/quickstart/monitoring.png similarity index 100% rename from docs/img/monitoring.png rename to docs/img/quickstart/monitoring.png diff --git a/docs/img/panoptician.png b/docs/img/quickstart/panoptician.png similarity index 100% rename from docs/img/panoptician.png rename to docs/img/quickstart/panoptician.png diff --git a/docs/img/prometheus.png b/docs/img/quickstart/prometheus.png similarity index 100% rename from docs/img/prometheus.png rename to docs/img/quickstart/prometheus.png diff --git a/docs/img/services.png b/docs/img/quickstart/services.png similarity index 100% rename from docs/img/services.png rename to docs/img/quickstart/services.png diff --git a/docs/quickstart/observability.md b/docs/quickstart/observability.md index f78c62da1..5abf65881 100644 --- a/docs/quickstart/observability.md +++ b/docs/quickstart/observability.md @@ -20,7 +20,7 @@ To view the dashboards, go to the Grafana endpoint with the `/dashboards` path. Click the hamburger menu in the top left to go to **Dashboards**. -![Monitoring dashboards](../img/monitoring.png) +![Monitoring dashboards](../img/quickstart/monitoring.png) There are two predefined dashboards here to help you understand the health of the CDK at a glance. @@ -28,18 +28,18 @@ There are two predefined dashboards here to help you understand the health of th The Panoptichain dashboard displays the metrics that are collected from the Panoptichain service. This dashboard focuses on on-chain metrics such as blocks, transactions, and smart contract calls. -![Panoptichain dashboard](../img/panoptician.png) +![Panoptichain dashboard](../img/quickstart/panoptician.png) ## Services The services dashboard captures the metrics being emitted by the individual services in the CDK, and metrics pertaining to process health. -![Services dashboard](../img/services.png) +![Services dashboard](../img/quickstart/services.png) ## Prometheus targets To ensure that a service is properly emitting metrics, you can view all the Prometheus targets and their state by navigating to the Prometheus endpoint with the `/targets` path. -![Prometheus targets dashboard](../img/services.png) +![Prometheus targets dashboard](../img/quickstart/services.png)
\ No newline at end of file diff --git a/docs/setup-a-token b/docs/setup-a-token new file mode 100644 index 000000000..e69de29bb diff --git a/mkdocs.yml b/mkdocs.yml index e1ea52913..ffce2aea7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,13 +24,17 @@ theme: nav: - Overview: index.md - - For technical users: - - Deploy the CDK stack: quickstart/deploy-stack.md - - Set up a permissionless node: quickstart/set-up-node.md - - Observability: quickstart/observability.md - - For developers: - - Breakdown the deployment: quickstart/breakdown-deployment.md - - zkEVM contracts caching: quickstart/zkevm-cache-contracts.md + - Getting started: + - For technical users: + - Deploy the CDK stack: quickstart/deploy-stack.md + - Set up a permissionless node: quickstart/set-up-node.md + - Observability: quickstart/observability.md + - For developers: + - Breakdown the deployment: quickstart/breakdown-deployment.md + - zkEVM contracts caching: quickstart/zkevm-cache-contracts.md + - How to: + - Use a native token: how-to/use-native-token.md + markdown_extensions: