Skip to content

fix: accept 0x-prefixed value inputs#14406

Merged
zerosnacks merged 3 commits intofoundry-rs:masterfrom
figtracer:fix/cast-value-hex-prefix
Apr 22, 2026
Merged

fix: accept 0x-prefixed value inputs#14406
zerosnacks merged 3 commits intofoundry-rs:masterfrom
figtracer:fix/cast-value-hex-prefix

Conversation

@figtracer
Copy link
Copy Markdown
Collaborator

@figtracer figtracer commented Apr 22, 2026

Fixes #14403.

Summary

Fix parse_ether_value and parse_ether_or_wei to correctly handle 0x-prefixed hex strings (e.g. --value 0x12).

Problem

cast call --value 0x12 ...
error: invalid value '0x12' for '--value <VALUE>': digit 33 is out of range for base 16

The previous code passed the full 0x-prefixed string to U256::from_str_radix(value, 16), which treats the x as an invalid hex digit.

Fix

Use U256::from_str(value) which natively handles the 0x/0X prefix — it strips the prefix and delegates to from_str_radix with base 16 internally.

Also adds 0X prefix support and expands regression tests to cover hex, decimal, and ether-tagged values.

mablr
mablr previously approved these changes Apr 22, 2026
Copy link
Copy Markdown
Collaborator

@mablr mablr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm

@zerosnacks zerosnacks enabled auto-merge (squash) April 22, 2026 09:22
@zerosnacks zerosnacks merged commit 5e497f5 into foundry-rs:master Apr 22, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Foundry Apr 22, 2026
@figtracer figtracer deleted the fix/cast-value-hex-prefix branch April 22, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

cast call can not parse --value correctly

3 participants