ethblocks

package
v0.0.0-...-241d88a Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BalanceAt

func BalanceAt(ctx context.Context, client *ethclient.Client, account common.Address, blockNumber *big.Int) (*big.Int, error)

BalanceAt - returns the wei balance of the given account.

func BlockNumber

func BlockNumber(ctx context.Context, client *ethclient.Client) (string, error)

BlockNumber - returns the number of most recent block https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_blocknumber

func CodeAt

func CodeAt(ctx context.Context, client *ethclient.Client, account common.Address, blockNumber *big.Int) ([]byte, error)

CodeAt - returns the contract code of the given account.

func CreateRawTransaction

func CreateRawTransaction(nonce uint64, toAddress common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *types.Transaction

CreateRawTransaction - Create Raw Transaction

func GetBalance

func GetBalance(ctx context.Context, client *ethclient.Client, addr string) (*big.Int, error)

GetBalance - returns the wei balance of the given account.

func GetBlockByHash

func GetBlockByHash(ctx context.Context, client *ethclient.Client, hash common.Hash) (*types.Block, error)

GetBlockByHash - Returns information about a block by hash https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblockbyhash

func GetBlockByNumber

func GetBlockByNumber(ctx context.Context, client *ethclient.Client, blockNumber *big.Int) (*types.Block, error)

GetBlockByNumber - Get block by block number https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_getblockbynumber

func GetBlockTransactionCountByHash

func GetBlockTransactionCountByHash(ctx context.Context, client *ethclient.Client, blockHash common.Hash) (uint, error)

GetBlockTransactionCountByHash - Returns the number of transactions in a block from a block matching the given block hash. https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbyhash

func GetBlockTransactionCountByNumber

func GetBlockTransactionCountByNumber(ctx context.Context, client *ethclient.Client) (uint, error)

GetBlockTransactionCountByNumber - returns the total number of transactions in the pending state. https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getblocktransactioncountbynumber

func GetBlocks

func GetBlocks(ctx context.Context, client *ethclient.Client, startBlockNumber *big.Int, endBlockNumber *big.Int) ([]*types.Block, error)

GetBlocks - return blocks between start and end

func GetBlocksByMiner

func GetBlocksByMiner(ctx context.Context, client *ethclient.Client, miner string, startBlockNumber *big.Int, endBlockNumber *big.Int) ([]*types.Block, error)

GetBlocksByMiner - Get blocks by miner

func GetClient

func GetClient(addr string) (*ethclient.Client, error)

GetClient - connects a client to the given URL

func GetEthblocksClient2Details

func GetEthblocksClient2Details() (string, string, string)

GetEthblocksClient2Details - used to get address from sepolia.infura

func GetEthblocksClientAddr

func GetEthblocksClientAddr() string

GetEthblocksClientAddr - used to get address from infura

func GetGethClient

func GetGethClient(addr string) (*gethclient.Client, error)

GetGethClient - Get gethclient

func GetLogs

func GetLogs(receipt *types.Receipt) []*types.Log

GetLogs - Get Logs by receipt

func GetPendingBalanceAt

func GetPendingBalanceAt(ctx context.Context, client *ethclient.Client, addr string) (*big.Int, error)

GetPendingBalanceAt - returns the wei balance of the given account in the pending state

func GetProof

func GetProof(ctx context.Context, gclient *gethclient.Client, account common.Address, keys []string, blockNumber *big.Int) (*gethclient.AccountResult, error)

GetProof - returns the account and storage values of the specified account including the Merkle-proof

func GetTopics

func GetTopics(lg *types.Log) []common.Hash

GetTopics - Get Transaction Log Topic by log

func GetTransactionByBlockHashAndIndex

func GetTransactionByBlockHashAndIndex(ctx context.Context, client *ethclient.Client, hash common.Hash, index uint) (*types.Transaction, error)

GetTransactionByBlockHashAndIndex - Returns information about a transaction by block hash and transaction index position. https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyblockhashandindex

func GetTransactionByHash

func GetTransactionByHash(ctx context.Context, client *ethclient.Client, hash common.Hash) (*types.Transaction, bool, error)

GetTransactionByHash - Returns the information about a transaction requested by transaction hash. https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionbyhash

func GetTransactionReceipt

func GetTransactionReceipt(ctx context.Context, client *ethclient.Client, txHash common.Hash) (*types.Receipt, error)

GetTransactionReceipt - Returns the receipt of a transaction by transaction hash https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_gettransactionreceiptt

func GetTransactions

func GetTransactions(block *types.Block) []*types.Transaction

GetTransactions - return the Transactions in this block

func GetTransactionsByAddress

func GetTransactionsByAddress(ctx context.Context, client *ethclient.Client, frmaddr string, startBlockNumber *big.Int, endBlockNumber *big.Int) ([]*types.Transaction, error)

GetTransactionsByAddress - returns the transactions in a range of blocks

func GetUncleCountByBlockHash

func GetUncleCountByBlockHash(ctx context.Context, client *ethclient.Client, hash common.Hash) (int, error)

GetUncleCountByBlockHash - Returns the number of uncles in a block from a block matching the given block number. https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclecountbyblocknumber

func GetUncleCountByBlockNumber

func GetUncleCountByBlockNumber(ctx context.Context, client *ethclient.Client, blockNumber *big.Int) (int, error)

GetUncleCountByBlockNumber - Returns the number of uncles in a block from a block matching the given block number. https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_getunclecountbyblocknumber

func GetUncles

func GetUncles(block *types.Block) []*types.Header

GetUncles - return the Uncles in the block

func NonceAt

func NonceAt(ctx context.Context, client *ethclient.Client, account common.Address, blockNumber *big.Int) (uint64, error)

NonceAt - returns the account nonce of the given account

func PrintBlock

func PrintBlock(block *types.Block)

PrintBlock - Print block

func PrintBlockHeader

func PrintBlockHeader(header *types.Header)

PrintBlockHeader - Print a single block Header

func PrintBlockTransactions

func PrintBlockTransactions(blocktransactions []*types.Transaction)

PrintBlockTransactions Loop over the transactions and print each one

func PrintBlockUncle

func PrintBlockUncle(uncle *types.Header)

PrintBlockUncle - Print a single block Uncle

func PrintBlockUncles

func PrintBlockUncles(uncles []*types.Header)

PrintBlockUncles - Loop over the uncles and print each one

func PrintReceipt

func PrintReceipt(receipt *types.Receipt)

PrintReceipt - Print Receipt

func PrintReceiptLog

func PrintReceiptLog(lg *types.Log)

PrintReceiptLog - Print Receipt Log

func PrintTopic

func PrintTopic(s common.Hash)

PrintTopic - Print Transaction Log Topic

func PrintTransaction

func PrintTransaction(tx *types.Transaction)

PrintTransaction - Print Transaction

func SendRawTransaction

func SendRawTransaction(ctx context.Context, client *ethclient.Client, tx *types.Transaction, prv *ecdsa.PrivateKey) error

SendRawTransaction - Send a signed Transaction https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sendrawtransaction

func SendTransaction1

func SendTransaction1(client *ethclient.Client, fromAddr common.Address, toAddress *common.Address, privateKey *ecdsa.PrivateKey, value *big.Int, gas uint64, gasPrice *big.Int) error

SendTransaction1 -- create and send a transaction

func SendTransaction2

func SendTransaction2(client *ethclient.Client, nonce uint64, toAddress *common.Address, privateKey *ecdsa.PrivateKey, value *big.Int, gas uint64, gasPrice *big.Int) error

SendTransaction2 -- create and send a transaction

func StorageAt

func StorageAt(ctx context.Context, client *ethclient.Client, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)

StorageAt - returns the value of key in the contract storage of the given account.

func SubscribeFullPendingTransactions

func SubscribeFullPendingTransactions(ctx context.Context, client *ethclient.Client, gclient *gethclient.Client, nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, testKey *ecdsa.PrivateKey) error

SubscribeFullPendingTransactions - subscribe full pending transactions

func SubscribePendingTransactions

func SubscribePendingTransactions(ctx context.Context, client *ethclient.Client, gclient *gethclient.Client, nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, testKey *ecdsa.PrivateKey) error

SubscribePendingTransactions - Subscribe to Transactions

func TransactionInBlock

func TransactionInBlock(ctx context.Context, client *ethclient.Client, blockHash common.Hash, index uint) (*types.Transaction, error)

TransactionInBlock - return a single transaction at index in the given block

Types

type Block

type Block struct {
	Id               uint
	ParentHash       string
	UncleHash        string
	Coinbase         string
	BlockRoot        string
	TxHash           string
	ReceiptHash      string
	Bloom            []byte
	Difficulty       uint64
	BlockNumber      uint64
	GasLimit         uint64
	GasUsed          uint64
	BlockTime        uint64
	Extra            []byte
	MixDigest        string
	BlockNonce       uint64
	BaseFee          uint64
	WithdrawalsHash  string
	BlobGasUsed      *uint64
	ExcessBlobGas    *uint64
	ParentBeaconRoot string
	BlockHash        string
	BlockSize        uint64
	ReceivedAt       time.Time
	BlockUncles      []*BlockUncle
	Transactions     []*Transaction
}

Block - Used for

type BlockService

type BlockService struct {
	Db *sql.DB
}

BlockService - For accessing block services

func NewBlockService

func NewBlockService(db *sql.DB) *BlockService

NewBlockService - Create block service

func (*BlockService) AddBlock

func (b *BlockService) AddBlock(ctx context.Context, client *ethclient.Client, block *types.Block) (*Block, error)

AddBlock - add a block to the db

func (*BlockService) CreateBlockTransaction

func (b *BlockService) CreateBlockTransaction(ctx context.Context, client *ethclient.Client, tx *sql.Tx, blk *Block, block *types.Block) error

CreateBlockTransaction - add a block transaction to the db

func (*BlockService) GetBlock

func (b *BlockService) GetBlock(ctx context.Context, id uint) (*Block, error)

GetBlock - used for

type BlockServiceIntf

type BlockServiceIntf interface {
	AddBlock(ctx context.Context, client *ethclient.Client, block *types.Block) (*Block, error)
	CreateBlockTransaction(ctx context.Context, client *ethclient.Client, tx *sql.Tx, blk *Block, block *types.Block) error
	GetBlock(ctx context.Context, id uint) (*Block, error)
}

BlockServiceIntf - BlockIntf interface for BlockService

type BlockUncle

type BlockUncle struct {
	Id               uint
	ParentHash       string
	UncleHash        string
	Coinbase         string
	BlockRoot        string
	TxHash           string
	ReceiptHash      string
	Bloom            []byte
	Difficulty       uint64
	BlockNumber      uint64
	GasLimit         uint64
	GasUsed          uint64
	BlockTime        uint64
	Extra            []byte
	MixDigest        string
	BlockNonce       uint64
	BaseFee          uint64
	WithdrawalsHash  string
	BlobGasUsed      *uint64
	ExcessBlobGas    *uint64
	ParentBeaconRoot string
	BlockId          uint
}

BlockUncle - Used for

type BlockUncleIntf

type BlockUncleIntf interface {
	AddBlockUncle(ctx context.Context, tx *sql.Tx, blkUncle *types.Header, blockId uint) (*BlockUncle, error)
	GetBlockUncles(ctx context.Context, blockId uint) ([]*BlockUncle, error)
}

BlockUncleIntf - interface

type BlockUncleService

type BlockUncleService struct {
	Db *sql.DB
}

BlockUncleService - For accessing Block Uncle services

func NewBlockUncleService

func NewBlockUncleService(db *sql.DB) *BlockUncleService

NewBlockUncleService - Create Block Uncle service

func (*BlockUncleService) AddBlockUncle

func (bu *BlockUncleService) AddBlockUncle(ctx context.Context, tx *sql.Tx, blkUncle *types.Header, blockId uint) (*BlockUncle, error)

AddBlockUncle - add a block uncle to the db

func (*BlockUncleService) GetBlockUncles

func (bu *BlockUncleService) GetBlockUncles(ctx context.Context, blockId uint) ([]*BlockUncle, error)

GetBlockUncles - used for

type Transaction

type Transaction struct {
	Id                  uint
	TxType              uint8
	ChainId             uint64
	TxData              []byte
	Gas                 uint64
	GasPrice            uint64
	GasTipCap           uint64
	GasFeeCap           uint64
	TxValue             uint64
	AccountNonce        uint64
	TxTo                string
	TxV                 uint64
	TxR                 uint64
	TxS                 uint64
	BlockNumber         uint64
	BlockHash           string
	BlockId             uint
	TransactionReceipts []*TransactionReceipt
}

Transaction - Used for

type TransactionIntf

type TransactionIntf interface {
	AddTransaction(ctx context.Context, tx *sql.Tx, ethTrans *types.Transaction, blockId uint, blockNumber uint64) (*Transaction, error)
	GetBlockTransactions(ctx context.Context, blockId uint) ([]*Transaction, error)
}

TransactionIntf - interface

type TransactionLog

type TransactionLog struct {
	Id                   uint
	Address              string
	LogData              []byte
	BlockNumber          uint64
	TxHash               string
	TxIndex              uint
	BlockHash            string
	LogIndex             uint
	Removed              bool
	BlockId              uint
	TransactionId        uint
	TransactionReceiptId uint
	Topics               []*TransactionLogTopic
}

TransactionLog - Used for

type TransactionLogIntf

type TransactionLogIntf interface {
	AddTransactionLog(ctx context.Context, tx *sql.Tx, ethLog *types.Log, blockId uint, transactionId uint, transactionReceiptId uint) (*TransactionLog, error)
	GetTransactionLogs(ctx context.Context, transactionReceiptId uint) ([]*TransactionLog, error)
}

TransactionLogIntf - interface

type TransactionLogService

type TransactionLogService struct {
	Db *sql.DB
}

TransactionLogService - For accessing Transaction Log services

func NewTransactionLogService

func NewTransactionLogService(db *sql.DB) *TransactionLogService

NewTransactionLogService - Create Transaction Log service

func (*TransactionLogService) AddTransactionLog

func (tl *TransactionLogService) AddTransactionLog(ctx context.Context, tx *sql.Tx, ethLog *types.Log, blockId uint, transactionId uint, transactionReceiptId uint) (*TransactionLog, error)

AddTransactionLog - add a transaction log to the db

func (*TransactionLogService) GetTransactionLogs

func (tl *TransactionLogService) GetTransactionLogs(ctx context.Context, transactionReceiptId uint) ([]*TransactionLog, error)

GetTransactionLogs - used for getting logs by TransactionReceiptId

type TransactionLogTopic

type TransactionLogTopic struct {
	Id                   uint
	Topic                string
	BlockId              uint
	TransactionId        uint
	TransactionReceiptId uint
	TransactionLogId     uint
}

TransactionLogTopic - Used for

type TransactionLogTopicIntf

type TransactionLogTopicIntf interface {
	AddTransactionLogTopic(ctx context.Context, tx *sql.Tx, s common.Hash, blockId uint, transactionId uint, transactionReceiptId uint, TransactionLogId uint) (*TransactionLogTopic, error)
	GetTransactionLogTopics(ctx context.Context, transactionLogId uint) ([]*TransactionLogTopic, error)
}

TransactionLogTopicIntf interface

type TransactionLogTopicService

type TransactionLogTopicService struct {
	Db *sql.DB
}

TransactionLogTopicService - For accessing Transaction Log Topic services

func NewTransactionLogTopicService

func NewTransactionLogTopicService(db *sql.DB) *TransactionLogTopicService

NewTransactionLogTopicService - Create Transaction Log Topic service

func (*TransactionLogTopicService) AddTransactionLogTopic

func (t *TransactionLogTopicService) AddTransactionLogTopic(ctx context.Context, tx *sql.Tx, s common.Hash, blockId uint, transactionId uint, transactionReceiptId uint, transactionLogId uint) (*TransactionLogTopic, error)

AddTransactionLogTopic - add a transaction Topic to the db

func (*TransactionLogTopicService) GetTransactionLogTopics

func (t *TransactionLogTopicService) GetTransactionLogTopics(ctx context.Context, transactionLogId uint) ([]*TransactionLogTopic, error)

GetTransactionLogTopics - used for getting topics by TransactionLogId

type TransactionReceipt

type TransactionReceipt struct {
	Id                uint
	ReceiptType       uint8
	PostState         []byte
	TxStatus          uint64
	CumulativeGasUsed uint64
	Bloom             []byte
	TxHash            string
	ContractAddress   string
	GasUsed           uint64
	EffectiveGasPrice uint64
	BlobGasUsed       uint64
	BlobGasPrice      uint64
	BlockHash         string
	BlockNumber       uint64
	TransactionIndex  uint
	BlockId           uint
	TransactionId     uint
	Logs              []*TransactionLog
}

TransactionReceipt - Used for

type TransactionReceiptIntf

type TransactionReceiptIntf interface {
	AddTransactionReceipt(ctx context.Context, tx *sql.Tx, ethReceipt *types.Receipt, BlockId uint, BlockNumber uint64, BlockHash string, TransactionId uint) (*TransactionReceipt, error)
	GetTransactionReceipts(ctx context.Context, transactionId uint) ([]*TransactionReceipt, error)
}

TransactionReceiptIntf interface

type TransactionReceiptService

type TransactionReceiptService struct {
	Db *sql.DB
}

TransactionReceiptService - For accessing Transaction Receipt services

func NewTransactionReceiptService

func NewTransactionReceiptService(db *sql.DB) *TransactionReceiptService

NewTransactionReceiptService - Create Transaction Receipt service

func (*TransactionReceiptService) AddTransactionReceipt

func (t *TransactionReceiptService) AddTransactionReceipt(ctx context.Context, tx *sql.Tx, ethReceipt *types.Receipt, blockId uint, blockNumber uint64, blockHash string, transactionId uint) (*TransactionReceipt, error)

AddTransactionReceipt - add a transaction to the db

func (*TransactionReceiptService) GetTransactionReceipts

func (t *TransactionReceiptService) GetTransactionReceipts(ctx context.Context, transactionId uint) ([]*TransactionReceipt, error)

GetTransactionReceipts - used for getting receipts by TransactionId

type TransactionService

type TransactionService struct {
	Db *sql.DB
}

TransactionService - For accessing Transaction services

func NewTransactionService

func NewTransactionService(db *sql.DB) *TransactionService

NewTransactionService - Create Transaction service

func (*TransactionService) AddTransaction

func (t *TransactionService) AddTransaction(ctx context.Context, tx *sql.Tx, ethTransaction *types.Transaction, blockId uint, blockNumber uint64) (*Transaction, error)

AddTransaction - add a transaction to the db

func (*TransactionService) GetBlockTransactions

func (t *TransactionService) GetBlockTransactions(ctx context.Context, blockId uint) ([]*Transaction, error)

GetBlockTransactions - used for

Jump to

Keyboard shortcuts

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