foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.05k stars 1.65k forks source link

Allow passing arguments to `cast {call,send}` through `stdin` #7890

Open guidanoli opened 3 months ago

guidanoli commented 3 months ago

Component

Cast

Describe the feature you would like

There are several cast commands which can potentially receive lengthy arguments. Those are often limited by the underlying host OS to a couple of kilobytes, which, in some situations, might not be enough.

One alternative is to receive such arguments via stdin. It can be formatted as JSON, which is a format already in use for the output of some cast commands. For example:

cast call $to 'func(uint256,address,bytes)' < arguments.json

Where arguments.json might have the following data:

[
  "42",
  "0x41b1a0649752af1b28b3dc29a1556eee781e4a4c",
  "0x9f24c52e0fcd1ac696d00405c3bd5adc558c48936919ac5ab3718fcb7d70f93f..."
]

Alternatively, arguments can be separated line-by-line...

cast call $to 'func(uint256,address,bytes)' < arguments.txt

Where arguments.txt might have the following data:

42
0x41b1a0649752af1b28b3dc29a1556eee781e4a4c
0x9f24c52e0fcd1ac696d00405c3bd5adc558c48936919ac5ab3718fcb7d70f93f...

Additional context

This stemmed from an application I'm developing, called Bugless. We were using go-ethereum to sign transactions to anvil, but then we changed the underlying framework, and opted to sign transactions with cast instead. The problem is that some transactions can be quite big, and cast doesn't work because of the argument size limit imposed by the underlying OS, Linux. If cast doesn't implement a workaround, we might rewrite our CLI tool using viem.

guidanoli commented 3 months ago

If stdin is a bad idea, an option like --arguments <argument-file> would also work.

zerosnacks commented 1 month ago

Related: https://github.com/foundry-rs/foundry/issues/5069