ethereum

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Optimism
	// https://github.com/Inphi/optimism-rosetta/blob/d3c37e359fa4262a2a53014c424a8ae53efaf3d0/optimism/client_bedrock.go#L138
	TransactionTypeOptimismDeposit = 0x7E

	// Arbitrum
	// https://github.com/OffchainLabs/go-ethereum/blob/08bf9b119ff9c47ad51d507969997ff9cd8c5328/core/types/transaction.go#L45-L59
	TransactionTypeArbitrumDeposit         = 0x64
	TransactionTypeArbitrumUnsigned        = 0x65
	TransactionTypeArbitrumContract        = 0x66
	TransactionTypeArbitrumRetry           = 0x68
	TransactionTypeArbitrumSubmitRetryable = 0x69
	TransactionTypeArbitrumInternal        = 0x6A
	TransactionTypeArbitrumLegacy          = 0x78
)

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)
	BatchBlockByNumbers(ctx context.Context, numbers []*big.Int) ([]*Block, error)
	BlockReceipts(ctx context.Context, number *big.Int) ([]*Receipt, error)
	BatchBlockReceipts(ctx context.Context, numbers []*big.Int) ([][]*Receipt, error)
	TransactionByHash(ctx context.Context, hash common.Hash) (*Transaction, error)
	TransactionReceipt(ctx context.Context, hash common.Hash) (*Receipt, error)
	BatchTransactionReceipt(ctx context.Context, hashes []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, options ...Option) (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 Option added in v0.4.20

type Option = func(ctx context.Context, client *client) error

Option used to configure the client with additional options.

func WithHTTP2Disabled added in v0.4.21

func WithHTTP2Disabled() Option

WithHTTP2Disabled sets the HTTP2 client to be disabled.

func WithHTTPHeader added in v0.4.20

func WithHTTPHeader(httpHeader map[string]string) Option

WithHTTPHeader sets the HTTP header for the client. The header can be used to set the authorization token and other headers.

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