ethereum

package
v1.7.2 Latest Latest
Warning

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

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

Documentation

Overview

Package ethereum provides functions to assist with Ethereum related functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractAddresses

func ExtractAddresses(accs []*Account) []string

ExtractAddresses turns an array of accounts into an array of addresses

func ExtractAddressesNoPrefix

func ExtractAddressesNoPrefix(accs []*Account) []string

ExtractAddressesNoPrefix turns an array of accounts into an array of addresses without the 0x prefix

Types

type Account

type Account struct {
	PrivateKey *ecdsa.PrivateKey
	PublicKey  *ecdsa.PublicKey
	Address    common.Address
}

Account represents an ethereum account

func CreateAccountFromHex

func CreateAccountFromHex(hexPK string) (*Account, error)

CreateAccountFromHex creates an account from a hex encoded private key

func GenerateAccounts

func GenerateAccounts(accounts int) ([]*Account, error)

GenerateAccounts is a convience function to generate an arbitrary number of accounts using GenerateEthereumAddress

func GenerateEthereumAddress

func GenerateEthereumAddress() (*Account, error)

GenerateEthereumAddress generates a new, random Ethereum account

func NewAccount

func NewAccount(privKey *ecdsa.PrivateKey) *Account

NewAccount creates an account from a SECP256K1 ECDSA private key

func (Account) HexAddress

func (acc Account) HexAddress() string

HexAddress gets the address in hex format

func (Account) HexPrivateKey

func (acc Account) HexPrivateKey() string

HexPrivateKey gets the private key in hex format

func (Account) HexPublicKey

func (acc Account) HexPublicKey() string

HexPublicKey gets the public key in hex format

func (Account) MarshalJSON

func (acc Account) MarshalJSON() ([]byte, error)

MarshalJSON handles the marshaling of Acount into JSON, so that the fields are exposed in their hex encodings

func (*Account) UnmarshalJSON added in v1.7.1

func (acc *Account) UnmarshalJSON(data []byte) error

UnmarshalJSON handles the conversion from json to account

Jump to

Keyboard shortcuts

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