Skip to content

feat: support decimal calldata values and prefixes (u256:, str:)#29

Merged
broody merged 2 commits intomainfrom
fix/calldata-decimal-support
Feb 12, 2026
Merged

feat: support decimal calldata values and prefixes (u256:, str:)#29
broody merged 2 commits intomainfrom
fix/calldata-decimal-support

Conversation

@broodling-bot
Copy link
Collaborator

@broodling-bot broodling-bot commented Feb 12, 2026

Previously, calldata values had to be in hex format (0x...). This change allows users to specify calldata as either hex, decimal, or use special prefixes for common types.

New Features

Prefix Support

Prefix Example Output Use Case
u256: u256:1000000000000000000 [low, high] Token amounts - auto-splits into low/high 128-bit felts
str: str:hello [felt] Cairo short strings
(none) 0x123 or 1000 [felt] Hex or decimal felt (existing behavior enhanced)

Examples

Transfer 1 STRK without manual splitting:

controller execute 0x... transfer "0xrecipient,u256:1000000000000000000"

Use short strings:

controller execute 0x... set_name "str:myname"

Mixed calldata:

controller execute 0x... transfer "0xrecipient,u256:1000000,str:memo,0x999"

Changes

  • Add parse_calldata_value() function to handle special prefixes
  • Update execute.rs and call.rs to use the new parser
  • Support both hex (0x...) and decimal formats for all numeric inputs
  • Handle uppercase 0X prefix (normalize to lowercase)

Testing

  • All existing tests pass
  • 5 new tests for u256 parsing (decimal, hex, large values with high/low parts)
  • 2 new tests for str parsing (short string, empty)
  • cargo clippy -- -D warnings clean

Breaking Changes

None. All existing hex-only calldata continues to work.

Future Extensions

Could add more prefixes following starkli patterns:

  • selector: - auto-convert function name to selector
  • addr: - address book resolution
  • storage: - storage variable address calculation

@broodling-bot broodling-bot force-pushed the fix/calldata-decimal-support branch 4 times, most recently from 5a5e20e to 3629ee2 Compare February 12, 2026 04:36
@broodling-bot broodling-bot changed the title feat: support decimal calldata values in execute and call commands feat: support decimal calldata values and prefixes (u256:, str:) Feb 12, 2026
Previously, calldata values had to be in hex format (0x...). This change
allows users to specify calldata as either hex (with 0x prefix) or decimal
numbers.

Examples that now work:
  --calldata "0x123,0x456"     # hex (existing behavior)
  --calldata "1000000,200"    # decimal (new)
  --calldata "0xDE0B6B3A7640000,100"  # mixed

Changes:
- Add parse_felt() helper function to parse hex or decimal strings
- Update execute.rs to use parse_felt() for calldata parsing
- Update call.rs to use parse_felt() for calldata parsing

Fixes paymaster overflow errors when using decimal amounts like
1000000000000000000 instead of 0xDE0B6B3A7640000
@broodling-bot broodling-bot force-pushed the fix/calldata-decimal-support branch from 3629ee2 to c793e84 Compare February 12, 2026 04:40
Extract duplicate parse_calldata_value from execute.rs and call.rs into
shared calldata module. Update README, LLM_USAGE.md, and skill files to
document u256:, str:, and decimal calldata formats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@broody broody force-pushed the fix/calldata-decimal-support branch from ca9919c to 258ea77 Compare February 12, 2026 05:03
@broody broody merged commit e66297e into main Feb 12, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants