foundry
                                
                                 foundry copied to clipboard
                                
                                    foundry copied to clipboard
                            
                            
                            
                        cast call returns integers in scientific notation
Component
Cast
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
cast 0.2.0 (53b15e6 2023-12-14T00:16:29.514805588Z)
What command(s) is the bug in?
cast call
Operating System
Linux
Describe the bug
cast call --rpc-url $ALCHEMY_URL  0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 'balanceOf(address) returns(uint256)' 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
78077338549235265036291 [7.807e22]
The returned numeric output of cast call includes the values in scientific notation. I'm not sure when this change in behavior occurred, but the previous versions of cast didn't do this. This breaks scripts that expect a certain format. The old behavior was something like this:
cast call --rpc-url $ALCHEMY_URL  0x1f9840a85d5af5bf1d1762f925bdaddc4201f984 'balanceOf(address) returns(uint256)' 0x1f9840a85d5af5bf1d1762f925bdaddc4201f984
78077338549235265036291
I just git hit by this too. I worked it around by adding  | cut -f 1 -d " " to every cast call in the script.
The scientific notion doesn't show up for small numbers, so it's not consistent. A script that doesn't expect that may crash only when specific data is returned, which may happen after executing many expensive operations or operations that need a closure.
I think adding the scientific notation output was a breaking change? I don't remember that always being there. If so, that does break cast integrations and usage in scripts. I think we should revert the default to what it used to be to preserve integrations, and have a --verbose/-v flag which adds the scientific notation, or use --pretty which is consistent with forge inspect
Almost certainly a breaking change. I, like @CodeSandwich, am just using trivial unix commands to slice the output but would prefer it be opt-in given the inconsistency
Should we close this issue as a duplicate of https://github.com/foundry-rs/foundry/issues/6600?
Duplicate of #6600