ethereum

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var (
	AddressGenesis = common.HexToAddress("0x0000000000000000000000000000000000000000")
	HashGenesis    = common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000")
)

Functions

func IsBurnAddress

func IsBurnAddress(address common.Address) bool

IsBurnAddress will return whether the current address is a black hole address, most of which are provided by https://etherscan.io/accounts/label/burn.

Types

type Block

type Block struct {
	Hash         common.Hash    `json:"hash"`
	ParentHash   common.Hash    `json:"parentHash"`
	UncleHash    common.Hash    `json:"sha3Uncles"`
	Coinbase     common.Address `json:"miner"`
	Number       *big.Int       `json:"number"`
	GasLimit     uint64         `json:"gasLimit"`
	GasUsed      uint64         `json:"gasUsed"`
	Timestamp    uint64         `json:"timestamp"`
	BaseFee      *big.Int       `json:"baseFeePerGas"`
	Transactions []*Transaction `json:"transactions"`
}

func (Block) Header

func (b Block) Header() *Header

func (Block) MarshalJSON

func (b Block) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Client

type Client interface {
	// ContractCaller is used for compatibility with abigen generated contract callers.
	bind.ContractCaller

	ChainID(ctx context.Context) (*big.Int, error)
	BlockNumber(ctx context.Context) (*big.Int, error)
	HeaderByHash(ctx context.Context, hash common.Hash) (*Header, error)
	HeaderByNumber(ctx context.Context, number *big.Int) (*Header, error)
	BlockByHash(ctx context.Context, hash common.Hash) (*Block, error)
	BlockByNumber(ctx context.Context, number *big.Int) (*Block, error)
	BlockReceipts(ctx context.Context, number *big.Int) ([]*Receipt, error)
	TransactionByHash(ctx context.Context, hash common.Hash) (*Transaction, error)
	TransactionReceipt(ctx context.Context, hash common.Hash) (*Receipt, error)
	StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNumber *big.Int) ([]byte, error)
	FilterLogs(ctx context.Context, filter Filter) ([]*Log, error)
}

Client provides basic RPC methods.

func Dial

func Dial(ctx context.Context, endpoint string) (Client, error)

Dial creates a new client for the given endpoint.

type Filter

type Filter struct {
	BlockHash *common.Hash     `json:"blockHash"`
	FromBlock *big.Int         `json:"fromBlock"`
	ToBlock   *big.Int         `json:"toBlock"`
	Addresses []common.Address `json:"addresses"`
	Topics    [][]common.Hash  `json:"topics"`
}
type Header struct {
	Hash         common.Hash    `json:"hash"`
	ParentHash   common.Hash    `json:"parentHash"`
	UncleHash    common.Hash    `json:"sha3Uncles"`
	Coinbase     common.Address `json:"miner"`
	Number       *big.Int       `json:"number"`
	GasLimit     uint64         `json:"gasLimit"`
	GasUsed      uint64         `json:"gasUsed"`
	Timestamp    uint64         `json:"timestamp"`
	BaseFee      *big.Int       `json:"baseFeePerGas"`
	Transactions []common.Hash  `json:"transactions"`
}

func (Header) MarshalJSON

func (h Header) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Log

type Log struct {
	Address          common.Address `json:"address"`
	Topics           []common.Hash  `json:"topics"`
	Data             []byte         `json:"data"`
	BlockNumber      *big.Int       `json:"blockNumber"`
	TransactionHash  common.Hash    `json:"transactionHash"`
	TransactionIndex uint           `json:"transactionIndex"`
	BlockHash        common.Hash    `json:"blockHash"`
	Index            uint           `json:"logIndex"`
	Removed          bool           `json:"removed"`
}

func (Log) Export

func (l Log) Export() types.Log

func (Log) MarshalJSON

func (l Log) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Receipt

type Receipt struct {
	BlockHash         common.Hash     `json:"blockHash"`
	BlockNumber       *big.Int        `json:"blockNumber"`
	ContractAddress   *common.Address `json:"contractAddress"`
	CumulativeGasUsed uint64          `json:"cumulativeGasUsed"`
	EffectiveGasPrice *big.Int        `json:"effectiveGasPrice"`
	GasUsed           uint64          `json:"gasUsed"`

	// Optimism
	L1GasPrice *big.Int   `json:"l1GasPrice,omitempty"`
	L1GasUsed  *big.Int   `json:"l1GasUsed,omitempty"`
	L1Fee      *big.Int   `json:"l1Fee,omitempty"`
	FeeScalar  *big.Float `json:"l1FeeScalar,omitempty"`

	Logs             []*Log      `json:"logs"`
	Status           uint64      `json:"status"`
	TransactionHash  common.Hash `json:"transactionHash"`
	TransactionIndex uint        `json:"transactionIndex"`
}

func (Receipt) MarshalJSON

func (r Receipt) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Receipt) UnmarshalJSON

func (r *Receipt) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type Transaction

type Transaction struct {
	BlockHash   common.Hash     `json:"blockHash"`
	BlockNumber *big.Int        `json:"blockNumber"`
	From        common.Address  `json:"from"`
	Gas         uint64          `json:"gas"`
	GasPrice    *big.Int        `json:"gasPrice"`
	GasTipCap   *big.Int        `json:"maxPriorityFeePerGas"`
	Hash        common.Hash     `json:"hash"`
	Input       []byte          `json:"input"`
	To          *common.Address `json:"to"`
	Index       uint            `json:"index"`
	Value       *big.Int        `json:"value"`
	Type        uint64          `json:"type"`
	ChainID     *big.Int        `json:"chainId"`
}

func (Transaction) MarshalJSON

func (t Transaction) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type TransactionCall

type TransactionCall struct {
	From     common.Address  `json:"from"`
	To       *common.Address `json:"to,omitempty"`
	Gas      uint64          `json:"gas,omitempty"`
	GasPrice *big.Int        `json:"gasPrice,omitempty"`
	Value    *big.Int        `json:"value,omitempty"`
	Data     []byte          `json:"data,omitempty"`
}

func (TransactionCall) MarshalJSON

func (t TransactionCall) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*TransactionCall) UnmarshalJSON

func (t *TransactionCall) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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