Categorygithub.com/reiver/go-ethaddr
modulepackage
0.0.0-20240725113632-c09f96572c11
Repository: https://github.com/reiver/go-ethaddr.git
Documentation: pkg.go.dev

# README

go-ethaddr

Package ethaddr provides tools for working with eth-addresses, for the Go programming language.

The eth-address (also known as an ethereum-address or evm-address) is a 20-byte address — and is commonly used by EVM based networks, as well as other places

ethaddr.Address is meant to be a replacement for go-ethereum/common.Address from the official Ethereum golang package.

Examples

Here is an example of loading an ethaddr.Address from a hexadecimal-literal stored in a Go string:

address, err := ethaddr.ParseString("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")

Here is an example of loading an ethaddr.Address from a hexadecimal-literal stored in a Go []byte:

var bytes []byte = []byte("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")

address, err := ethaddr.Parse(bytes)

Here is an example of loading an ethaddr.Address from a Go [20]byte:

address := ethaddr.Something( [20]{0x5a,0xAe,0xb6,0x05,0x3F,0x3E,0x94,0xC9,0xb9,0xA0,0x9f,0x33,0x66,0x94,0x35,0xE7,0xEf,0x1B,0xeA,0xed} )

Here is an example of loading an ethaddr.Address from a Go *big.Int:

var bigint *big.Int = // ...

address := ethaddr.BigInt(bigint)

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-ethaddr

GoDoc

Import

To import package ethaddr use import code like the follownig:

import "github.com/reiver/go-ethaddr"

Installation

To install package ethaddr do the following:

GOPROXY=direct go get https://github.com/reiver/go-ethaddr

Author

Package ethaddr was written by Charles Iliya Krempeaux

# Functions

BigInt returns the eth-address represented by the *big.Int.
BigIntElsePanic is similar to the BigInt func, except that it panic()s if there is an error.
Nothing returns an empty address.
Parse returns the eth-address represented by the hexadecimal-literal.
ParseElsePanic is similar to the Parse func, except that it panic()s if there is an error.
ParseString returns the eth-address represented by the hexadecimal-literal.
ParseStringElsePanic is similar to the ParseString func, except that it panic()s if there is an error.
Something returns an address whose value is equal to the contents of the 'value' variable.

# Constants

AddressLength is the length of the eth-address measured in number of bytes.

# Structs

Address holds the eth-address.