18 lines
305 B
Go
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
|
||
|
}
|