From 9379783b372c0e8fcca81bb30ee555704d455b1f Mon Sep 17 00:00:00 2001
From: emilyjlin95 <17280653+emilyJLin95@users.noreply.github.com>
Date: Tue, 22 Aug 2023 16:18:20 -0400
Subject: [PATCH 1/2] Foundry verification and secret files
---
.../deploy-smart-contract/foundry.md | 49 ++++++--
.../deploy-smart-contract/hardhat.mdx | 4 +-
.../deploy-smart-contract/truffle.mdx | 2 +-
.../verify-smart-contract/foundry.md | 105 +++++++++---------
.../verify-smart-contract/truffle.md | 2 +-
5 files changed, 93 insertions(+), 69 deletions(-)
diff --git a/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md b/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md
index d965d64f6..614f73c6f 100644
--- a/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md
+++ b/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md
@@ -1,6 +1,6 @@
---
title: Foundry
-sidebar_position: 3
+sidebar_position: 2
---
# Foundry
@@ -26,7 +26,7 @@ Before you begin, Ensure you've:
## Create a Foundry project
-To create an empty Foundry project, run:
+To create a Foundry project, run:
```bash
forge init linea-tutorial
@@ -38,26 +38,55 @@ And change into the directory:
cd linea-tutorial
```
-## Write the smart contract
+## Deploy a smart contract
Running `forge init` sets you up with a sample contract, test, and script for `Counter.sol`. To build it, simply run `forge build`.
-## Deploy the smart contract
+To deploy a smart contract, we highly recommend using an Infura endpoint, as the public endpoint may experience rate limiting.
-To deploy a smart contract, we highly recommend using an Infura endpoint, as the public endpoint may experience rate limiting. You can find out how to [get an API key here](https://support.linea.build/hc/en-us/articles/15752713253147). Then, you can run the following command.
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
-Using Infura:
+
+
+
+To use Infura, you'll need to [get an API key](https://support.infura.io/hc/en-us/articles/15116941373979-Connecting-to-the-Linea-network)
+
+On testnet:
```bash
forge create --rpc-url https://linea-goerli.infura.io/v3/YOUR-INFURA-API-KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
```
-Using the public endpoint:
+On mainnet:
+
+```bash
+forge create --rpc-url https://linea.infura.io/v3/YOUR-INFURA-API-KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
+```
+
+
+
+:::caution
+
+The public endpoints are rate limited and not meant for production systems.
+
+On testnet:
```bash
forge create --rpc-url https://rpc.goerli.linea.build/ src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
```
+On mainnet:
+
+:::
+
+```bash
+forge create --rpc-url https://rpc.linea.build/ src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
+```
+
+
+
+
Your output should look a little something like this:
```bash
@@ -66,8 +95,4 @@ Deployed to: 0xED0Ff7E8B655dFFfCA471ea3B6B649ce7C2C1b83
Transaction hash: 0x967e1290b285e67b3d74940ee19925416734c345f58bd1ec64dcea134647d7ee
```
-Next, you can optionally [verify your contract on the network](../verify-smart-contract/foundry.md).
-
-## Deploy to Mainnet
-
-_Instructions coming soon!_
+Next, you can optionally [verify your contract on the network](../verify-smart-contract/foundry.md).
\ No newline at end of file
diff --git a/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx b/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx
index 3f8e5342b..b9398f38d 100644
--- a/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx
+++ b/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx
@@ -131,7 +131,7 @@ To deploy to Linea, we'll need to add the network to our `hardhat.config.js`. To
1. Add Linea to your `hardhat.config.js` file.
-
+
To use Infura, you'll need to [get an API key](https://support.infura.io/hc/en-us/articles/15116941373979-Connecting-to-the-Linea-network). Add it to the `.env` file as follows:
@@ -162,7 +162,7 @@ To deploy to Linea, we'll need to add the network to our `hardhat.config.js`. To
};
```
-
+
The public endpoints are rate limited and not meant for production systems. However, you can use the public endpoints by modifying `hardhat.config.js` as follows:
diff --git a/docs/build-on-linea/quickstart/deploy-smart-contract/truffle.mdx b/docs/build-on-linea/quickstart/deploy-smart-contract/truffle.mdx
index 9efe9c6d7..3a12fadcc 100644
--- a/docs/build-on-linea/quickstart/deploy-smart-contract/truffle.mdx
+++ b/docs/build-on-linea/quickstart/deploy-smart-contract/truffle.mdx
@@ -1,6 +1,6 @@
---
title: Truffle
-sidebar_position: 2
+sidebar_position: 3
---
import Tabs from '@theme/Tabs';
diff --git a/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md b/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md
index e42b2b4e4..d8ad721a9 100644
--- a/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md
+++ b/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md
@@ -1,83 +1,82 @@
---
title: Foundry
-sidebar_position: 3
+sidebar_position: 2
---
-To verify your contracts with Foundry, use Blockscout's verification page and Foundry's [`forge flatten`](https://book.getfoundry.sh/reference/forge/forge-flatten) utility.
+To verify your Foundry contracts, you can use Foundry's [verify-contract](https://book.getfoundry.sh/reference/forge/forge-verify-contract) to verify contracts on Lineascan.
-In this example, we'll walk through verifying the `Counter` smart contract we deployed in the [Foundry deployment quickstart](../deploy-smart-contract/foundry.md).
+You'll need to get a Lineascan (Linea instance of Etherscan) API key by creating an account at [https://lineascan.build/myapikey](https://lineascan.build/myapikey).
-## Access the Blockscout verification page
+## Verify your smart contract
-In the [Linea block explorer](https://goerli.lineascan.build/), search for your deployed contract address. You can find it in the `Deployed to` address in the Foundry deployment output. In our example, the address is `0xED0Ff7E8B655dFFfCA471ea3B6B649ce7C2C1b83`.
+### Verify a contract that has already been deployed
-```bash
-Deployer: YOUR_ACCOUNT_NUMBER
-Deployed to: 0xED0Ff7E8B655dFFfCA471ea3B6B649ce7C2C1b83
-Transaction hash: 0x967e1290b285e67b3d74940ee19925416734c345f58bd1ec64dcea134647d7ee
-```
-
-Enter the address in the Blockscout search bar, then select the **Code** tab on the page. An unverified contract should look something like this:
-
-![unverified contract](/img/quests/foundry/foundry_verification_1.png)
-
-To verify the contract, select **Verify & Publish**, which takes you to the Blockscout verification page pre-populated with your contract address. Select **Via flattened source code**, and select **Next**.
-
-![flattened source code option](/img/quests/foundry/foundry_verification_2.png)
-
-## Flatten the contract source code
-
-To verify the contract, use the `forge flatten` utility to flatten the smart contract and all its imports into one file. Run the `forge flatten` command as follows:
-
-
+If you want to verify a contract that has already been deployed, you can use the following commands:
-# Syntax
+
+
```bash
-forge flatten --output
+forge verify-contract --etherscan-api-key --verifier-url https://api.lineascan.build/api path_to_contract:contract_name --watch
```
-# Example
+
+
```bash
-forge flatten src/Counter.sol --output ./flat.sol
+forge verify-contract --etherscan-api-key LINEASCAN_API_KEY --verifier-url https://api-testnet.lineascan.build/api path_to_contract:contract_name --watch
```
-
+
+
-In the example, open `flat.sol` and copy paste the code inside:
+You should see something a little like this:
-```javascript
-// SPDX-License-Identifier: UNLICENSED
-pragma solidity ^0.8.13;
-
-contract Counter {
- uint256 public number;
+```bash
+Start verifying contract `0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16` deployed on mainnet
+
+Submitting verification for [src/Counter.sol:Counter] "0x8dE6e9b6c774c8B7AbA587ED84E5AD0A45837b16".
+Submitted contract for verification:
+ Response: `OK`
+ GUID: `ynnfyvwcqev9i5xr1urdqt9kdwx4zkurvpu7rgh2ywmyp22dpy`
+ URL:
+ https://etherscan.io/address/0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16
+Contract verification status:
+Response: `NOTOK`
+Details: `Pending in queue`
+Contract verification status:
+Response: `OK`
+Details: `Pass - Verified`
+Contract successfully verified
+```
- function setNumber(uint256 newNumber) public {
- number = newNumber;
- }
+### Verify a contract upon creation
- function increment() public {
- number++;
- }
-}
-```
+If you want to verify a contract that has already been deployed, you can use the following commands:
-In our case, the flattened code matches the `Counter.sol` code, but oftentimes your smart contracts may import libraries and other smart contracts, and the file will look different.
+
+
-## Get your compiler version
+```bash
+forge create --rpc-url https://linea-goerli.infura.io/v3/INFURA_API_KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY --verify --verifier-url
+l https://apilineascan.build/api --etherscan-api-key LINEASCAN_API_KEY
+```
-Foundry compiles your code using the compiler version found in `~/.svm`. To get the compiler version, run `ls ~/.svm`. In this example, the compiler version is `0.8.17`.
+
+
-![get compiler version](/img/quests/foundry/foundry_verification_3.png)
+```bash
+forge create --rpc-url https://linea-goerli.infura.io/v3/INFURA_API_KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY --verify --verifier-url
+l https://api-testnet.lineascan.build/api --etherscan-api-key LINEASCAN_API_KEY
+```
-## Fill out the Blockscout verification page
+
+
-Now, you have all the information to fill out the verification page. It should look something like this:
+You can check that it was verified correctly by navigating to the [testnet block explorer](https://goerli.lineascan.build/) or the [mainnet block explorer](https://lineascan.build/) and pasting in the deployed contract address.
-![fill out page](/img/quests/foundry/foundry_verification_4.png)
+:::info
-Click **Verify & Publish** and you'll be directed to the verified contract page:
+[Learn more about different configurations for verifying your smart contracts](https://book.getfoundry.sh/reference/forge/forge-verify-contract).
-![verified contract](/img/quests/foundry/foundry_verification_5.png)
+:::
diff --git a/docs/build-on-linea/quickstart/verify-smart-contract/truffle.md b/docs/build-on-linea/quickstart/verify-smart-contract/truffle.md
index 14ba96a13..1e6712203 100644
--- a/docs/build-on-linea/quickstart/verify-smart-contract/truffle.md
+++ b/docs/build-on-linea/quickstart/verify-smart-contract/truffle.md
@@ -1,6 +1,6 @@
---
title: Truffle
-sidebar_position: 2
+sidebar_position: 3
---
To verify your contracts, you can use Truffle's verification plugin [truffle-plugin-verify](https://github.com/rkalis/truffle-plugin-verify).
From cf37a8079a45dc78e0482919823c21e6359ad17b Mon Sep 17 00:00:00 2001
From: emilyjlin95 <17280653+emilyJLin95@users.noreply.github.com>
Date: Tue, 22 Aug 2023 17:43:07 -0400
Subject: [PATCH 2/2] foundry instructions
---
.../deploy-smart-contract/foundry.md | 60 +++++++++++++++++--
.../deploy-smart-contract/hardhat.mdx | 6 +-
.../verify-smart-contract/foundry.md | 58 +++++++++++++++---
project-words.txt | 6 ++
4 files changed, 114 insertions(+), 16 deletions(-)
diff --git a/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md b/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md
index 614f73c6f..e6bd87528 100644
--- a/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md
+++ b/docs/build-on-linea/quickstart/deploy-smart-contract/foundry.md
@@ -3,6 +3,9 @@ title: Foundry
sidebar_position: 2
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
# Foundry
In this tutorial, we'll walk through creating a basic [Foundry](https://book.getfoundry.sh/) project.
@@ -44,8 +47,11 @@ Running `forge init` sets you up with a sample contract, test, and script for `C
To deploy a smart contract, we highly recommend using an Infura endpoint, as the public endpoint may experience rate limiting.
-import Tabs from '@theme/Tabs';
-import TabItem from '@theme/TabItem';
+:::caution
+
+These instructions use API keys and private keys inline. We highly recommend hiding them in `.env` files [by following the instructions below](#using-env-to-store-private-keys).
+
+:::
@@ -55,13 +61,13 @@ To use Infura, you'll need to [get an API key](https://support.infura.io/hc/en-u
On testnet:
```bash
-forge create --rpc-url https://linea-goerli.infura.io/v3/YOUR-INFURA-API-KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
+forge create --rpc-url https://linea-goerli.infura.io/v3/INFURA_API_KEY src/Counter.sol:Counter --private-key PRIVATE_KEY
```
On mainnet:
```bash
-forge create --rpc-url https://linea.infura.io/v3/YOUR-INFURA-API-KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
+forge create --rpc-url https://linea.infura.io/v3/INFURA_API_KEY src/Counter.sol:Counter --private-key PRIVATE_KEY
```
@@ -70,6 +76,8 @@ forge create --rpc-url https://linea.infura.io/v3/YOUR-INFURA-API-KEY src/Counte
The public endpoints are rate limited and not meant for production systems.
+:::
+
On testnet:
```bash
@@ -78,8 +86,6 @@ forge create --rpc-url https://rpc.goerli.linea.build/ src/Counter.sol:Counter -
On mainnet:
-:::
-
```bash
forge create --rpc-url https://rpc.linea.build/ src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY
```
@@ -95,4 +101,46 @@ Deployed to: 0xED0Ff7E8B655dFFfCA471ea3B6B649ce7C2C1b83
Transaction hash: 0x967e1290b285e67b3d74940ee19925416734c345f58bd1ec64dcea134647d7ee
```
+### Using `.env` to store private keys
+
+It is dangerous to directly paste your private key into the command line. One workaround is to use `.env` files to store private information such as your wallet's private keys or API keys. In order to do so, create a `.env` file and add it to your `.gitignore` file. Then, fill it with the following information:
+
+```bash
+PRIVATE_KEY=YOUR_PRIVATE_KEY
+INFURA_API_KEY=YOUR_INFURA_API_KEY
+```
+
+Then, run:
+
+```bash
+source .env
+```
+
+Finally, we can modify the `foundry.toml` file to conveniently store the various rpc endpoints we might be working with. Add this section:
+
+```bash
+[rpc_endpoints]
+linea-testnet = "https://linea-goerli.infura.io/v3/${INFURA_API_KEY}"
+linea-mainnet = "https://linea.infura.io/v3/${INFURA_API_KEY}"
+```
+
+Now, in order to deploy, you can simply run:
+
+
+
+
+```bash
+forge create --rpc-url linea-mainnet src/Counter.sol:Counter --private-key $PRIVATE_KEY
+```
+
+
+
+
+```bash
+forge create --rpc-url linea-testnet src/Counter.sol:Counter --private-key $PRIVATE_KEY
+```
+
+
+
+
Next, you can optionally [verify your contract on the network](../verify-smart-contract/foundry.md).
\ No newline at end of file
diff --git a/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx b/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx
index b9398f38d..8c92ee386 100644
--- a/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx
+++ b/docs/build-on-linea/quickstart/deploy-smart-contract/hardhat.mdx
@@ -131,7 +131,7 @@ To deploy to Linea, we'll need to add the network to our `hardhat.config.js`. To
1. Add Linea to your `hardhat.config.js` file.
-
+
To use Infura, you'll need to [get an API key](https://support.infura.io/hc/en-us/articles/15116941373979-Connecting-to-the-Linea-network). Add it to the `.env` file as follows:
@@ -162,9 +162,9 @@ To deploy to Linea, we'll need to add the network to our `hardhat.config.js`. To
};
```
-
+
- The public endpoints are rate limited and not meant for production systems. However, you can use the public endpoints by modifying `hardhat.config.js` as follows:
+ The public endpoints are rate limited and not meant for production systems.
```javascript
require("@nomicfoundation/hardhat-toolbox");
diff --git a/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md b/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md
index d8ad721a9..13ebb3d46 100644
--- a/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md
+++ b/docs/build-on-linea/quickstart/verify-smart-contract/foundry.md
@@ -3,6 +3,9 @@ title: Foundry
sidebar_position: 2
---
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
To verify your Foundry contracts, you can use Foundry's [verify-contract](https://book.getfoundry.sh/reference/forge/forge-verify-contract) to verify contracts on Lineascan.
You'll need to get a Lineascan (Linea instance of Etherscan) API key by creating an account at [https://lineascan.build/myapikey](https://lineascan.build/myapikey).
@@ -17,14 +20,14 @@ If you want to verify a contract that has already been deployed, you can use the
```bash
-forge verify-contract --etherscan-api-key --verifier-url https://api.lineascan.build/api path_to_contract:contract_name --watch
+forge verify-contract --etherscan-api-key LINEASCAN_API_KEY --verifier-url https://api.lineascan.build/api CONTRACT_ADDRESS path_to_contract:contract_name --watch
```
```bash
-forge verify-contract --etherscan-api-key LINEASCAN_API_KEY --verifier-url https://api-testnet.lineascan.build/api path_to_contract:contract_name --watch
+forge verify-contract --etherscan-api-key LINEASCAN_API_KEY --verifier-url https://api-testnet.lineascan.build/api CONTRACT_ADDRESS path_to_contract:contract_name --watch
```
@@ -33,11 +36,11 @@ forge verify-contract --etherscan-api-key LINEASCAN_API_KEY --verifier-url https
You should see something a little like this:
```bash
-Start verifying contract `0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16` deployed on mainnet
+Start verifying contract 0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16 deployed on mainnet
Submitting verification for [src/Counter.sol:Counter] "0x8dE6e9b6c774c8B7AbA587ED84E5AD0A45837b16".
Submitted contract for verification:
- Response: `OK`
+ Response: OK
GUID: `ynnfyvwcqev9i5xr1urdqt9kdwx4zkurvpu7rgh2ywmyp22dpy`
URL:
https://etherscan.io/address/0x8de6e9b6c774c8b7aba587ed84e5ad0a45837b16
@@ -58,8 +61,7 @@ If you want to verify a contract that has already been deployed, you can use the
```bash
-forge create --rpc-url https://linea-goerli.infura.io/v3/INFURA_API_KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY --verify --verifier-url
-l https://apilineascan.build/api --etherscan-api-key LINEASCAN_API_KEY
+forge create --rpc-url https://linea-goerli.infura.io/v3/INFURA_API_KEY src/Counter.sol:Counter --private-key YOUR_PRIVATE_KEY --verify --verifier-url https://api.lineascan.build/api --etherscan-api-key LINEASCAN_API_KEY
```
@@ -75,8 +77,50 @@ l https://api-testnet.lineascan.build/api --etherscan-api-key LINEASCAN_API_KEY
You can check that it was verified correctly by navigating to the [testnet block explorer](https://goerli.lineascan.build/) or the [mainnet block explorer](https://lineascan.build/) and pasting in the deployed contract address.
+## Using `.env` and `foundry.toml` to store etherscan information
+
+If you don't want to paste your keys inline and have multiple etherscan API keys to manage, you can use `.env` and `foundry.toml` to set up custom configurations.
+
+Assuming you followed the instructions to create a `.env` file [here](../deploy-smart-contract/foundry.md#using-env-to-store-private-keys), add your Lineascan API key to the file:
+
+```bash
+LINEASCAN_API_KEY=YOUR_LINEASCAN_API_KEY
+```
+
+Then, run:
+
+```bash
+source .env
+```
+
+Finally, modify `foundry.toml` to include the etherscan configurations:
+
+```bash
+[etherscan]
+linea-testnet = { key = "${LINEASCAN_API_KEY}", url = "https://api-testnet.lineascan.build/api" }
+linea-mainnet = { key = "${LINEASCAN_API_KEY}", url = "https://api.lineascan.build/api" }
+```
+
+Then, to verify your smart contracts, you can simply run:
+
+
+
+
+```bash
+forge verify-contract --chain linea-mainnet path_to_contract:contract_name --watch
+```
+
+
+
+
+```bash
+forge verify-contract --chain linea-testnet path_to_contract:contract_name --watch
+```
+
+
+
:::info
-[Learn more about different configurations for verifying your smart contracts](https://book.getfoundry.sh/reference/forge/forge-verify-contract).
+Learn more about different configurations for verifying your smart contracts [here](https://book.getfoundry.sh/reference/forge/forge-verify-contract) and [here](https://book.getfoundry.sh/forge/deploying).
:::
diff --git a/project-words.txt b/project-words.txt
index c4bc51121..bc7b551fe 100644
--- a/project-words.txt
+++ b/project-words.txt
@@ -304,6 +304,7 @@ jssdk
kaszubowski
katex
kato
+kdwx
keccak
keyfile
keyholders
@@ -423,6 +424,7 @@ nomicfoundation
nomiclabs
noninteractive
noreply
+NOTOK
nousb
npmjs
npmrc
@@ -709,6 +711,7 @@ upcheck
upgr
upserts
upvotes
+urdqt
urlset
USDL
userland
@@ -750,12 +753,15 @@ xsoar
yacop
yangshun
yangshunz
+ynnfyvwcqev
yourcode
yrbjp
Yuhu
+ywmyp
zhou
zkevm
ZKEX
+zkurvpu
zkvotev
zonic
zoomable