wallet/pkg/eth/eth_util.go
Anton Nesterov 1382da92a3
[init]
2024-08-31 16:46:20 +02:00

18 lines
305 B
Go

package eth
import (
"math"
"math/big"
)
func floatStringToWei(value string) *big.Int {
return floatStringToDec(value, 18)
}
func floatStringToDec(value string, dec int) *big.Int {
f, _ := new(big.Float).SetString(value)
f.Mul(f, big.NewFloat(math.Pow10(dec)))
wei, _ := f.Int(nil)
return wei
}