Skip to content

Conversation

0xrusowsky
Copy link
Contributor

@0xrusowsky 0xrusowsky commented Oct 17, 2025

Motivation

towards #9840 (comment)

foundry is unable to fully support multichain deployments within a single script/run if the target chain have different EVM versions.

this is a summary of the issues/challenges that we face:

  • scripts run with a single solc & evm_version configuration. feat(cheatcodes): add setEvmVersion / getEvmVersion #12014 introduced the ability to select the evm version at runtime with setEvmVersion()
  • the runtime evm version is not enough, we also need to deploy bytecode compiled with the corresponding target version, which requires accessing the multiple artifacts at runtime

Solution

this PR introduces getProfile() cheatcodes that forwards profile metadata (artifacts path and EVM version) to the script runner, which is the last missing piece.

combined with setEvmVersion(), and deployCode() cheatcode, this enables:

  1. getProfile(): get the evm version and locate the correct artifacts directory for each chain.
  2. setEvmVersion(): switch to the required runtime environment
  3. deployCode(): deploy the bytecode of the corresponding artifacts

Implementation Details

struct ProfileMetadata {
    /// The output path of the generated artifacts.
    string artifacts;
    /// The EVM version.
    string evm;
}

/// Derives the `ProfileMetadata` from the `foundry.toml` for the active profile.
function getProfile() external returns (ProfileMetadata memory);

/// Derives the `ProfileMetadata` from the `foundry.toml` for the given profile.
/// Reverts if the profile does not exist or the path cannot be resolved.
function getProfile(string calldata profile) external returns (ProfileMetadata memory);

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Next Steps

leverage the new cheatcodes in forge-std so that users can have a smooth and safe multi-chain experience (simply by inheriting the Config abstract).

@0xrusowsky 0xrusowsky marked this pull request as ready for review October 17, 2025 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant