Documentation
¶
Index ¶
- Constants
- func CalcGasCost(gasLimit uint64, gasPrice *big.Int) *big.Int
- func ConvertAddress(addr string) fixtures.Address
- func GenerateNewKey() (*ecdsa.PrivateKey, error)
- func GetAddressFromPrivateKey(privateKey *ecdsa.PrivateKey) fixtures.Address
- func GetPrivateKeyAsEthString(privateKey *ecdsa.PrivateKey) string
- func GetPrivateKeyBytes(privateKey *ecdsa.PrivateKey) []byte
- func GetPublicKey(privateKey *ecdsa.PrivateKey) *ecdsa.PublicKey
- func GetPublicKeyAsEthString(pub *ecdsa.PublicKey) string
- func GetPublicKeyBytes(pub *ecdsa.PublicKey) []byte
- func IsValidAddress(addr string) bool
- func IsValidAddressLow(addr string) bool
- func IsValidBlockHash(blockHash string) bool
- func IsValidBlockNumber(blkStr string) bool
- func IsValidHexPrivateKey(pkey string) bool
- func IsValidHexSignature(signature string) bool
- func IsXdigit(c byte) bool
- func IsZeroAddress(addr string) bool
- func LogTopicHash(functionSignature string) fixtures.Hash
- func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal
- func ToWei(iamount interface{}, decimals int) *big.Int
Constants ¶
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 ¶
CalcGasCost calculate gas cost given gas limit (units) and gas price (wei)
func ConvertAddress ¶
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 ¶
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 ¶
get the bytes of public key
func IsValidAddress ¶
check if an address is syntactically valid or not example address: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f
func IsValidAddressLow ¶
check if an address is syntactically valid or not example address: 0x71c7656ec7ab88b098defb751b7401b5f6d8976f
func IsValidBlockHash ¶
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 ¶
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 IsValidHexSignature ¶
func IsZeroAddress ¶
IsZeroAddress validate if it's a 0 address
func LogTopicHash ¶
LogTopicHash generates the log topic hash given the event function declaration signature
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. |