ethereum

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PrivateKeysEnvName = "ETH_PRIVATE_KEYS"
	NodeURLEnvName     = "NODE_URL"
	ComponentName      = "ethereum"
	BlockTime          = float64(15)
	BlocksPerSecond    = float64(1 / BlockTime)
	BlocksPerMinute    = float64(60 / BlockTime)
	ReorgEventWait     = time.Minute
)

Variables

This section is empty.

Functions

func DecodeHex

func DecodeHex(s string) []byte

func GetAddressForNetwork

func GetAddressForNetwork(addresses string, networkID int64) (string, error)

GetAddressForNetwork returns an ethereum address based on ethereum node network id.

func GetEtherscanURL added in v0.3.0

func GetEtherscanURL(netID int64) string

func Keccak256

func Keccak256(input []byte) [32]byte

func NewClient

func NewClient(ctx context.Context, logger log.Logger) (*ethclient.Client, int64, error)

func NewSignedTX added in v0.3.0

func NewSignedTX(
	to common.Address,
	data []byte,
	nonce uint64,
	prvKey *ecdsa.PrivateKey,
	netID int64,
	gasLimit uint64,
	gasMaxFee float64,
) (*types.Transaction, string, error)

func PrepareTx added in v0.3.0

func PrepareTx(
	ctx context.Context,
	client *ethclient.Client,
	account *Account,
	gasMaxFee float64,
	gasLimit uint64,
) (*bind.TransactOpts, error)

func ValidateAddress

func ValidateAddress(address string) error

ValidateAddress checks if an ethereum URL is valid?

Types

type Account

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

func GetAccountByPubAddress added in v0.3.0

func GetAccountByPubAddress(logger log.Logger, pubAddr string) (*Account, error)

func GetAccounts

func GetAccounts(logger log.Logger) ([]*Account, error)

GetAccounts returns a slice of Account from private keys in PrivateKeysEnvName environment variable.

func (*Account) GetAddress

func (a *Account) GetAddress() common.Address

func (*Account) GetPrivateKey

func (a *Account) GetPrivateKey() *ecdsa.PrivateKey

Jump to

Keyboard shortcuts

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