foundry-rs / foundry-rs/foundry

feat(`forge script`): allow specifying maximum USD amount to spend on (multichain) scripts

Open
#11,502 3 comments 1 reaction 0 assignees View on GitHub
Cmd-forge-script T-feature T-to-discuss
Dominant language
Rust
Stars
10.6k
Forks
2.6k
Avg merge
18h 20m
Merged PRs (30d)
510

Description

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.