17 units decimals
Overview
The Challenge
Solution: Fixed-Point Units
Concept
UNIT Selection
Option 1: UNIT = 1e6 (Recommended)
Option 2: UNIT = 1e18 (Maximum Precision)
Implementation
Contract Definition
Conversion Functions
To On-Chain (Tons → Units)
From On-Chain (Units → Tons)
UI Display
Example: Complete Flow
Project Setup
Credit Issuance
Retail Purchase
Enterprise Purchase
Retirement
Precision Considerations
Rounding
Maximum Values
Common Patterns
Check Balance
Validate Purchase Amount
Calculate Total Price
Best Practices
Last updated