Skip to main content

format_trx

Function format_trx 

Source
pub fn format_trx(amount: Trx) -> String
Expand description

Format a Trx amount as a decimal string with exactly 6 fractional digits.

Free-function alias for Trx’s Display, mirroring alloy’s format_ether. The conversion is exact — no f64 is involved — matching format_units.

use tronz_primitives::{Trx, format_trx};

assert_eq!(format_trx(Trx::from_sun(1_500_000).unwrap()), "1.500000");
assert_eq!(format_trx(Trx::from_sun(1).unwrap()), "0.000001");
assert_eq!("100".parse::<Trx>().unwrap().to_string(), "100.000000");