ethereum

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const ChainName = "Ethereum"

Variables

This section is empty.

Functions

func BuildErc20Data

func BuildErc20Data(toAddress common.Address, amount *big.Int) []byte

func BuildErc721Data

func BuildErc721Data(fromAddress, toAddress common.Address, tokenId *big.Int) []byte

func CreateEip1559SignedTx

func CreateEip1559SignedTx(txData *types.DynamicFeeTx, signature []byte, chainId *big.Int) (string, string, error)

func CreateEip1559UnSignTx

func CreateEip1559UnSignTx(txData *types.DynamicFeeTx, chainId *big.Int) (string, error)

func CreateLegacySignedTx

func CreateLegacySignedTx(txData *types.LegacyTx, signature []byte, chainId *big.Int) (string, string, error)

func CreateLegacyUnSignTx

func CreateLegacyUnSignTx(txData *types.LegacyTx, chainId *big.Int) string

func NewChainAdaptor

func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)

Types

type ChainAdaptor

type ChainAdaptor struct {
	// contains filtered or unexported fields
}

func (*ChainAdaptor) BuildSignedTransaction

func (*ChainAdaptor) ConvertAddress

func (*ChainAdaptor) CreateUnSignTransaction

func (*ChainAdaptor) DecodeTransaction

func (*ChainAdaptor) GetAccount

func (*ChainAdaptor) GetBlockByHash

func (c *ChainAdaptor) GetBlockByHash(req *account.BlockHashRequest) (*account.BlockResponse, error)

func (*ChainAdaptor) GetBlockByNumber

func (c *ChainAdaptor) GetBlockByNumber(req *account.BlockNumberRequest) (*account.BlockResponse, error)

func (*ChainAdaptor) GetBlockByRange

func (*ChainAdaptor) GetBlockHeaderByHash

func (c *ChainAdaptor) GetBlockHeaderByHash(req *account.BlockHeaderHashRequest) (*account.BlockHeaderResponse, error)

func (*ChainAdaptor) GetBlockHeaderByNumber

func (c *ChainAdaptor) GetBlockHeaderByNumber(req *account.BlockHeaderNumberRequest) (*account.BlockHeaderResponse, error)

func (*ChainAdaptor) GetExtraData

func (*ChainAdaptor) GetFee

func (*ChainAdaptor) GetSupportChains

func (*ChainAdaptor) GetTxByAddress

func (*ChainAdaptor) GetTxByHash

func (c *ChainAdaptor) GetTxByHash(req *account.TxHashRequest) (*account.TxHashResponse, error)

func (*ChainAdaptor) SendTx

func (*ChainAdaptor) ValidAddress

func (*ChainAdaptor) VerifySignedTransaction

type EthClient

type EthClient interface {
	BlockHeaderByNumber(*big.Int) (*types.Header, error)

	BlockByNumber(*big.Int) (*RpcBlock, error)
	BlockByHash(common.Hash) (*RpcBlock, error)

	LatestSafeBlockHeader() (*types.Header, error)
	LatestFinalizedBlockHeader() (*types.Header, error)
	BlockHeaderByHash(common.Hash) (*types.Header, error)
	BlockHeadersByRange(*big.Int, *big.Int, uint) ([]types.Header, error)

	TxByHash(common.Hash) (*types.Transaction, error)
	TxReceiptByHash(common.Hash) (*types.Receipt, error)

	StorageHash(common.Address, *big.Int) (common.Hash, error)
	FilterLogs(filterQuery ethereum.FilterQuery, chainId uint) (Logs, error)

	TxCountByAddress(common.Address) (hexutil.Uint64, error)

	SendRawTransaction(rawTx string) error

	SuggestGasPrice() (*big.Int, error)
	SuggestGasTipCap() (*big.Int, error)

	Close()
}

func DialEthClient

func DialEthClient(ctx context.Context, rpcUrl string) (EthClient, error)

type EthData

type EthData struct {
	EthDataCli *etherscan.ChainExplorerAdaptor
}

func NewEthDataClient

func NewEthDataClient(baseUrl, apiKey string, timeout time.Duration) (*EthData, error)

func (*EthData) GetBalanceByAddress

func (ed *EthData) GetBalanceByAddress(contractAddr, address string) (*account.AccountBalanceResponse, error)

func (*EthData) GetTxByAddress

func (ed *EthData) GetTxByAddress(page, pagesize uint64, address string, action account.ActionType) (*account.TransactionResponse[account.AccountTxResponse], error)

type Logs

type Logs struct {
	Logs          []types.Log
	ToBlockHeader *types.Header
}

type RPC

type RPC interface {
	Close()
	CallContext(ctx context.Context, result any, method string, args ...any) error
	BatchCallContext(ctx context.Context, b []rpc.BatchElem) error
}

func NewRPC

func NewRPC(client *rpc.Client) RPC

type RpcBlock

type RpcBlock struct {
	Hash         common.Hash       `json:"hash"`
	Height       uint64            `json:"height"`
	Transactions []TransactionList `json:"transactions"`
	BaseFee      string            `json:"baseFeePerGas"`
}

type TransactionList

type TransactionList struct {
	From  string `json:"from"`
	To    string `json:"to"`
	Hash  string `json:"hash"`
	Value string `json:"value"`
}

type TxStructure

type TxStructure struct {
	ChainId         string `json:"chain_id"`
	Nonce           uint64 `json:"nonce"`
	GasPrice        string `json:"gas_price"`
	GasTipCap       string `json:"gas_tip_cap"`
	GasFeeCap       string `json:"gas_fee_cap"`
	Gas             uint64 `json:"gas"`
	ContractAddress string `json:"contract_address"`
	FromAddress     string `json:"from_address"`
	ToAddress       string `json:"to_address"`
	TokenId         string `json:"token_id"`
	Value           string `json:"value"`
}

Jump to

Keyboard shortcuts

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