I would like to get the balance of a user formatted using the base unit of the Substrate chain.
When I use toHuman()
, I get an opinionated formatting which includes a prefix like so:
let account = await api.query.system.account("EGVQCe73TpFyAZx5uKfE1222XfkT3BSKozjgcqzLBnc5eYo");
account.data.free.toHuman()
2.8320 kKSM
While toNumber()
returns the value without any units at all:
account.data.free.toNumber()
2832057009447293
How do I get this value with just the base units using the Polkadot JS API?