eth

package
v0.0.0-...-bb1a4e7 Latest Latest
Warning

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

Go to latest
Published: May 9, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// length of an ethereum address
	AddressLengthBytes = 20
	// length of ethereum address hexadecimal encoded
	AddressLengthHexEncoded = AddressLengthBytes * 2
	// length of ethereum address hexadecimal encoded and prefixed with '0x'
	AddressLengthHexEncodedWithPrefix = 2 + AddressLengthHexEncoded
)

Variables

This section is empty.

Functions

func CalcGasCost

func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int

CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)

func ConvertAddress

func ConvertAddress(addr string) fixtures.Address

converts an string ethereum address to eth address addr: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f

func GenerateNewKey

func GenerateNewKey() (*ecdsa.PrivateKey, error)

generates new ethereum ECDSA key This is the private key which is used for signing transactions and is to be treated like a password and never be shared, since who ever is in possesion of it will have access to all your funds.

func GetAddressFromPrivateKey

func GetAddressFromPrivateKey(privateKey *ecdsa.PrivateKey) fixtures.Address

get ethereum address from its private key

func GetPrivateKeyAsEthString

func GetPrivateKeyAsEthString(privateKey *ecdsa.PrivateKey) string

get the private key encoded as 0x..... string

func GetPrivateKeyBytes

func GetPrivateKeyBytes(privateKey *ecdsa.PrivateKey) []byte

get the bytes of private key

func GetPublicKey

func GetPublicKey(privateKey *ecdsa.PrivateKey) *ecdsa.PublicKey

get the bytes of private key

func GetPublicKeyAsEthString

func GetPublicKeyAsEthString(pub *ecdsa.PublicKey) string

The public address is simply the Keccak-256 hash of the public key and then we take the last 40 characters (20 bytes) and prefix it with 0x

func GetPublicKeyBytes

func GetPublicKeyBytes(pub *ecdsa.PublicKey) []byte

get the bytes of public key

func IsValidAddress

func IsValidAddress(addr string) bool

check if an address is syntactically valid or not example address: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f

func IsValidAddressLow

func IsValidAddressLow(addr string) bool

check if an address is syntactically valid or not example address: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f

func IsValidBlockHash

func IsValidBlockHash(blockHash string) bool

a block hash is valid only if: starts with 0x is hexadecimal string of 32 bytes encoded data (64 bytes as hex string) + 0x prefix example: 0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238

func IsValidBlockNumber

func IsValidBlockNumber(blkStr string) bool

check if the input string represents a valid block number allowed block numbers are: The following options are possible for the defaultBlock parameter:

HEX String - an integer block number
String "earliest" for the earliest/genesis block
String "latest" - for the latest mined block
String "pending" - for the pending state/transactions

func IsValidHexPrivateKey

func IsValidHexPrivateKey(pkey string) bool

func IsValidHexSignature

func IsValidHexSignature(signature string) bool

func IsXdigit

func IsXdigit(c byte) bool

check whether given byte value is hexadecimal or not

func IsZeroAddress

func IsZeroAddress(addr string) bool

IsZeroAddress validate if it's a 0 address

func LogTopicHash

func LogTopicHash(functionSignature string) fixtures.Hash

LogTopicHash generates the log topic hash given the event function declaration signature

func ToDecimal

func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal

ToDecimal wei to decimals

func ToWei

func ToWei(iamount interface{}, decimals int) *big.Int

ToWei decimals to wei

Types

This section is empty.

Directories

Path Synopsis
Package hexutil implements hex encoding with 0x prefix.
Package hexutil implements hex encoding with 0x prefix.
abi
Package abi implements the Ethereum ABI (Application Binary Interface).
Package abi implements the Ethereum ABI (Application Binary Interface).
common
Package common contains various helper functions.
Package common contains various helper functions.
common/math
Package math provides integer math utilities.
Package math provides integer math utilities.
crypto/bn256
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
crypto/bn256/cloudflare
Package bn256 implements a particular bilinear group at the 128-bit security level.
Package bn256 implements a particular bilinear group at the 128-bit security level.
crypto/bn256/google
Package bn256 implements a particular bilinear group.
Package bn256 implements a particular bilinear group.
crypto/secp256k1
Package secp256k1 wraps the bitcoin secp256k1 C library.
Package secp256k1 wraps the bitcoin secp256k1 C library.
rlp
rpc

Jump to

Keyboard shortcuts

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