Skip to content

Latest commit

 

History

History
46 lines (35 loc) · 1.69 KB

README.md

File metadata and controls

46 lines (35 loc) · 1.69 KB

Github CI/CD Go Report Repository Top Language GitHub go.mod Go version Github Repository Size Github Open Issues Lines of code License GitHub last commit GitHub contributors

Ethereum Unit Converter

It is a simple library for conversion units between themselves. The library is written in Golang.

Install

go get github.com/DeOne4eg/eth-unit-converter

Docs

Usage

// first
amount := ethUnit.NewWei(big.NewInt(1000000000000000000))

fmt.Printf("Wei: %v\n", amount.Wei())
fmt.Printf("GWei: %v\n", amount.GWei())
fmt.Printf("Ether: %v\n", amount.Ether())

// second (the same of first)
amount, err := ethUnit.ParseUnit(big.NewFloat(1000000000000000000), "wei")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("Wei: %v\n", amount.Wei())
fmt.Printf("GWei: %v\n", amount.GWei())
fmt.Printf("Ether: %v\n", amount.Ether())

Tests

  • run with make test