Skip to main content

Stroops and USDC Precision

USDC on Stellar uses 7 decimal places. The smallest unit is called a stroop:
All on-chain amounts are stored and transmitted as stroops represented by bigint values. The SDK provides two helper functions to convert between human-readable strings and stroops.
Why stroops? Floating-point arithmetic introduces rounding errors that are unacceptable for financial transactions. By using integer math with bigint, every calculation is exact - no precision loss, no rounding surprises.

toStroops

Converts a human-readable amount string to a bigint in stroops.
Signature:
Returns: bigint - The amount in stroops.

fromStroops

Converts a bigint in stroops back to a human-readable string.
Signature:
Returns: string - Human-readable decimal string.

Conversion Table


Constants

The SDK exports several constants for common values:
These time constants are the same values used by the Vowena smart contract. Use them when setting period and gracePeriod in buildCreatePlan() to stay consistent with on-chain conventions.

Examples

Creating a Plan with Correct Amounts

Displaying a Subscription Price