goethereumhelper

package module
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 21 Imported by: 7

README

goethereumhelper

Set of Golang functions for helping to manage and deploy Solidity Smart Contracts at Ethereum blockchain

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCustomNetworkClient

func GetCustomNetworkClient(URL string) (client *ethclient.Client, err error)

GetCustomNetworkClient connects and return a client to user defined Ethereum network

func GetCustomNetworkClientWebsocket

func GetCustomNetworkClientWebsocket(URL string) (client *ethclient.Client, err error)

GetCustomNetworkClientWebsocket connects via websocket and return a client to user defined Ethereum network

func GetKeyedTransactor

func GetKeyedTransactor(client *ethclient.Client, increaseNonceFactor int) (transactor *bind.TransactOpts, err error)

GetKeyedTransactor gets a keyed (signed?) transctor do perform a transaction within the Ethereum Blockchain

func GetKeyedTransactorWithOptions

func GetKeyedTransactorWithOptions(client *ethclient.Client, increaseNonceFactor int, txValue int, pvtkey *ecdsa.PrivateKey) (transactor *bind.TransactOpts, err error)

GetKeyedTransactorWithOptions gets a keyed (signed?) transactor to perform a transaction within the Ethereum Blockchain

func GetMockBlockchain

func GetMockBlockchain() (auth *bind.TransactOpts, backend *backends.SimulatedBackend, coinbaseAccountPrivateKey *ecdsa.PrivateKey)

GetMockBlockchain get a "in-memory" Blockchain instance

func GetNonceNumber

func GetNonceNumber(client *ethclient.Client, pubkey ecdsa.PublicKey) (nonce uint64, err error)

GetNonceNumber gets actual nonce number of an Ethereum address/account

func GetPubKey

func GetPubKey(accountPrivateKey *ecdsa.PrivateKey) (publicKeyECDSA *ecdsa.PublicKey, address common.Address, err error)

GetPubKey gets public key and address from a private key

func GetRinkebyClient

func GetRinkebyClient() (client *ethclient.Client, err error)

GetRinkebyClient connects and return a client to the Rinkeby Ethereum network

func GetRinkebyClientWebsocket

func GetRinkebyClientWebsocket() (client *ethclient.Client, err error)

GetRinkebyClientWebsocket connects via websocket and return a client to the Rinkeby Ethereum network

func GetTransactionResult

func GetTransactionResult(client *ethclient.Client, trx common.Hash, maxAttempts int, interval int) (txReceipt *types.Receipt, err error)

GetTransactionResult check trx mining and return his results

func NewAccount

func NewAccount() (accountPrivateKey *ecdsa.PrivateKey, address common.Address)

NewAccount generates new Ethereum address/account

func SendEtherUsingKeystoreWallet added in v0.1.14

func SendEtherUsingKeystoreWallet(client *ethclient.Client, sender KeystoreWallet, to common.Address, value int64) (signedTx *types.Transaction, err error)

SendEtherUsingKeystoreWallet an example that shows how to send ether using an account from KeystoreWallet to another using Go (Golang)

func SendEtherUsingPrivateKey added in v0.1.14

func SendEtherUsingPrivateKey(client *ethclient.Client, senderPrivateKey *ecdsa.PrivateKey, to common.Address, value int64) (signedTx *types.Transaction, err error)

SendEtherUsingPrivateKey an example that shows how to send ether using private key from an account to another using Go (Golang)

func SubLogs

func SubLogs(addressToWatch common.Address, wg *sync.WaitGroup)

SubLogs Subscribe to watch to notifications to a specific Ethereum address

func UpdateKeyedTransactor

func UpdateKeyedTransactor(transactor *bind.TransactOpts, backend *backends.SimulatedBackend, increaseNonceFactor int, valueToSend int) (err error)

UpdateKeyedTransactor updates a keyed (signed?) transctor do perform a transaction within a Simulated Ethereum Blockchain

func UpdateKeyedTransactorWithClient added in v0.1.3

func UpdateKeyedTransactorWithClient(transactor *bind.TransactOpts, client *ethclient.Client, increaseNonceFactor int, valueToSend int) (err error)

UpdateKeyedTransactorWithClient updates a keyed (signed?) transctor using Ethereum client to perform a transaction within a Simulated Ethereum Blockchain

func WaitForTransactionProcessing

func WaitForTransactionProcessing(client *ethclient.Client, trx *types.Transaction, maxAttempts int, interval int) (txReceipt *types.Receipt, err error)

WaitForTransactionProcessing check trx mining and return his results

Types

type KeystoreWallet

type KeystoreWallet struct {
	Account  accounts.Account   // Single account contained in this wallet
	Keystore *keystore.KeyStore // Keystore where the account originates from
	Wallet   accounts.Wallet
}

KeystoreWallet implements the accounts.Wallet interface for the original

func NewKeystoreWallet

func NewKeystoreWallet(ks *keystore.KeyStore, accountHex, keystorePassphrase string) (ksw *KeystoreWallet, err error)

NewKeystoreWallet returns new instance of KeystoreWallet

func (*KeystoreWallet) GenerateSignedTxAsJSON added in v0.1.1

func (w *KeystoreWallet) GenerateSignedTxAsJSON(
	txOpts *bind.TransactOpts,
	passphrase string,
	contractMethodParameters []byte,
	smartContractAddress common.Address,
	nonce, chainID uint64,
) (txJSON []byte, err error)

GenerateSignedTxAsJSON generates a JSON signed raw Ethereum Transaction TODO: Update to London fork

func (*KeystoreWallet) GetNonceNumber

func (w *KeystoreWallet) GetNonceNumber(client *ethclient.Client) (nonce uint64, err error)

GetNonceNumber gets actual nonce number of an Ethereum address/account

func (*KeystoreWallet) NewKeyStoreTransactor

func (w *KeystoreWallet) NewKeyStoreTransactor(passphrase string, client *ethclient.Client) (*bind.TransactOpts, error)

NewKeyStoreTransactor is a utility method to easily create a transaction signer from an decrypted key from a keystore

func (*KeystoreWallet) SignData

func (w *KeystoreWallet) SignData(mimeType string, data []byte) ([]byte, error)

SignData signs keccak256(data). The mimetype parameter describes the type of data being signed

func (*KeystoreWallet) SignTextWithPassphrase

func (w *KeystoreWallet) SignTextWithPassphrase(passphrase string, text []byte) ([]byte, error)

SignTextWithPassphrase implements accounts.Wallet, attempting to sign the given hash with the given account using passphrase as extra authentication.

func (*KeystoreWallet) SignTxWithPassphrase

func (w *KeystoreWallet) SignTxWithPassphrase(passphrase string, tx *types.Transaction, chainID *big.Int) (*types.Transaction, error)

SignTxWithPassphrase implements accounts.Wallet, attempting to sign the given transaction with the given account using passphrase as extra authentication.

func (*KeystoreWallet) SwitchAccount added in v0.1.11

func (w *KeystoreWallet) SwitchAccount(accountHex, keystorePassphrase string) (err error)

func (*KeystoreWallet) URL

func (w *KeystoreWallet) URL() accounts.URL

URL implements accounts.Wallet, returning the URL of the account within.

func (*KeystoreWallet) UpdateKeyedTransactor

func (w *KeystoreWallet) UpdateKeyedTransactor(transactor *bind.TransactOpts, client *ethclient.Client, increaseNonceFactor int, valueToSend int) (err error)

UpdateKeyedTransactor updates a keyed (signed?) transctor do perform a transaction within a Simulated Ethereum Blockchain

type TxData added in v0.1.1

type TxData struct {
	AccountNonce uint64          `json:"nonce"    gencodec:"required"`
	Price        *big.Int        `json:"gasPrice" gencodec:"required"`
	GasLimit     uint64          `json:"gas"      gencodec:"required"`
	Recipient    *common.Address `json:"to"       rlp:"nil"` // nil means contract creation
	Amount       *big.Int        `json:"value"    gencodec:"required"`
	Payload      []byte          `json:"input"    gencodec:"required"`

	// Signature values
	V *big.Int `json:"v" gencodec:"required"`
	R *big.Int `json:"r" gencodec:"required"`
	S *big.Int `json:"s" gencodec:"required"`

	// This is only used when marshaling to JSON.
	Hash *common.Hash `json:"hash" rlp:"-"`
}

TxData represents an Ethereum raw transaction data

Jump to

Keyboard shortcuts

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