wallet/pkg/eth/eth_util.go

18 lines
305 B
Go
Raw Normal View History

2024-08-31 14:46:20 +00:00
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
}