address

package module
v0.0.0-...-bdb9d3d Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: MIT Imports: 7 Imported by: 0

README

Go Reference Report card

address

High efficient and minimal utilities library that will help you to work with Ethereum addresses easier. (a go-ethereum helper library)

Installation

go get github.com/Cleverse/go-utilities/address

Documentation

Overview

Package address provides efficient utilities for easily working with Ethereum addresses.

Index

Constants

View Source
const (
	// AddressLength is the expected length of the address
	AddressLength = common.AddressLength
)

Variables

View Source
var (
	// Ether is the default address of the Ethereum's native currency.
	Ether = common.HexToAddress("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE")

	// Zero is zero value of common.Address.
	Zero = common.Address{}

	// DeadWalletAddress is the defailt address of the dead wallet.
	DeadWalletAddress = common.HexToAddress("0x000000000000000000000000000000000000dead")

	// DeadAddresseses is the list of dead addresses.
	DeadAddresseses = map[common.Address]interface{}{
		Zero:              nil,
		DeadWalletAddress: nil,
		common.HexToAddress("0x0000000000000000000000000000000000000001"): nil,
		common.HexToAddress("0xdEAD000000000000000042069420694206942069"): nil,
		common.HexToAddress("0xdead000000000000000000000000000000000000"): nil,
	}

	// RandomGenerator is the address random generator function and used by address.Random() function.
	//
	// Default address random generator is cryptographically secure random number generator.
	RandomGenerator func() (addr common.Address) = RandomFromBytes
)

Functions

func CompareAddress

func CompareAddress(address0 common.Address, address1 common.Address) int

CompareAddress returns -1 if address0 < address1 returns 0 if address0 == address1 returns 1 if address0 > address1

func FromHex

func FromHex(address string) (addr common.Address)

FromHex safely converts a hex string to a common.Address.

func FromHexes

func FromHexes(src []string) (dst []common.Address)

FromHexes safely converts hex string slice to a common.Address slice.

func FromString

func FromString(address string) (addr common.Address)

FromString safely converts a string to a common.Address.

func FromStrings

func FromStrings(src []string) (dst []common.Address)

FromStrings alias of FromHexes. safely converts string slice to a common.Address slice.

func IsDead

func IsDead(a common.Address) bool

IsDead returns `true` if the address is dead address.

func IsEmpty

func IsEmpty(a common.Address) bool

IsEmpty returns `true` if the address is empty (alias of IsZero)

func IsValid

func IsValid(a common.Address) bool

IsZero returns `true` if the address is can't be used. (zero value or dead address)

func IsZero

func IsZero(a common.Address) bool

IsZero returns `true` if the address is zero value.

func Random

func Random() (addr common.Address)

Random returns a random common.Address. can be changed address random generator by RandomGenerator variable.

Default address random generator is use cryptographically secure random number generator.

func RandomFromBytes

func RandomFromBytes() (addr common.Address)

RandomFromBytes returns a random address from a random byte slice (via crypto/rand)

func RandomFromPrivateKey

func RandomFromPrivateKey() common.Address

RandomFromPrivateKey returns a random address from a random private key

func SortAddress

func SortAddress(address0 common.Address, address1 common.Address) (common.Address, common.Address)

SortAddress for sorting two addresses by hex value.

func ToLower

func ToLower(a common.Address) string

ToLower converts an address to a lower-case string withouth checksum.

func ToLowers

func ToLowers(src []common.Address) []string

ToLowers converts an addresses to a lower-case strings withouth checksum.

func ToString

func ToString(a common.Address) string

ToString alias of ToLower. converts an address to a lower-case string withouth checksum.

func ToStrings

func ToStrings(src []common.Address) []string

ToStrings alias of ToLowers. converts an addresses to a lower-case strings withouth checksum.

Types

This section is empty.

Jump to

Keyboard shortcuts

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