ethutils

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2019 License: Unlicense Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromWei

func FromWei(wei *big.Int, decimals int) *big.Float

FromWei transforms wei to a decimal value with `decimals` orders of magnitude (divide by 10^`decimals`)

func RenderFloat

func RenderFloat(format string, n float64) string

RenderFloat is a Go function to render a number to a string based on the following user-specified criteria: * thousands separator * decimal separator * decimal precision Usage: s := RenderFloat(format, n) The format parameter tells how to render the number n. http://play.golang.org/p/LXc1Ddm1lJ Examples of format strings, given n = 12345.6789: "#,###.##" => "12,345.67" "#,###." => "12,345" "#,###" => "12345,678" "#\u202F###,##" => "12 345,67" "#.###,###### => 12.345,678900 "" (aka default format) => 12,345.67 The highest precision allowed is 9 digits after the decimal symbol. There is also a version for integer number, RenderInteger(), which is convenient for calls within template. I didn't feel it was worth to publish a library just for this piece of code, hence the snippet. Feel free to reuse as you wish.

func RenderInteger

func RenderInteger(format string, n int) string

RenderInteger is a convenient function to format integers, see RenderFloat

func SliceToBytes32

func SliceToBytes32(bs []byte) (ba [32]byte, err error)

SliceToBytes32 transforms a []byte to a [32]byte

func ToWei

func ToWei(value *big.Float, decimals int) *big.Int

ToWei transforms decimal value to wei with `decimals` orders of magnitude (multiply by 10^`decimals`)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL