Balance -> u64
let value :Option = TryInto::::try_into(balance).ok();
u64-> Balance
let balance :Option<T::Balance> = value.try_into().ok();
BlockNumber -> u32
let number : Option = TryInto::::try_into(block_number);
u32 -> BlockNumber
let block_number :T::BlockNumber = value.into();
或者用saturated_into() 转换
let number: u128 = block_number.saturated_into();
let value :u64 = balance.saturated_into();
not_std 下数字转hex字符串,调用转换 sp_std::str::from_utf8(&result_bytes)
pub fn u64_to_hex_bytes(data:u64)->Vec<u8>{
let mut data_bytes = data.to_ne_bytes();
data_bytes.reverse();
let start = "0x".as_bytes();
let hex_str = hex::encode(data_bytes);
let hex_str = hex_str.trim_start_matches("0").as_bytes();
[start,hex_str].concat().to_vec()
}
ss58格式字符串地址-> T::AccountId
<