convert-units

Convert between XNO units (raw/xno/knano/mnano) with exact BigInt precision.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "convert-units" with this command: npx skills add casualsecurityinc/xno-skills/casualsecurityinc-xno-skills-convert-units

Convert XNO Units

Convert between different XNO cryptocurrency units with BigInt precision. XNO uses 30 decimal places, making floating-point arithmetic unsafe. Always use this skill for accurate conversions.

Unit Reference

UnitRaw ValueDecimal PlacesDescription
raw10Smallest unit (base unit)
mnano10^2424Mega-nano (0.000001 XNO)
knano10^2727Kilonano (0.001 XNO)
XNO10^3030Base unit (1 XNO)

Conversion Factors

1 XNO    = 1,000 knano = 1,000,000 mnano = 10^30 raw
1 knano  = 1,000 mnano = 10^27 raw
1 mnano  = 10^24 raw

CLI Usage

Basic Syntax

npx xno-skills convert <amount> <from-unit> --to <to-unit>

Examples

Convert XNO to raw

npx xno-skills convert 1 XNO --to raw
# Output: 1000000000000000000000000000000

npx xno-skills convert 0.5 XNO --to raw
# Output: 500000000000000000000000000000

Convert raw to XNO

npx xno-skills convert 1000000000000000000000000000000 raw --to XNO
# Output: 1

npx xno-skills convert 500000000000000000000000000000 raw --to XNO
# Output: 0.5

Convert XNO to knano

npx xno-skills convert 1 XNO --to knano
# Output: 1000

npx xno-skills convert 0.001 XNO --to knano
# Output: 1

Convert knano to XNO

npx xno-skills convert 1000 knano --to XNO
# Output: 1

npx xno-skills convert 1 knano --to XNO
# Output: 0.001

Convert XNO to mnano

npx xno-skills convert 1 XNO --to mnano
# Output: 1000000

npx xno-skills convert 0.000001 XNO --to mnano
# Output: 1

Convert mnano to XNO

npx xno-skills convert 1000000 mnano --to XNO
# Output: 1

npx xno-skills convert 1 mnano --to XNO
# Output: 0.000001

Convert between knano and mnano

npx xno-skills convert 1000 knano --to mnano
# Output: 1000000

npx xno-skills convert 1 mnano --to knano
# Output: 0.001

Precision Handling

Why BigInt?

XNO uses 30 decimal places, which exceeds JavaScript's safe integer limit (15-17 digits). Floating-point arithmetic causes precision loss:

// WRONG - Floating point loses precision
const wrong = 0.1 + 0.2; // 0.30000000000000004

// RIGHT - BigInt maintains precision
const correct = BigInt("1000000000000000000000000000000");

Implementation Notes

  1. All conversions use BigInt internally - No floating-point operations
  2. Input parsing - Decimal strings converted to BigInt raw units
  3. Output formatting - BigInt raw units converted to requested unit
  4. No precision loss - Exact conversions for any amount

Common Precision Pitfalls

// DON'T use Number for XNO amounts
const wrong = 1.5; // Loses precision at 30 decimals

// DO use string input for CLI
// npx xno-skills convert "1.5" XNO --to raw

Common Use Cases

Wallet Balance Display

# Convert raw balance to human-readable XNO
npx xno-skills convert 500000000000000000000000000000 raw --to XNO
# Output: 0.5

# Convert to knano for smaller display
npx xno-skills convert 500000000000000000000000000000 raw --to knano
# Output: 500

Transaction Amounts

# Send 0.001 XNO
npx xno-skills convert 0.001 XNO --to raw
# Output: 1000000000000000000000000000

# Send 1 knano
npx xno-skills convert 1 knano --to raw
# Output: 1000000000000000000000000000

Fee Calculations

# Calculate fee in raw (e.g., 0.000001 XNO fee)
npx xno-skills convert 0.000001 XNO --to raw
# Output: 1000000000000000000000000

# Convert fee to mnano
npx xno-skills convert 0.000001 XNO --to mnano
# Output: 1

Large Amounts

# Convert 1 million XNO to raw
npx xno-skills convert 1000000 XNO --to raw
# Output: 1000000000000000000000000000000000000

# Convert large raw amount to XNO
npx xno-skills convert 1000000000000000000000000000000000000 raw --to XNO
# Output: 1000000

Validation

Input Validation

  • Amount must be a valid number (integer or decimal)
  • Unit must be one of: raw, XNO, knano, mnano
  • Negative amounts are supported

Error Handling

# Invalid unit
npx xno-skills convert 1 XNO --to bitcoin
# Error: Unknown unit 'bitcoin'. Valid units: raw, XNO, knano, mnano

# Invalid amount
npx xno-skills convert abc XNO --to raw
# Error: Invalid amount 'abc'. Must be a valid number.

Quick Reference

# Most common conversions
npx xno-skills convert 1 XNO --to raw          # 10^30 raw
npx xno-skills convert 1 XNO --to knano        # 1000 knano
npx xno-skills convert 1 XNO --to mnano        # 1000000 mnano
npx xno-skills convert 1 knano --to XNO        # 0.001 XNO
npx xno-skills convert 1 mnano --to XNO        # 0.000001 XNO
npx xno-skills convert 1 raw --to XNO          # 0.000000000000000000000000000001 XNO

Related Skills

  • create-wallet - Generate XNO wallet with seed phrase
  • validate-address - Validate XNO addresses (BIP-44, legacy)

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Security

create-wallet

No summary provided by upstream source.

Repository SourceNeeds Review
Security

nano wallet operations

No summary provided by upstream source.

Repository SourceNeeds Review
Security

generate nano qr code

No summary provided by upstream source.

Repository SourceNeeds Review
Security

validate-address

No summary provided by upstream source.

Repository SourceNeeds Review