This documentation is structured to provide a clear overview of the supported forge commands. Each command is presented in the following format:
- Command Name: The name of the command, colored to indicate its status (green for working, red for non-working).
- Command: The full command syntax with required parameters.
- Required Parameters: Parameters that must be provided for the command to execute, as specified in the help files.
- Example: A collapsible dropdown containing the complete command with its output or error message, ensuring all relevant details are included.
This format ensures clarity and ease of navigation, with the color scheme providing an immediate visual cue for command reliability.
- If the command is not listed, it is not supported.
- If the command is listed with a red color, it is not supported.
- If the command is listed with a green color, it is supported.
-
Command:
forge init -
Example:
Click to toggle contents of example
> forge init Initializing /test... Installing forge-std in /test/lib/forge-std (url: Some("https://github.com/foundry-rs/forge-std"), tag: None) Cloning into '/test/lib/forge-std'... Installed forge-std v1.9.7 Initialized forge project
-
Command:
forge bind -
Additional Flags:
--resolc: Use the Resolc compiler.
-
Example:
Click to toggle contents of example
> forge bind --resolc Compiling 23 files with Resolc v0.2.0, Solc v0.8.30 installing solc version "0.8.30" Successfully installed solc 0.8.30 Resolc 0.2.0, Solc 0.8.30 finished in 7.22s Compiler run successful with warnings: Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdCheats.sol Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdCheats.sol Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdUtils.sol Generating bindings for 2 contracts Bindings have been generated to /test/out/bindings
-
Command:
forge bind-json -
Additional Flags:
--resolc: Use the Resolc compiler.
-
Example:
Click to toggle contents of example
> forge bind-json --resolc Compiling 24 files with Resolc v0.2.0, Solc v0.8.30 installing solc version "0.8.30" Successfully installed solc 0.8.30 Resolc 0.2.0, Solc 0.8.30 finished in 5.23s Bindings written to /test/utils/JsonBindings.sol
-
Command:
forge build -
Additional Flags:
--resolc: Use the Resolc compiler.
-
Example:
Click to toggle contents of example
> forge build --resolc Compiling 23 files with Resolc v0.2.0, Solc v0.8.30 installing solc version "0.8.30" Successfully installed solc 0.8.30 Resolc 0.2.0, Solc 0.8.30 finished in 7.22s Compiler run successful with warnings: Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdCheats.sol Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdCheats.sol Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdUtils.sol
-
Command:
forge cache clean -
Example:
Click to toggle contents of example
> forge cache clean
-
Command:
forge cache ls -
Example:
Click to toggle contents of example
> forge cache ls
-
Command:
forge clean -
Example:
Click to toggle contents of example
> forge cache clean
-
Command:
forge compiler resolve --resolc -
Example:
Click to toggle contents of example
> forge compiler resolve --resolc Solidity: - Resolc v0.2.0, Solc v0.8.30
-
Command:
forge config -
Example:
Click to toggle contents of example
> forge config
-
Command:
forge create [OPTIONS] <CONTRACT> -
Additional Flags:
--resolc: Use the Resolc compiler.
-
Required Parameters:
CONTRACT -
Example:
Click to toggle contents of example
> forge create Counter --resolc --rpc-url https://testnet-passet-hub-eth-rpc.polkadot.io --private-key 0xacef3f4d5f7c6666e927c24af52f35c45c07990d1f199cd476b0189d1029419f --broadcast --constructor-args 0 Compiling 1 files with Resolc v0.2.0, Solc v0.8.30 installing solc version "0.8.30" Successfully installed solc 0.8.30 Resolc 0.2.0, Solc 0.8.30 finished in 2.21s Compiler run successful! Deployer: 0x2a187c63c5c5212006cBB5D42CCd0BF0F67B142E Deployed to: 0xF4ed7573DA31302eCe974692e230Cc9F4D9CE18D Transaction hash: 0x4e14189ff8197e8c8c4a0e0ee3c59884b89fd7dfc1a322011506093dc546a88a
-
Command:
forge doc -
Example:
Click to toggle contents of example
> forge doc
-
Command:
forge flatten [OPTIONS] <PATH> -
Required Parameters:
PATH -
Example:
Click to toggle contents of example
> forge flatten src/Counter.sol // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.13; // src/Counter.sol contract Counter { uint256 public number; function setNumber(uint256 newNumber) public { number = newNumber; } function increment() public { number++; } }
-
Command:
forge fmt -
Example:
Click to toggle contents of example
> forge fmt
-
Command:
forge geiger <PATH> -
Required Parameters:
PATH -
Example:
Click to toggle contents of example
> forge geiger src/Counter.sol
-
Command:
forge generate test --contract-name <CONTRACT_NAME> -
Required Parameters:
CONTRACT_NAME -
Example:
Click to toggle contents of example
> forge generate test --contract-name Counter Generated test file: test/Counter.t.sol
-
Command:
forge generate-fig-spec -
Example:
Click to toggle contents of example
> forge generate-fig-spec
-
Command:
forge inspect -
Additional Flags:
--resolc: Use the Resolc compiler. When running with this flag the output for the bytecode should start with0x505.
-
Example:
Click to toggle contents of example
> forge inspect Counter bytecode --resolc
-
Command:
forge install -
Example:
Click to toggle contents of example
> forge install vectorized/solady Installing solady in /test/lib/solady (url: Some("https://github.com/vectorized/solady"), tag: None) Cloning into '/test/lib/solady'... Installed solady v0.1.19
-
Command:
forge update -
Example:
Click to toggle contents of example
> forge update vectorized/solady
-
Command:
forge remappings -
Example:
Click to toggle contents of example
> forge remappings forge-std/=lib/forge-std/src/ solady/=lib/solady/src/
-
Command:
forge remove -
Example:
Click to toggle contents of example
> forge remove solady --force Removing 'solady' in lib/solady, (url: None, tag: None)
-
Command:
forge selectors upload -
Example:
Click to toggle contents of example
> forge selectors upload --all Compiling 1 files with Resolc v0.2.0, Solc v0.8.30 installing solc version "0.8.30" Successfully installed solc 0.8.30 Resolc 0.2.0, Solc 0.8.30 finished in 6.46s Compiler run successful with warnings: Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdCheats.sol Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdCheats.sol Warning: Warning: Your code or one of its dependencies uses the 'extcodesize' instruction, which is usually needed in the following cases: 1. To detect whether an address belongs to a smart contract. 2. To detect whether the deploy code execution has finished. Polkadot comes with native account abstraction support (so smart contracts are just accounts coverned by code), and you should avoid differentiating between contracts and non-contract addresses. --> lib/forge-std/src/StdUtils.sol Uploading selectors for Counter... Duplicated: Function increment(): 0xd09de08a Duplicated: Function number(): 0x8381f58a Duplicated: Function setNumber(uint256): 0x3fb5c1cb Selectors successfully uploaded to OpenChain
-
Command:
forge selectors list -
Example:
Click to toggle contents of example
> forge selectors list Listing selectors for contracts in the project... Counter ╭----------+--------------------+------------╮ | Type | Signature | Selector | +============================================+ | Function | increment() | 0xd09de08a | |----------+--------------------+------------| | Function | number() | 0x8381f58a | |----------+--------------------+------------| | Function | setNumber(uint256) | 0x3fb5c1cb | ╰----------+--------------------+------------╯
-
Command:
forge selectors find -
Example:
Click to toggle contents of example
> forge selectors find 0xd09de08a Searching for selector "0xd09de08a" in the project... Found 1 instance(s)... ╭----------+-------------+------------+----------╮ | Type | Signature | Selector | Contract | +================================================+ | Function | increment() | 0xd09de08a | Counter | ╰----------+-------------+------------+----------╯
-
Command:
forge selectors cache -
Example:
Click to toggle contents of example
> forge selectors cache Caching selectors for contracts in the project...
-
Command:
forge tree -
Example:
Click to toggle contents of example
> forge tree
-
Command:
forge snapshot -
Additional Flags:
--resolc: Use the Resolc compiler.
-
Example:
Click to toggle contents of example
> forge snapshot --resolc
-
Command:
forge test -
Example:
Click to toggle contents of example
> forge test
-
Command:
forge clone -
Example:
Click to toggle contents of example
> forge clone
-
Command:
forge coverage -
Additional Flags:
--resolc: Use the Resolc compiler.
-
Example:
Click to toggle contents of example
> forge coverage