ethutils

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 7 Imported by: 0

README

ethutils

A light-weight library providing simple utils for ethereum data validation and testing

Documentation

Index

Constants

View Source
const (
	EthAddrRegex = `^0x[0-9|a-f|A-F]{40}$`
	EthHashRegex = `^0x[0-9|a-f|A-F]{64}$`
)
View Source
const SolidityIntSize uint = 256

SolidityIntSize is the size of a Solidity int in bits.

Variables

View Source
var (
	EthAddrExp        = regexp.MustCompile(EthAddrRegex)
	EthHashExp        = regexp.MustCompile(EthHashRegex)
	ErrInvalidEthAddr = fmt.Errorf("invalid ethereum address")
	ErrInvalidEthHash = fmt.Errorf("invalid ethereum hash")
)

Functions

func FromDecimal added in v1.0.1

func FromDecimal(balance *big.Float, decimals int) *big.Int

func GenRandEVMAddr

func GenRandEVMAddr() string

GenRandEVMAddr generates a random Ethereum address using non-cryptographic randomness

func GenRandEVMHash

func GenRandEVMHash() string

GenRandEVMHash generates a random Ethereum hash using non-cryptographic randomness

func HexToByte32

func HexToByte32(hexString string) ([32]byte, error)

func SanitizeEthAddr

func SanitizeEthAddr(addr string) (string, error)

SanitizeEthAddr returns a valid Ethereum address or an error if the address is invalid. will add the 0x prefix if it's missing, and lowercase the input.

func SanitizeEthHash

func SanitizeEthHash(hash string) (string, error)

SanitizeEthHash returns a valid Ethereum hash or an error if the hash is invalid. will add the 0x prefix if it's missing, and lowercase the input.

func ToDecimal added in v1.0.1

func ToDecimal(balance *big.Int, decimals int) *big.Float

Types

This section is empty.

Jump to

Keyboard shortcuts

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