Skip to content

Specify maximum USD amount to spend on multichain scripts #11502

@legion2002

Description

@legion2002

Component

Forge

Describe the feature you would like

Use Case

Currently, when you run forge script with --broadcast, it executes the scripts with the current gas values if no other flag is provided and you have enough funds in your account.

Sometimes on expensive chains like Ethereum Mainnet, this can lead to a loss of funds because of temporary gas spikes. Gas can spike to 100 or 1000x the normal prices, which can lead to thousands of dollars of funds being lost, if the script is run at the wrong time.

Current Alternatives

  1. You can also run the script with exact gas parameters every time. But this doesn't work well for mutlichain scripts, because all chains have different gas numbers. It is also cumbersome, because manually choosing the right gas numbers is slow, and can lead to stuck transactions.

  2. Dry run the script before running it, if the displayed gas costs are too high, run the script later. This is fine, but it requires manual human intervention. Also all prices are displayed in gwei or wei, it is hard to understand the actual dollar cost of the deployments given current gas and eth prices.

Request

Add a chain specific configuration variable in the foundry.toml, that stops the script from running, if the total calculated gas amount is more than X Eth.

An addition to this could be that we also allow the user to specify this in USD, and foundry automatically converts the ETH price to USD using some free pricing API.

Rationale is that many times people running the scripts are not familiar with the intricacies of each blockchain, giving them a solid max USD/ETH deployment cost will enable them to make better decision when to deploy.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-featureType: featureT-needs-triageType: this issue needs to be labelled

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions