GithubHelp home page GithubHelp logo

Comments (2)

ShaneMaglangit avatar ShaneMaglangit commented on September 26, 2024

The returned price is in WEI, you would simply need to convert it to the proper denomination to get the ETH equivalent.

1 Ether = 1000000000000000000 Wei.
1 Ether = 1000000000000000 Kwei.
1 Ether = 1000000000000 Mwei.
1 Ether = 1000000000 Gwei.
1 Ether = 1000000 Szabo.
1 Ether = 1000 Finney.
1 Ether = 0.001 Kether.
1 Ether = 0.000001 Mether.

You may use the following as reference

// WeiToEther converts wei to the proper ETH denomination
func WeiToEther(wei *big.Int) *big.Float {
	f := new(big.Float)
	f.SetPrec(236) //  IEEE 754 octuple-precision binary floating-point format: binary256
	f.SetMode(big.ToNearestEven)
	fWei := new(big.Float)
	fWei.SetPrec(236) //  IEEE 754 octuple-precision binary floating-point format: binary256
	fWei.SetMode(big.ToNearestEven)
	return f.Quo(fWei.SetInt(wei), big.NewFloat(params.Ether))
}

Or this dumbed down conversion:

axie.auction.currentPrice = (parseFloat(axie.auction.currentPrice.slice(0, -14)) / 10000).toString()

from axie-graphql-documentation.

njh18 avatar njh18 commented on September 26, 2024

Perfect! Thank you!

from axie-graphql-documentation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.