diff --git a/docs/build/test-and-debug/foundry.md b/docs/build/test-and-debug/foundry.md index 2399902249..9dc3e07003 100644 --- a/docs/build/test-and-debug/foundry.md +++ b/docs/build/test-and-debug/foundry.md @@ -11,7 +11,7 @@ For instructions on how to install `foundry-zksync` please refer to the [Getting ## Overview -`foundry-zksync`, a fork of Foundry, provides developers with a tailored testing framework designed specifically for zkSync environments. Utilizing `zkforge test`, you can execute your smart contract tests efficiently. Tests are written in Solidity, and the framework is designed to recognize any contract function prefixed with `test` as a test case. By convention, tests are typically stored within the `test/` directory and have a `.t.sol` extension. +`foundry-zksync`, a fork of Foundry, provides developers with a tailored testing framework designed specifically for zkSync environments. Utilizing `forge test --zksync`, you can execute your smart contract tests efficiently. Tests are written in Solidity, and the framework is designed to recognize any contract function prefixed with `test` as a test case. By convention, tests are typically stored within the `test/` directory and have a `.t.sol` extension. :::info For more detailed documentation related to Foundry testing please refer to the official upstream Foundry documentation [here](https://book.getfoundry.sh/forge/tests). @@ -19,10 +19,10 @@ For more detailed documentation related to Foundry testing please refer to the o ## Running Tests -To initiate your tests, use the `zkforge test` command. This command automatically locates and executes tests across your source directory. Here's an example of executing tests in a standard project setup: +To initiate your tests, use the `forge test --zksync` command with the `--zksync` flag, or incorporate `vm.zkVm(true)` within your tests. This command automatically locates and executes tests across your source directory. Here's an example of executing tests in a standard project setup: ```bash -zkforge test +forge test --zksync Running 2 tests for test/Counter.t.sol:CounterTest [PASS] testFuzz_SetNumber(uint256) (runs: 256, μ: 27553, ~: 28409) @@ -35,7 +35,7 @@ Test result: ok. 2 passed; 0 failed; 0 skipped; finished in 96.80ms You can run specific tests by filtering based on the contract or test names: ```bash -zkforge test --match-contract CounterTest --match-test test_Increment +forge test --match-contract CounterTest --match-test test_Increment --zksync ``` This command will execute only the tests within `CounterTest` that include `test_Increment` in their name. @@ -43,14 +43,14 @@ This command will execute only the tests within `CounterTest` that include `test Similarly, you can use `--match-path` to run tests in files that match a specific glob pattern: ```bash -zkforge test --match-path Counter.t.sol +forge test --match-path test/Counter.t.sol --zksync ``` Inverse filters are available through `--no-match-contract`, `--no-match-test`, and `--no-match-path` flags. ## Watch Mode -To automatically re-run tests upon any file changes, use the `zkforge test --watch --run-all` command. +To automatically re-run tests upon any file changes, use the `forge test --watch --run-all --zksync` command. ## Writing Tests diff --git a/docs/build/tooling/foundry/getting-started.md b/docs/build/tooling/foundry/getting-started.md index 83887ec3f0..4b8783a9fd 100644 --- a/docs/build/tooling/foundry/getting-started.md +++ b/docs/build/tooling/foundry/getting-started.md @@ -24,21 +24,21 @@ To integrate `foundry-zksync` into your projects, you have the flexibility to in 2. Navigate to the project directory and switch to the main branch: ```bash - cd foundry-zksync && git checkout main + cd foundry-zksync && git checkout dev ``` For component-specific installations: -- **zkForge**: To install, execute: +- **Forge**: To install, execute: ```bash - cargo install --path ./crates/zkforge --profile local --force --locked + cargo install --path ./crates/forge --profile local --force --locked ``` -- **zkCast**: To install, run: +- **Cast**: To install, run: ```bash - cargo install --path ./crates/zkcast --profile local --force --locked + cargo install --path ./crates/cast --profile local --force --locked ``` For the entire suite: @@ -55,7 +55,7 @@ Choose the installation that best fits your development needs. ### Initial Setup -After installation, initialize a new project with `zkforge init `, which sets up the basic structure of a new Foundry project. +After installation, initialize a new project with `forge init `, which sets up the basic structure of a new Foundry project. ### Project Configuration using `foundry.toml` @@ -65,11 +65,11 @@ Configuration can be arbitrarily namespaced by profiles. The default profile is You can select another profile using the `FOUNDRY_PROFILE` environment variable. You can also override parts of your configuration using `FOUNDRY_` or `DAPP_` prefixed environment variables, like `FOUNDRY_SRC`. -`zkforge init` creates a basic, extendable `foundry.toml` file. +`forge init` creates a basic, extendable `foundry.toml` file. -To see your current configuration, run `zkforge config`. To see only basic options (as set with `zkforge init`), run `zkforge config --basic`. This can be used to create a new `foundry.toml` file with `zkforge config --basic > foundry.toml`. +To see your current configuration, run `forge config`. To see only basic options (as set with `forge init`), run `forge config --basic`. This can be used to create a new `foundry.toml` file with `forge config --basic > foundry.toml`. -By default `zkforge config` shows the currently selected foundry profile and its values. It also accepts the same arguments as `zkforge build`. An example `foundry.toml` for zkSync with zksolc configurations may look like: +By default `forge config` shows the currently selected foundry profile and its values. It also accepts the same arguments as `forge build`. An example `foundry.toml` for zkSync with zksolc configurations may look like: ``` [profile.default] @@ -81,7 +81,7 @@ libs = ['lib'] src = 'src' libs = ['lib'] fallback_oz = true -is_system = true +is_system = false mode = "3" ``` @@ -89,18 +89,18 @@ mode = "3" ### Running Tests -Use `zkforge test` to run tests written for your smart contracts. For an overview of how to write tests using `Foundry-zksync` please refer to Foundry testing [here](../../test-and-debug/foundry.md). +Use `forge test --zksync` to run tests written for your smart contracts. For an overview of how to write tests using `foundry-zksync` please refer to Foundry testing [here](../../test-and-debug/foundry.md). -## Deploying Smart Contracts with `zkforge` +## Deploying Smart Contracts with `forge` -### Compilation with `zkforge zk-build` +### Compilation with `forge build --zksync` -`zkforge zkbuild` (also accessible via aliases like `zkforge zk-build`, `zkforge zk-compile`, `zkforge zkb`) is used for compiling smart contracts into zkEVM bytecode. The compiled files are stored in a structured directory at `/zkout/`. +`forge build --zksync` is used for compiling smart contracts into zkEVM bytecode. The compiled files are stored in a structured directory at `/zkout/`. **Usage:** ```sh -zkforge zkbuild [OPTIONS] +forge build [OPTIONS] --zksync ``` **Key Compiler Options:** @@ -117,20 +117,17 @@ zkforge zkbuild [OPTIONS] Compile with default settings or specify `zksolc` version: ```sh -zkforge zkbuild - -# specifying zksolc version -zkforge zkbuild --use-zksolc v1.3.19 +forge build --zksync ``` -### Deployment with `zkforge zk-create` +### Deployment with `forge create --zksync` -`zkforge zkcreate` (and its aliases `zkforge zk-create`, `zkforge zk-deploy`, `zkforge zkc`) deploys smart contracts to zkSync. +`forge create --zksync` deploys smart contracts to zkSync. **Usage:** ```sh -zkforge zkcreate [OPTIONS] --rpc-url --chain --private-key +forge create [OPTIONS] --rpc-url --chain --private-key --zksync ``` **Options:** @@ -170,7 +167,7 @@ contract Greeter { ```bash -zkforge zkcreate src/Greeter.sol:Greeter --constructor-args "Hello zkSync" --private-key --rpc-url https://sepolia.era.zksync.dev --chain 300 +forge create src/Greeter.sol:Greeter --constructor-args "Hello zkSync" --private-key --rpc-url https://sepolia.era.zksync.dev --chain 300 --zksync ``` ### Deploying Factory Contracts @@ -209,25 +206,25 @@ contract Factory { **Compile `GreeterFactory.sol`:** ```bash -zkforge zkbuild --is-system=true +forge build --is-system=true --zksync ``` **Deploy `GreeterFactory.sol`:** ```sh -zkforge zkcreate src/GreeterFactory.sol:Factory --factory-deps src/Greeter.sol:Greeter --private-key --rpc-url https://sepolia.era.zksync.dev --chain 300 +forge create src/GreeterFactory.sol:Factory --factory-deps src/Greeter.sol:Greeter --private-key --rpc-url https://sepolia.era.zksync.dev --chain 300 --zksync ``` **Deploy `Greeter.sol` via `GreeterFactory.sol`:** ```sh -zkcast zk-send "CreateNewGreeter(string)" "zkSync Rules" --private-key --rpc-url https://sepolia.era.zksync.dev --chain 300 +cast send "CreateNewGreeter(string)" "zkSync Rules" --private-key --rpc-url https://sepolia.era.zksync.dev --chain 300 ``` **Interact with `Greeter.sol`** ```sh -zkcast call "greet()(string)" --rpc-url https://sepolia.era.zksync.dev --chain 300 +cast call "greet()(string)" --rpc-url https://sepolia.era.zksync.dev --chain 300 ``` **Output:** @@ -239,7 +236,7 @@ zkcast call "greet()(string)" --rpc-url https://sepolia.era.z **To decode the output to a readable string:** ```sh -zkcast to-ascii 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c7a6b53796e632052756c65730000000000000000000000000000000000000000 +cast to-ascii 0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000c7a6b53796e632052756c65730000000000000000000000000000000000000000 ``` **Output:** @@ -248,11 +245,11 @@ zkcast to-ascii 0x0000000000000000000000000000000000000000000000000000000000000 zkSync Rules ``` -## Basic zkSync Chain Interactions with `zkcast` +## Basic zkSync Chain Interactions with `cast` ### Introduction -This guide introduces you to fundamental interactions within the zkSync chain using `zkcast`, a component of the `foundry-zksync` toolkit. Learn how to query chain IDs, retrieve client versions, check L2 ETH balances, obtain gas prices, and more. +This guide introduces you to fundamental interactions within the zkSync chain using `cast`, a component of the `foundry-zksync` toolkit. Learn how to query chain IDs, retrieve client versions, check L2 ETH balances, obtain gas prices, and more. ### Chain ID Retrieval @@ -261,7 +258,7 @@ This guide introduces you to fundamental interactions within the zkSync chain us Retrieve the Chain ID for a local zkSync node with: ```sh - zkcast chain-id --rpc-url http://localhost:3050 + cast chain-id --rpc-url http://localhost:3050 ``` Expected Output: `270`, indicating the Chain ID of your local zkSync node. @@ -271,7 +268,7 @@ This guide introduces you to fundamental interactions within the zkSync chain us For the zkSync Sepolia Testnet, use: ```sh - zkcast chain-id --rpc-url https://sepolia.era.zksync.dev + cast chain-id --rpc-url https://sepolia.era.zksync.dev ``` Expected Output: `300`, the Chain ID for the zkSync Sepolia Testnet. @@ -281,7 +278,7 @@ This guide introduces you to fundamental interactions within the zkSync chain us Knowing the client version is vital for compatibility checks and debugging: ```sh -zkcast client --rpc-url https://sepolia.era.zksync.dev +cast client --rpc-url https://sepolia.era.zksync.dev ``` Expected Output: `zkSync/v2.0`, denoting the client version. @@ -291,7 +288,7 @@ Expected Output: `zkSync/v2.0`, denoting the client version. Verify the Layer 2 (L2) balance of an account: ```sh -zkcast balance 0x8b1d48a69ACEbC6eb201e2F4d162A002203Bfe8E --rpc-url https://sepolia.era.zksync.dev +cast balance 0x8b1d48a69ACEbC6eb201e2F4d162A002203Bfe8E --rpc-url https://sepolia.era.zksync.dev ``` Expected Output: A numerical value, e.g., `774909739323110932`, representing the account's L2 balance. @@ -301,7 +298,7 @@ Expected Output: A numerical value, e.g., `774909739323110932`, representing the Fetch the current gas price on the network for transaction cost estimations: ```sh -zkcast gas-price --rpc-url https://sepolia.era.zksync.dev +cast gas-price --rpc-url https://sepolia.era.zksync.dev ``` Expected Output: A value such as `100000000`, indicating the current gas price. @@ -311,57 +308,23 @@ Expected Output: A value such as `100000000`, indicating the current gas price. Gain insights into the latest block on the zkSync chain: ```sh -zkcast block latest --rpc-url https://sepolia.era.zksync.dev +cast block latest --rpc-url https://sepolia.era.zksync.dev ``` Expected Output: Detailed information about the latest block, including base fee per gas, gas limit, block hash, and more. ### Sending Transactions -Initiate transactions, such as contract function calls, using `zkcast`: +Initiate transactions, such as contract function calls, using `cast`: ```sh -zkcast zk-send --rpc-url --private-key --chain +cast send --rpc-url --private-key --chain ``` Example: ```sh -zkcast zk-send 0x97b985951fd3e0c1d996421cc783d46c12d00082 "setGreeting(string)" "Hello, zkSync!" --rpc-url http://localhost:3050 --private-key --chain 270 +cast send 0xe34E488C1B0Fb372Cc4a5d39219261A5a6fc7996 "setGreeting(string)" "Hello, zkSync!" --rpc-url https://sepolia.era.zksync.dev --private-key --chain 300 ``` This command calls the `setGreeting` function of a contract, updating the greeting to "Hello, zkSync!". Replace `` with your actual private key. - -### Bridging Assets Between L1 and L2 - -#### L1 to L2 Deposits - -Deposit assets from Layer 1 (Ethereum) to Layer 2 (zkSync): - -```sh -zkcast zk-deposit --l1-rpc-url --l2-url --chain --private-key -``` - -Note: For ETH deposits, leave the `` parameter empty. - -Example (Depositing ETH): - -```sh -zkcast zk-deposit 0x36615Cf349d7F6344891B1e7CA7C72883F5dc049 1 ether --l1-rpc-url http://localhost:8545 --l2-url http://localhost:3050 --private-key --chain 270 -``` - -#### L2 to L1 Withdrawals - -Withdraw assets from Layer 2 back to Layer 1: - -```sh -zkcast zk-send --withdraw --amount --rpc-url --private-key --chain -``` - -Example (Withdrawing ETH): - -```sh -zkcast zk-send --withdraw 0x36615Cf349d7F6344891B1e7CA7C728 - -83F5dc049 --amount 1 ether --rpc-url http://localhost:3050 --private-key --chain 270 -``` diff --git a/docs/build/tooling/foundry/overview.md b/docs/build/tooling/foundry/overview.md index 01fa85279c..8f4946eee7 100644 --- a/docs/build/tooling/foundry/overview.md +++ b/docs/build/tooling/foundry/overview.md @@ -9,7 +9,7 @@ head: ## Overview -`foundry-zksync` is a specialized fork of [Foundry](https://github.com/foundry-rs/foundry), tailored for zkSync. It extends Foundry's capabilities for Ethereum app development to support zkSync, allowing for the compilation, deployment, testing, and interaction with smart contracts on zkSync. `foundry-zksync` introduces `zkforge` and `zkcast` extensions of Foundry's existing `forge` and `cast` tools but tailored for zkSync usage. +`foundry-zksync` is a specialized fork of [Foundry](https://github.com/foundry-rs/foundry), tailored for zkSync. It extends Foundry's capabilities for Ethereum app development to support zkSync, allowing for the compilation, deployment, testing, and interaction with smart contracts on zkSync. `foundry-zksync` introduces `--zksync` flag, or the use of `vm.zkVm(true)` to target the zkSync VM. ### Status and Contribution @@ -36,7 +36,6 @@ head: While `foundry-zksync` is **alpha stage**, there are some limitations to be aware of, but not limited to: -- **Cheat Codes Support**: Not all cheat codes are fully supported. [View the list of supported cheat codes](https://github.com/matter-labs/foundry-zksync/blob/main/SUPPORTED_CHEATCODES.md). - **Compile Time**: Some users may experience slow compiling. - **Specific Foundry Features**: Currently features such as `coverage`, `--gas-report` or `--verify` may not work as intended. We are actively working on providing support for these feature types. - **Compiling Libraries**: Compiling non-inlinable libraries requires deployment and adding to configuration. For more information please refer to [official docs](https://era.zksync.io/docs/tools/hardhat/compiling-libraries.html).