Skip to content

Comments

Add CAP-0082 - checked 256-bit integer arithmetic#1887

Merged
leighmcculloch merged 3 commits intostellar:masterfrom
jayz22:cap-82
Feb 24, 2026
Merged

Add CAP-0082 - checked 256-bit integer arithmetic#1887
leighmcculloch merged 3 commits intostellar:masterfrom
jayz22:cap-82

Conversation

@jayz22
Copy link
Contributor

@jayz22 jayz22 commented Feb 24, 2026

@jayz22 jayz22 changed the title Add CAP-0082 - checked 256 integer arithmetic Add CAP-0082 - checked 256-bit integer arithmetic Feb 24, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces CAP-0082, which proposes adding checked variants of the existing 256-bit integer arithmetic host functions in the Soroban smart contract environment. The CAP addresses a limitation where the current arithmetic functions trap on overflow, preventing contracts from gracefully handling arithmetic errors that are common in financial mathematics. The proposal adds eight new host functions that return Void on overflow instead of trapping, following the pattern of Rust's checked_* methods.

Changes:

  • Adds CAP-0082 specification document proposing eight new checked arithmetic host functions for 256-bit integers
  • Functions cover addition, subtraction, multiplication, and exponentiation for both unsigned (U256) and signed (I256) types
  • Functions return Val (either the result or Void on overflow) instead of trapping, enabling graceful error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

Some clarification is needed inline in the env.json. See inline comment.

Can you update the readme as well?

Looks great otherwise 👍🏻

@jayz22
Copy link
Contributor Author

jayz22 commented Feb 24, 2026

Some clarification is needed inline in the env.json. See inline comment.

Can you update the readme as well?

Looks great otherwise 👍🏻

done!

@leighmcculloch leighmcculloch enabled auto-merge (squash) February 24, 2026 23:55
@leighmcculloch leighmcculloch merged commit d6f137e into stellar:master Feb 24, 2026
5 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