diff --git a/docs/overview.md b/docs/overview.md index c4279e3..c3dcdce 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -2,6 +2,7 @@ id: overview title: Dogechain sidebar_label: Overview + --- ## Devnet diff --git a/docs/zkevm/how-to/using-foundry.md b/docs/zkevm/how-to/using-foundry.md new file mode 100644 index 0000000..ebfe6e4 --- /dev/null +++ b/docs/zkevm/how-to/using-foundry.md @@ -0,0 +1,192 @@ +--- +id: using-foundry +title: Deploy a contract with Foundry +--- + +Any smart contract deployable to the Ethereum network can be deployed easily to the Dogechain zkEVM network. In this guide, we will demonstrate how to deploy an ERC-721 token contract on the Dogechain zkEVM network using Foundry. + +We will be following the Soulbound NFT tutorial from [this video](https://www.loom.com/share/41dcd20628774d3bbcce5edf2647312f). + +## Set up the environment + +Foundry is a smart contract development toolchain. It can be used to manage dependencies, compile a project, run tests and deploy smart contracts. It also lets one interact with the blockchain from the CLI or via Solidity scripts. + +### Install Foundry + +If you have not installed Foundry, Go to [book.getfoundry](https://book.getfoundry.sh) and select **Installation** from the side menu. Follow the instructions to download **Using Foundryup**. + +Next, select **Creating a New Project** from the sidebar. Initialize and give your new project a name: ```forge init zkevm-sbt``` + +In case of a `library not loaded error`, you should run below command and then repeat the above process again: + +```bash +brew install libusb +``` + +If you never installed Rust or need an update, visit the website [here](https://www.rust-lang.org/tools/install). + +### Build a project and test + +Run the command `forge build` to build the project. The output should look something like this: + +![Successful forge build command](/img/zkEVM/zkv-success-forge-build.png) + +Now, test the build with `forge test` + +![Testing Forge Build](/img/zkEVM/zkv-test-forge-build.png) + +You can check out the contents of the newly built project by switching to your IDE. In case of VSCode, just type: ```code .``` + +## Writing the smart contract + +1. Find the [OpenZeppelin Wizard](https://wizard.openzeppelin.com) in your browser, and use the wizard to create an out-of-the-box NFT contract. + + - Select the `ERC721` tab for an NFT smart contract. + + - Name the NFT and give it an appropriate symbol. Example: Name `SoEarly` and Symbol `SOE`. + + - Go ahead and select features for your token. Simply tick the relevant boxes. + + - You can tick the **URI Storage** box if you wish to attach some image or special text to the token. + +2. Open your CLI and install dependencies with this command: + + ```bash + npm install @openzeppelin/contracts-upgradeable + ``` + +3. Remap dependencies to easy-to-read filenames with the command: + + ```bash + forge remappings > remappings.txt + ``` + +4. Inside the new `remapping.txt` file, rename the referencing `openzeppelin-contracts` to `openzeppelin`, which is the name used when importing. That is, change `openzeppelin-contracts/=lib/openzeppelin-contracts` → `openzeppelin/=lib/openzeppelin-contracts`. + +5. Copy the smart contract code in OpenZeppelin: **Copy to Clipboard** + +6. In the IDE, open a new `.sol` file, name it and paste the copied code to this file. This is in fact the actual smart contract for the NFT. + +## Add control on token transfers + +The aim here is to put rules in place stipulating that the token cannot be transferred without burning it. + +- Go to the [OpenZeppelin documentation](https://docs.openzeppelin.com/). + +- Look up the signature by searching for `_beforetokentransfererc721`. + +- Scroll down to `ERC 721` and copy the corresponding text on the right side: + + ```c + _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal + ``` + +- Create a new function in the code for the smart contract token called `_beforeTokenTransfer` + + ```c + function _beforeTokenTransfer (address from, address to, uint256 firstTokenId, uint256 batchSize) internal override { + require(from==address(0) || to==address(0), "Soulbound: cannot transfer"); + super._beforeTokenTransfer(from, to, firstTokenId, batchSize); + } + ``` + +## Set a token URI (optional) + +A token URI is a function that returns the address where the metadata of a specific token is stored. The metadata is a `. json` file where all the data associated with the NFT is stored. Our aim here is to attach some image to the created token. + +The stored data typically consists of the name of the token, brief description and URL where the image is stored. + +- Choose an image and give it a name relatable to the token + +- Find some free of charge IPFS storage for the image, like [NFT.STORAGE](https://nft.storage) + +- Upload the image to the storage using your GitHub account + +## Add URI json file + +This is the file that contains the metadata for the token which includes the image address (i.e., the IPFS address of the image). + +- In the IDE, create a new `.json` file which you can call `tokenuri.json` + +- Populate the `tokenuri.json` file with the token-name, description and URL where the image is stored: + + ```json + { + "title": "So Early", + "description": "I was super duper early to the Dogechain zkEVM", + "image": "" /* remove the forward-slash at the end of the URL, if any */ + } + ``` + +- Upload the `tokenuri.json` file to the same storage where the image was uploaded + +- Copy the address to the `Sbt.sol` inside the `safeMint` function + +- Remove the `uri` parameter so as to hardcode it. This makes all tokens to have the same `uri` image, but every consecutively minted pair of tokens will differ by 1 in numerical value of their `tokenId`. + +## Populate the `.env` file + +In order to deploy on the Dogechain zkEVM Testnet, populate the `.env` file in the usual way. That is, + +- Create a `.env.sample` file within the `src` folder + +- Populate `.env.sample` file with your `ACCOUNT_PRIVATE_KEY` and the Dogechain zkEVM Testnet's `RPC URL` found [here](/docs/zkevm/quick-start/connect-wallet). So the `.env.sample` file will look like this: + + ```json + RPC_URL="https://rpc.testnet-cdk.dogechain.dog" + PVTKEY="" + ``` + +- Copy the contents of the `.env.sample` file to the `.env` file, + + ```bash + cp .env.sample .env + ``` + +!!!warning + + Make sure `.env` is in the `.gitignore` file to avoid uploading your `ACCOUNT_PRIVATE_KEY`. + +## Deploy your contract + +1. In the CLI, use the following command to ensure grabbing variables from `.env`: + + ```bash + source .env + ``` + +2. Check if the correct `RPC URL` is read from the `.env` file: + + ```bash + echo $RPC_URL + ``` + +3. You can now use the next command: + + ```bash + forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY src/{ContractFile.sol}:{ContractName} --legacy + ``` + + which executes the following: + + - Does a `forge create`. + - Passes the `RPC_URL` and `PVTKEY`. + - References the actual smart contract. + + For example, when deploying the `Sbt.sol` contract, the command will look like this: + + ```bash + forge create --rpc-url $RPC_URL --private-key $PRIVATE_KEY src/Sbt.sol:SoEarly --legacy + ``` + +The above command compiles and deploys the contract to the Dogechain zkEVM Testnet. The output on the CLI looks like this one below. + +![Successful Deploy Sbt.sol](/img/zkEVM/zkv-success-deploy-sbtdotsol.png) + +## Check deployed contract in explorer + +- Copy the address of your newly deployed contract (i.e. the `Deployed to:` address as in the above example output). + +- Go to the [Dogechain zkEVM Testnet Explorer](https://explorer.testnet-cdk.dogechain.dog), and paste the address in the `Search by address` field. + +- Check `Transaction Details` reflecting the `From` address, which is the owner's address and the `To` address, which is the same `Deployed to:` address seen in the CLI. \ No newline at end of file diff --git a/docs/zkevm/how-to/using-hardhat.md b/docs/zkevm/how-to/using-hardhat.md new file mode 100644 index 0000000..5c9777a --- /dev/null +++ b/docs/zkevm/how-to/using-hardhat.md @@ -0,0 +1,296 @@ +--- +id: using-hardhat +title: Deploy a contract with Hardhat +--- + +Hardhat is one of the popular smart contract development frameworks. It is the Dogechain zkEVM's preferred framework, and therefore used in the Dogechain zkEVM as a default for deploying and automatically verifying smart contracts. + +This document is a guide on how to deploy a smart contract on the Dogechain zkEVM network using Hardhat. Feel free to check out the tutorial video available [here](https://www.youtube.com/watch?v=GNBHDCGFxtw). + +## Initial setup + +!!!info + + Before starting with this deployment, please ensure that your wallet is connected to the Dogechain zkEVM Testnet. See the demo [here](/docs/get-started/connect-wallet) for details on how to connect your wallet. + +- Add the Dogechain zkEVM Testnet to your Metamask wallet and get some Testnet ETH from the [Faucet](https://dogechain-demo.caldera.dev/faucet). + +- Clone the repo using below command: + + ```bash + git clone https://github.com/oceans404/fullstack-zkevm + ``` + +- Install dependencies and start React app (you can copy all three lines in one go). + + ```bash + cd fullstack-zkevm + npm i + npm start + ``` + + Correct installation opens up the Counter App at `localhost:3000`. You can test it by clicking on the `+1` button several times. + +- Back in the CLI, install dependencies: + + ```bash + npm install ethers hardhat @nomiclabs/hardhat-waffle ethereum-waffle chai @nomiclabs/hardhat-ethers dotenv + ``` + +- Populate the `.env.sample` file with your `ACCOUNT_PRIVATE_KEY` + +
+How to get your private key in MetaMask + +- Click the vertical 3 dots in the upper-right corner of Metamask window + +- Select **Account details** and then click **Export private key** + +- Enter your Metamask password to reveal the private key + +- Copy the private key and paste it into the `.env.sample` file. + +
+ +- Copy the contents of the `.env.sample` file to the `.env` file, + + ```bash + cp .env.sample .env + ``` + +## Hardhat smart contract + +Next is the initialization of a project using Hardhat. Hardhat cannot initialize a sample project if there is an existing README file. To avoid clashes, rename any existing `README.md` temporarily before initializing Hardhat. + +```bash +mv README.md README-tutorial.md +``` + +- Initialize a project with Hardhat: ```npx hardhat```. + +- Next, (... *To avoid failure ... please go slow with this cli dialogue*...), + + The aim here is to achieve the following outcome: + + ![Figure _ ](/img/zkEVM/zkv-proj-created-outcome.png) + + So then, + + - Press `` to set the project root. + - Press `` again to accept addition of `.gitignore`. + - Type `n` to reject installing `sample project's dependencies`. + + The idea here is to postpone installing dependencies to later steps due to a possible version-related bug. + +- Open the `hardhat.config.js` file and paste the below code: + + ```js + require("dotenv").config(); + require("@nomicfoundation/hardhat-toolbox"); + + /** @type import('hardhat/config').HardhatUserConfig */ + module.exports = { + solidity: "0.8.9", + paths: { + artifacts: "./src", + }, + networks: { + zkEVM: { + url: `https://rpc.testnet-cdk.dogechain.dog`, + accounts: [process.env.ACCOUNT_PRIVATE_KEY], + }, + }, + }; + ``` + + Note that a different path to artifacts is added so that the React app will be able to read the contract ABI within the `src` folder. + +## Add scripts + +- Create a new file, in the contracts folder, named `Counter.sol`: ```touch contracts/Counter.sol```. + +- Copy the below code and paste it in the Counter contract code: + + ```solidity + //SPDX-License-Identifier: MIT + pragma solidity ^0.8.9; + + contract Counter { + uint256 currentCount = 0; + + function increment() public { + currentCount = currentCount + 1; + } + + function retrieve() public view returns (uint256){ + return currentCount; + } + } + ``` + +- Create a new file in the scripts folder `deploy-counter.js`: ```touch scripts/deploy-counter.js```. + +- Add the code below to the `deploy-counter.js` file: + + ```js + const hre = require("hardhat"); + + async function main() { + const deployedContract = await hre.ethers.deployContract("Counter"); + await deployedContract.waitForDeployment(); + console.log( + `Counter contract deployed to https://explorer.testnet-cdk.dogechain.dog/address/${deployedContract.target}` + ); + } + + main().catch((error) => { + console.error(error); + process.exitCode = 1; + }); + ``` + +- Before compiling the contract, you need to install the toolbox. You may need to change directory to install outside the project. Use this command: + + ```bash + npm install --save-dev @nomicfoundation/hardhat-toolbox + ``` + +- Compile your contract code (i.e., go back to the project root in the CLI): + + ```bash + npx hardhat compile + ``` + +- Now run the scripts: + + ```bash + npx hardhat run scripts/deploy-counter.js --network zkEVM + ``` + + ​Here's an output example: + + `Counter contract deployed to https://explorer.testnet-cdk.dogechain.dog/address/0x5FbDB2315678afecb367f032d93F642f64180aa3` + +## Update frontend + +The next step is to turn `Counter.sol` into a dApp by importing the `ethers` and the `Counter` file, as well as logging the contract's ABI. + +- Include the below code in the `App.js` file: + + ```js + import { ethers } from "ethers"; + import Counter from "./contracts/Counter.sol/Counter.json"; + const counterAddress = "your-contract-address" + console.log(counterAddress, "Counter ABI: ", Counter.abi); + ``` + +- Update the `counterAddress` to your deployed address. + + - It is the hexadecimal number found at the tail-end of the output of the last `npx hardhat run ...` command and looks like this `0x5FbDB2315678afecb367f032d93F642f64180aa3`. + + - It must be pasted in the `App.js` to replace `your-contract-address`. Be sure to use the deployed address from your own implementation! + +- Update frontend counter to read from blockchain. Include the below code in the `App.js` file: + + ```js + useEffect(() => { + // declare the data fetching function + const fetchCount = async () => { + const data = await readCounterValue(); + return data; + }; + + fetchCount().catch(console.error); + }, []); + + async function readCounterValue() { + if (typeof window.ethereum !== "undefined") { + const provider = new ethers.providers.Web3Provider(window.ethereum); + + console.log("provider", provider); + + const contract = new ethers.Contract( + counterAddress, + Counter.abi, + provider + ); + + console.log("contract", contract); + + try { + const data = await contract.retrieve(); + console.log(data); + console.log("data: ", parseInt(data.toString())); + setCount(parseInt(data.toString())); + } catch (err) { + console.log("Error: ", err); + alert( + "Switch your MetaMask network to Dogechain zkEVM Testnet and refresh this page!" + ); + } + } + } + ``` + +- Also, to import `useEffect`, insert it like this: + + ```js + import { useState, useEffect } from "react"; + ``` + +- To be able to track a loader, add this to your state: + + ```js + const [isLoading, setIsLoading] = useState(false); + ``` + + - This is within the `App()` function. + +- Let frontend counter write to the blockchain by adding the below `requestAccount` and `updateCounter` functions: + + ```js + async function requestAccount() { + await window.ethereum.request({ method: "eth_requestAccounts" }); + } + + async function updateCounter() { + if (typeof window.ethereum !== "undefined") { + await requestAccount(); + const provider = new ethers.providers.Web3Provider(window.ethereum); + console.log({ provider }); + const signer = provider.getSigner(); + const contract = new ethers.Contract(counterAddress, Counter.abi, signer); + const transaction = await contract.increment(); + setIsLoading(true); + await transaction.wait(); + setIsLoading(false); + readCounterValue(); + } + } + ``` + + Place these two functions above the `readCounterValue()` function in the `App.js` file. + +- Replace the `incrementCounter` function with this one: + + ```js + const incrementCounter = async () => { + await updateCounter(); + }; + ``` + +- Update the increment button code to: + + ```js + + ``` + +Now, run the Counter dApp by simply using `npm start` in CLI at the project root. + +Congratulations for reaching this far. You have successfully deployed a dApp on the Dogechain zkEVM testnet. \ No newline at end of file diff --git a/docs/zkevm/how-to/verify-contract.md b/docs/zkevm/how-to/verify-contract.md new file mode 100644 index 0000000..7479ede --- /dev/null +++ b/docs/zkevm/how-to/verify-contract.md @@ -0,0 +1,122 @@ +--- +id: verify-contract +title: Verify a contract +--- + +Once a smart contract is deployed to Dogechain zkEVM, it can be verified in various ways depending on the framework of deployment as well as the complexity of the contract. The aim here is to use examples to illustrate how you can manually verify a deployed smart contract. + +Ensure that your wallet is connected while following this guide. We will use Metamask wallet throughout this tutorial. + +## Manual verification + +After successfully compiling a smart contract, follow the next steps to verify your smart contract. + +1. Copy the address to which the smart contract is deployed. + +2. Navigate to the [Dogechain zkEVM Explorer](https://explorer.testnet-cdk.dogechain.dog) and paste the contract address into the Search box. This opens a window with a box labelled **Contract Address Details**. + +3. Scroll down to the box with tabs labelled **Transactions**, **Internal Transactions**, **Coin Balance History**, **Logs**, and **Code**. + +4. Click the **Transaction Hash** in the **Contract Creation** box, which is the _super long_ number. + +5. Select the **Code** tab. + +6. Click the **Verify and Publish** button. + +7. There are 3 options to provide the Contract's code. We will be diving into the following two options: +??? "Flattened source code" + Click **Next** after selecting the **via Flattened Source Code** option. + + Various frameworks have specific ways to flatten the source code. Our examples are **Remix** and **Foundry**. + + #### Using Remix + + In order to flatten the contract code with Remix, one needs to only right-click on the contract name and select **Flatten** option from the drop-down menu that appears. See the below figure for reference. + + ![Selecting the flatten code option](/img/zkEVM/flatten-code-remix.png) + + After selecting **Flatten**, a new `.sol` file with the suffix `_flatten.sol` is automatically created. Copy the contents of the new `_flatten.sol` file and paste into the `Enter the Solidity Contract` field in the explorer. + + #### Using Foundry + + In order to flatten the code using Foundry, the following command can be used: + + ```bash + forge flatten src/ -o .sol + ``` + + With this command, the flattened code gets saved in the `.sol` file. Copy the contents of the new `.sol` file and paste into the `Enter the Solodity Contract` field in the [explorer](https://explorer.testnet-cdk.dogechain.dog). + + +??? "Standard input JSON" + Click **Next** after selecting the **via Standard Input JSON** option. + + 1. In order to update the **Compiler** based on your contract's compiler version, + - Click the ↓ for a list of compiler versions. + - Select the corresponding version. For example, select `v0.8.9+commit.e5eed63a` if your code has `pragma solidity ^0.8.9;`. + + 2. Paste the **Standard input JSON** file into the *Drop the standard input JSON file or Click here* field. You can find it in your local project folder. + - The **Standard input JSON** file is the `{"superlongnumberfile"}.json` in the `build-info` subfolder. Path example: `fullstack-zkevm/src/build-info/{"superlongnumberfile"}.json` + - Save this file to parse it with [Prettier](https://prettier.io/) + - Find the input JSON object. It will look [something like this](https://docs.soliditylang.org/en/latest/using-the-compiler.html#input-description) → `"input": {}` + - Copy the **input** object value into a new file + - **Name and save** this file locally in the **root folder**. Check this [example file](https://github.com/oceans404/zkevm-hardhat-demo/blob/main/example-standard-input.json) for reference + - Drag and drop the **Standard Input JSON** file into *Drop the standard input JSON file or Click here* field. Once pasted, the **Verify & Publish** button becomes active. + + 3. Since you have provided an input, set *Try to fetch constructor arguments automatically* to **No**. + + 4. To add your ABI-encoded constructor arguments: + - Open the [Online ABI Encoder](https://abi.hashex.org/) + - Choose the `Auto-parse` tab. + - Copy the ABI-encoded output. + - Paste it into `ABI-encoded Constructor Arguments` if required by the contract. + +Once you paste the contents of the newly created `.sol` file to the _Enter the Solidity Contract_ field, the **Verify & Publish** button will be active. + +Click on **Verify & Publish** to verify your deployed smart contract. + +## Verify using Remix + +We will be using the ready-made `Storage.sol` contract in Remix. Compile the contract and follow the steps provided below. + +1. Deploy the `Storage.sol` contract: + + - Click the **Deploy** icon on the left-side of the IDE window. + - Change `ENVIRONMENT` to "Injected Provider - MetaMask" (ensure that your wallet is already connected to Goërli network). + - Confirm the connection request when MetaMask pops up. + - Click the **Deploy** button and confirm. + +2. Check the deployed smart contract on Etherscan: + + - Copy the contract address below the **Deploy Contracts**. + - Navigate to the [Goërli explorer](https://goerli.etherscan.io). + - Paste the contract address in the _Search by address_ field and press **ENTER**. + - Click on the **Transaction Hash** to see transaction details. + +3. You are going to need your **Etherscan API Key** in order to verify. + + - Login to Etherscan. + - Hover the cursor over your username for a drop-down menu. + - Select **API Keys**. + - Click **API Keys** again below the **Others** option. + - Copy the API Key. + +4. Next, in the Remix IDE: + + - Click **Plugin Manager** icon on the bottom-left corner of the Remix IDE. + + - Type **Etherscan** in the search field at the top. + + - Click **Activate** button as the Etherscan option appears. Etherscan icon will appear on the left-side of the IDE. + + - Click on the Etherscan icon. + + - Ensure that **Goërli** is present in the **Selected Network** field. + + - Click within the _Contract Name_ field and type in the name of your deployed contract, or select it if it appears. + + - Paste the address in the _Contract Address_ field. + + - **Verify** button will be active if all information has been provided. + + - Click the **Verify** button to complete verification of your smart contract. \ No newline at end of file diff --git a/docs/zkevm/how-to/write-contract.md b/docs/zkevm/how-to/write-contract.md new file mode 100644 index 0000000..78d0a5a --- /dev/null +++ b/docs/zkevm/how-to/write-contract.md @@ -0,0 +1,45 @@ +--- +id: write-contract +title: Write a contract +--- + +This document explains how to automatically write a smart contract using the OpenZeppelin Wizard. The resulting smart contract code can either be integrated with Remix by Clicking the **Open in Remix** button, or copied to a clipboard and pasted in the user's intended IDE. + +## Getting started + +Navigate to the [OpenZeppelin Wizard](https://wizard.openzeppelin.com) in your browser. First thing to notice is the **Solidity Wizard** and **Cairo Wizard** buttons. + +One can choose any of the following tabs to begin creating an out-of-box smart contract code in either Solidity (for EVM chains) or Cairo (useful for Starknet). These are: + +- **ERC20** for writing an ERC-20 token smart contract. +- **ERC721** for writing an NFT token smart contract. +- **ERC1155** for writing an ERC-1155 token smart contract. +- **Governor** for creating a DAO. +- **Custom** for writing a customized smart contract. + +## Writing an NFT contract + +For illustration purposes, we will be creating a NFT smart contract. + +Suppose you wanted to create a `Mintable`, `Burnable` ERC721 token and specify an appropriate license for it. + +1. Select the **ERC721** tab. + +2. Give your NFT a name and a symbol by filling the `Name` and `Symbol` fields. + +3. Use the check-boxes on the left to select features of your token. + +- Put a tick on the `Mintable` check-box. +- Put a tick on the `Auto Increment Ids` check-box, this ensures uniqueness of each minted NFT. +- Put a tick on the `Burnable` check-box. +- Either leave the **default MIT license** or type the license of your choice. + + Notice that new lines of code are automatically written each time a feature is selected. + +## Voila! Contract is ready + +With the resulting lines of code, you now have the NFT token contract written in Solidity. As mentioned above, this source code can now be ported to an IDE of your choice or opened directly in Remix. + +The below figure depicts the auto-written NFT smart contract code. + +![The end-product NFT source code](/img/zkEVM/zkv-end-product-nft-code.png) diff --git a/docs/zkevm/overview.md b/docs/zkevm/overview.md new file mode 100644 index 0000000..221b1b9 --- /dev/null +++ b/docs/zkevm/overview.md @@ -0,0 +1,10 @@ +--- +id: overview +title: Overview +displayed_sidebar: zkevm +--- +Dogechain is powered by Dogechain team and Polygon, and now supports zkEVM. + +Dogechain zkEVM is a Layer 2 network of the Ethereum Virtual Machine (EVM), a zero-knowledge (ZK) rollup scaling solution. Dogechain zkEVM uses a cryptographic primitive called a ZK proof to validate state transitions. + +Dogechain zkEVM is EVM-equivalent. It supports the majority of Ethereum EIPs, precompiles, and opcodes. Developers benefit from the seamless deployment of smart contracts, developer tools, and wallets that already work on Ethereum, but in an environment with significantly lower costs. diff --git a/docs/zkevm/quick-start/bridge-to-zkevm.md b/docs/zkevm/quick-start/bridge-to-zkevm.md new file mode 100644 index 0000000..60c3b2a --- /dev/null +++ b/docs/zkevm/quick-start/bridge-to-zkevm.md @@ -0,0 +1,46 @@ +--- +id: bridge-to-zkevm +title: Bridging assets to zkEVM +--- + + + +Users can deposit assets from Ethereum and transact off-chain on Dogechain zkEVM. For moving assets across chains (L1 ↔ Dogechain zkEVM), you will need to use the Dogechain zkEVM Bridge. The bridge interface is available for both Mainnet Beta and Testnet in the [Polygon Wallet Suite](https://wallet.polygon.technology/zkEVM/bridge). + + + +## Step-by-step guide + +Follow this step-by-step guide on how to bridge assets from Ethereum to Dogechain zkEVM Mainnet and vice-versa. Or, from an Ethereum testnet to Dogechain zkEVM testnet, and conversely. + +- On the [Polygon Wallet Suite website](https://wallet.polygon.technology/), select the Dogechain zkEVM tab, which is next to the Proof-of-Stake tab: + +![Figure: wallet](/img/zkEVM/zkv-zkwallet-1.jpg) + +- Click on the Bridge wallet feature to access the Dogechain zkEVM environment. + +- Set the amount of tokens to transfer from Ethereum network to Dogechain zkEVM Mainnet (Or, from an Ethereum testnet to Dogechain zkEVM testnet). + +![Figure: bridge2](/img/zkEVM/zkv-bridge2.jpg) + +- Recent transactions and pending transactions can be viewed on the right hand side of the page. +- Click the **Bridge ETH to Dogechain zkEVM testnet** button to proceed. This is followed by Metamask's prompt to approve gas to be spent. + +![Figure: metamask1](/img/zkEVM/zkv-metamask1.jpg) + +- Click **Confirm** to approve the bridge transaction. + +- And allow a few moments for your transaction to be processed. + +- Once it is completed, past and pending transactions can be viewed by clicking the **Transactions** button located on the left side of the menu. + +![Figure: tx-history](/img/zkEVM/zkv-transaction-history.jpg) \ No newline at end of file diff --git a/docs/zkevm/quick-start/connect-wallet.md b/docs/zkevm/quick-start/connect-wallet.md new file mode 100644 index 0000000..0c3001c --- /dev/null +++ b/docs/zkevm/quick-start/connect-wallet.md @@ -0,0 +1,28 @@ +--- +id: connect-wallet +title: Connecting to zkEVM +--- + + + +Connect to either the Dogechain zkEVM's mainnet or the testnet. + +Add the Dogechain zkEVM network of your choice to your wallet by navigating to the add network input, and enter the respective network details as given in the below table: + +| Network | RPC URL | ChainID | Block Explorer URL | Currency | +| ------- | ------------------------------- | ---------------- | ---------------- | ----- | +| Testnet | `https://rpc.testnet-cdk.dogechain.dog` | `2024115` | `https://explorer.testnet-cdk.dogechain.dog` | **ETH** | + + + +Once the wallet is connected, the next step is to bridge crypto assets from Ethereum to Dogechain zkEVM. + +For testnet purposes, you can use the Dogechain zkEVM faucet to get testnet tokens. \ No newline at end of file diff --git a/docs/zkevm/quick-start/zkevm-faucet.md b/docs/zkevm/quick-start/zkevm-faucet.md new file mode 100644 index 0000000..af018a8 --- /dev/null +++ b/docs/zkevm/quick-start/zkevm-faucet.md @@ -0,0 +1,39 @@ +--- +id: zkevm-faucet +title: Using faucet +--- + + + Faucet is the official tool provided by Dogechain Labs to obtain Testnet tokens. It is a faucet that is similar to what ecosystem partners like Alchemy provide. + +The faucet allows anyone to request ETH testnet tokens, such as Sepolia testnet ETH. This cuts out the middle step of bridging testnet tokens from the faucet to the Dogechain zkEVM. + +!!!info + Dogechain zkEVM network faucet provides 0.025 ETH in a single user request. + + We understand that Goërli ETH holds value which might attract malicious actors. That is why, we have integrated certain security measures in place to prevent any DoS attacks on the Faucet. + +Here is how to use the Dogechain zkEVM faucet: + +- Navigate to [`faucet`](https://dogechain-demo.caldera.dev/faucet) +![Figure: faucet-zk](/img/zkEVM/zkv-faucet-zketh.png) + + \ No newline at end of file diff --git a/docusaurus.config.js b/docusaurus.config.js index c960e8d..ab4adaa 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -6,7 +6,7 @@ module.exports = { url: 'https://docs.dogechain.dog', baseUrl: '/', onBrokenLinks: 'throw', - onBrokenMarkdownLinks: 'warn', + onBrokenMarkdownLinks: 'throw', favicon: 'img/logo.png', organizationName: 'dogechain-lab', projectName: 'dogechain-docs', @@ -41,6 +41,12 @@ module.exports = { label: 'Developers', position: 'left' }, + { + to: 'docs/zkevm/overview', + activeBasePath: 'docs/', + label: 'zkEVM', + position: 'left' + }, { to: 'docs/tokenomics/overview', activeBasePath: 'docs/', diff --git a/sidebars.js b/sidebars.js index 441163b..d2bfba4 100644 --- a/sidebars.js +++ b/sidebars.js @@ -1,5 +1,27 @@ module.exports = { - develop: [ + zkevm: [ + 'zkevm/overview', + { + type: 'category', + label: 'Get started', + items: [ + 'zkevm/quick-start/connect-wallet', + 'zkevm/quick-start/zkevm-faucet', + 'zkevm/quick-start/bridge-to-zkevm', + ] + }, + { + type: 'category', + label: 'How to', + items: [ + 'zkevm/how-to/write-contract', + 'zkevm/how-to/using-foundry', + 'zkevm/how-to/using-hardhat', + 'zkevm/how-to/verify-contract', + ] + } + ], + default: [ 'overview', { type: 'category', diff --git a/src/pages/index.js b/src/pages/index.js new file mode 100644 index 0000000..6e5d08d --- /dev/null +++ b/src/pages/index.js @@ -0,0 +1,6 @@ +import React from 'react'; +import {Redirect} from '@docusaurus/router'; + +export default function Home() { + return ; +}; diff --git a/static/img/zkEVM/zkv-bridge2.jpg b/static/img/zkEVM/zkv-bridge2.jpg new file mode 100644 index 0000000..82858d4 Binary files /dev/null and b/static/img/zkEVM/zkv-bridge2.jpg differ diff --git a/static/img/zkEVM/zkv-confirm-zketh.png b/static/img/zkEVM/zkv-confirm-zketh.png new file mode 100644 index 0000000..391c2f2 Binary files /dev/null and b/static/img/zkEVM/zkv-confirm-zketh.png differ diff --git a/static/img/zkEVM/zkv-end-product-nft-code.png b/static/img/zkEVM/zkv-end-product-nft-code.png new file mode 100644 index 0000000..08498e4 Binary files /dev/null and b/static/img/zkEVM/zkv-end-product-nft-code.png differ diff --git a/static/img/zkEVM/zkv-faucet-zketh.png b/static/img/zkEVM/zkv-faucet-zketh.png new file mode 100644 index 0000000..2bf564e Binary files /dev/null and b/static/img/zkEVM/zkv-faucet-zketh.png differ diff --git a/static/img/zkEVM/zkv-metamask1.jpg b/static/img/zkEVM/zkv-metamask1.jpg new file mode 100644 index 0000000..e445fad Binary files /dev/null and b/static/img/zkEVM/zkv-metamask1.jpg differ diff --git a/static/img/zkEVM/zkv-proj-created-outcome.png b/static/img/zkEVM/zkv-proj-created-outcome.png new file mode 100644 index 0000000..c059d37 Binary files /dev/null and b/static/img/zkEVM/zkv-proj-created-outcome.png differ diff --git a/static/img/zkEVM/zkv-success-deploy-sbtdotsol.png b/static/img/zkEVM/zkv-success-deploy-sbtdotsol.png new file mode 100644 index 0000000..5b24bd1 Binary files /dev/null and b/static/img/zkEVM/zkv-success-deploy-sbtdotsol.png differ diff --git a/static/img/zkEVM/zkv-success-forge-build.png b/static/img/zkEVM/zkv-success-forge-build.png new file mode 100644 index 0000000..4668b9f Binary files /dev/null and b/static/img/zkEVM/zkv-success-forge-build.png differ diff --git a/static/img/zkEVM/zkv-success-zketh.png b/static/img/zkEVM/zkv-success-zketh.png new file mode 100644 index 0000000..d9006b5 Binary files /dev/null and b/static/img/zkEVM/zkv-success-zketh.png differ diff --git a/static/img/zkEVM/zkv-test-forge-build.png b/static/img/zkEVM/zkv-test-forge-build.png new file mode 100644 index 0000000..412dd72 Binary files /dev/null and b/static/img/zkEVM/zkv-test-forge-build.png differ diff --git a/static/img/zkEVM/zkv-transaction-history.jpg b/static/img/zkEVM/zkv-transaction-history.jpg new file mode 100644 index 0000000..4c34262 Binary files /dev/null and b/static/img/zkEVM/zkv-transaction-history.jpg differ diff --git a/static/img/zkEVM/zkv-zkwallet-1.jpg b/static/img/zkEVM/zkv-zkwallet-1.jpg new file mode 100644 index 0000000..0c91ac4 Binary files /dev/null and b/static/img/zkEVM/zkv-zkwallet-1.jpg differ