wallet/pkg/eth/eth_util.go
Anton Nesterov b19bf34e5f
[init]
2024-08-31 16:54:43 +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
}