Content pfp
Content
@
0 reply
0 recast
0 reaction

christopher pfp
christopher
@christopher
Getting the wei balance of a wallet using go-ethereum is easy! All you have to do is: func etherToWei(eth *big.Float) *big.Int { truncInt, _ := eth.Int(nil) truncInt = new(big.Int).Mul(truncInt, big.NewInt(params.Ether)) fracStr := strings.Split(fmt.Sprintf("%.18f", eth), ".")[1] fracStr += strings.Repeat("0", 18 - len(fracStr)) fracInt, _ := new(big.Int).SetString(fracStr, 10) wei := new(big.Int).Add(truncInt, fracInt) return wei; } and then just use the result.
7 replies
1 recast
25 reactions

christopher pfp
christopher
@christopher
actually it's way easier if you get the balance and new(big.Float).Quo(new(big.Float).SetInt(balance), new(big.Float).SetInt(big.NewInt(1e18)))
0 reply
0 recast
6 reactions

kevin pfp
kevin
@kevinoconnell
this is just one line in ethers js
1 reply
0 recast
1 reaction

iSpeakNerd πŸ§™β€β™‚οΈ pfp
iSpeakNerd πŸ§™β€β™‚οΈ
@ispeaknerd.eth
ah yes. so easy
0 reply
0 recast
1 reaction

Just Build pfp
Just Build
@justbuild
πŸ’›πŸ’›πŸ’›
0 reply
0 recast
1 reaction

AM pfp
AM
@am-hernandez
Wow, that's it? 😌
0 reply
0 recast
1 reaction

Jacob pfp
Jacob
@jrf
0 reply
0 recast
1 reaction

zoo pfp
zoo
@zoo
wowow
0 reply
0 recast
1 reaction