Closed lucasoares closed 7 months ago
let's refer to the documentation of solana RPC.
amount: <string>
- the raw balance without decimals, a string representation of u64
decimals: <u8>
- number of base 10 digits to the right of the decimal placeuiAmount: <number|null>
- the balance, using mint-prescribed decimals DEPRECATEDuiAmountString: <string>
- the balance as a string, using mint-prescribed decimalsI'd recommend parsing amount
and using decimals
for your internal calculations
to achieve this bin
is not mandatory. Just use stdlib
// to uint64
amnt, err := strconv.ParseUint(amount, 10, 64)
// or to *big.Int
amnt, ok := new(big.Int).SetString(amount, 10)
What is the reason the
UiAmount *float64
is deprecated? I saw the blame information and apparently, the UiAmount was previously of the type*bin.JSONFloat64
.I don't know which field is reliable and when I should use each one of them... And if I use the string type, should I use a type from
bin
library to parse it?