types

package
v0.23.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLength = 20
View Source
const BloomLength = 256
View Source
const HashLength = 32
View Source
const NonceLength = 8

Variables

View Source
var (
	EarliestBlockNumber = BlockNumber{/* contains filtered or unexported fields */}
	LatestBlockNumber   = BlockNumber{/* contains filtered or unexported fields */}
	PendingBlockNumber  = BlockNumber{/* contains filtered or unexported fields */}
)

Functions

This section is empty.

Types

type Address

type Address [AddressLength]byte

Address represents the 20 byte address of an Ethereum account.

func BytesToAddress

func BytesToAddress(bts []byte) Address

BytesToAddress returns an Address from a byte slice.

func HexToAddress

func HexToAddress(hex string) Address

HexToAddress parses a hex string into an Address.

func (*Address) Bytes

func (t *Address) Bytes() []byte

Bytes returns the byte representation of the address.

func (Address) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (Address) MarshalText

func (t Address) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Address) String

func (t *Address) String() string

String returns the hex string representation of the address.

func (*Address) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

func (*Address) UnmarshalText

func (t *Address) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Addresses

type Addresses []Address

Addresses is a slice of Address.

func HexToAddresses

func HexToAddresses(addresses ...string) Addresses

HexToAddresses parses a list of hex strings into Addresses.

func (Addresses) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (*Addresses) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type Block

type Block struct {
	Number           Number  `json:"number"`
	Hash             Hash    `json:"hash"`
	ParentHash       Hash    `json:"parentHash"`
	Nonce            Nonce   `json:"nonce"`
	Sha3Uncles       Hash    `json:"sha3Uncles"`
	LogsBloom        Bloom   `json:"logsBloom"`
	TransactionsRoot Hash    `json:"transactionsRoot"`
	StateRoot        Hash    `json:"stateRoot"`
	ReceiptsRoot     Hash    `json:"receiptsRoot"`
	Miner            Address `json:"miner"`
	MixHash          Hash    `json:"mixHash"`
	Difficulty       Number  `json:"difficulty"`
	TotalDifficulty  Number  `json:"totalDifficulty"`
	ExtraData        Bytes   `json:"extraData"`
	Size             Number  `json:"size"`
	GasLimit         Number  `json:"gasLimit"`
	GasUsed          Number  `json:"gasUsed"`
	Timestamp        Number  `json:"timestamp"`
	Uncles           []Hash  `json:"uncles"`
}

Block represents an Ethereum block.

type BlockNumber

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

BlockNumber is a type that can hold a block number or a tag.

func BigToBlockNumber

func BigToBlockNumber(x *big.Int) BlockNumber

BigToBlockNumber converts a big.Int to a BlockNumber.

func StringToBlockNumber

func StringToBlockNumber(str string) BlockNumber

StringToBlockNumber converts a string to a BlockNumber. A string can be a hex number, "earliest", "latest" or "pending".

func Uint64ToBlockNumber

func Uint64ToBlockNumber(x uint64) BlockNumber

Uint64ToBlockNumber converts a uint64 to a BlockNumber.

func (*BlockNumber) Big

func (t *BlockNumber) Big() *big.Int

func (*BlockNumber) IsEarliest

func (t *BlockNumber) IsEarliest() bool

func (*BlockNumber) IsLatest

func (t *BlockNumber) IsLatest() bool

func (*BlockNumber) IsPending

func (t *BlockNumber) IsPending() bool

func (*BlockNumber) IsTag

func (t *BlockNumber) IsTag() bool

func (BlockNumber) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (BlockNumber) MarshalText

func (t BlockNumber) MarshalText() ([]byte, error)

func (*BlockNumber) String

func (t *BlockNumber) String() string

func (*BlockNumber) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

func (*BlockNumber) UnmarshalText

func (t *BlockNumber) UnmarshalText(input []byte) error

type BlockTxHashes

type BlockTxHashes struct {
	Block
	Transactions []Hash `json:"transactions"`
}

BlockTxHashes represents Ethereum block with transaction hashes.

type BlockTxObjects

type BlockTxObjects struct {
	Block
	Transactions []Transaction `json:"transactions"`
}

BlockTxObjects represents Ethereum block with full transactions.

type Bloom

type Bloom [BloomLength]byte

Bloom represents a 2048 bit bloom filter.

func BytesToBloom

func BytesToBloom(bts []byte) Bloom

BytesToBloom converts a byte slice to a Bloom.

func (Bloom) MarshalJSON

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

MarshalJSON implements the json.Marshaler interface.

func (Bloom) MarshalText

func (t Bloom) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface.

func (*Bloom) String

func (t *Bloom) String() string

String returns the hex string representation of the bloom.

func (*Bloom) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Bloom) UnmarshalText

func (t *Bloom) UnmarshalText(input []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

type Bytes

type Bytes []byte

Bytes represents a byte slice.

func HexToBytes

func HexToBytes(hex string) Bytes

HexToBytes parses a hex string into a Bytes.

func (*Bytes) Bytes

func (t *Bytes) Bytes() []byte

Bytes represents a byte slice.

func (Bytes) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (Bytes) MarshalText

func (t Bytes) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Bytes) String

func (t *Bytes) String() string

func (*Bytes) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

func (*Bytes) UnmarshalText

func (t *Bytes) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type FeeHistory

type FeeHistory struct {
	OldestBlock   Number     `json:"oldestBlock"`
	Reward        [][]Number `json:"reward"`
	BaseFeePerGas []Number   `json:"baseFeePerGas"`
	GasUsedRatio  []float64  `json:"gasUsedRatio"`
}

FeeHistory represents the result of the feeHistory RPC call.

type FilterLogsQuery

type FilterLogsQuery struct {
	Address   Addresses    `json:"address"`
	FromBlock *BlockNumber `json:"fromBlock,omitempty"`
	ToBlock   *BlockNumber `json:"toBlock,omitempty"`
	Topics    []Hashes     `json:"topics"`
	BlockHash *Hash        `json:"blockhash,omitempty"`
}

FilterLogsQuery represents a query to filter logs.

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte Keccak256 hash of arbitrary data.

func BytesToHash

func BytesToHash(bts []byte) Hash

BytesToHash returns the hash corresponding to the byte slice.

func HexToHash

func HexToHash(hex string) Hash

HexToHash returns the hash corresponding to the hexadecimal string.

func (*Hash) Bytes

func (t *Hash) Bytes() []byte

Bytes returns the byte representation of the hash.

func (Hash) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (Hash) MarshalText

func (t Hash) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Hash) String

func (t *Hash) String() string

String returns the hex string representation of the hash.

func (*Hash) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

func (*Hash) UnmarshalText

func (t *Hash) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Hashes

type Hashes []Hash

Hashes marshals/unmarshals as hash.

func HexToHashes

func HexToHashes(hashes ...string) Hashes

HexToHashes returns the hashes corresponding to the hexadecimal strings.

func (Hashes) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (*Hashes) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type Log

type Log struct {
	Address     Address `json:"address"`
	Topics      []Hash  `json:"topics"`
	Data        Bytes   `json:"data"`
	BlockHash   Hash    `json:"blockHash"`
	BlockNumber Number  `json:"blockNumber"`
	TxHash      Hash    `json:"transactionHash"`
	TxIndex     Number  `json:"transactionIndex"`
	LogIndex    Number  `json:"logIndex"`
	Removed     bool    `json:"removed"`
}

Log represents a contract log event.

type Nonce

type Nonce [NonceLength]byte

Nonce represents a 64 bit nonce.

func BytesToNonce

func BytesToNonce(b []byte) Nonce

BytesToNonce converts a byte slice to a Nonce.

func HexToNonce

func HexToNonce(hex string) Nonce

func (Nonce) MarshalJSON

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

func (Nonce) MarshalText

func (t Nonce) MarshalText() ([]byte, error)

func (*Nonce) String

func (t *Nonce) String() string

func (*Nonce) UnmarshalJSON

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

func (*Nonce) UnmarshalText

func (t *Nonce) UnmarshalText(input []byte) error

type Number

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

Number represents an integer up to 256 bits.

func BigToNumber

func BigToNumber(x *big.Int) Number

BigToNumber converts a big.Int to a Number.

func HexToNumber

func HexToNumber(hex string) Number

func Uint64ToNumber

func Uint64ToNumber(x uint64) Number

Uint64ToNumber converts an uint64 to a Number.

func (*Number) Big

func (t *Number) Big() *big.Int

func (Number) MarshalJSON

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

MarshalJSON implements json.Marshaler.

func (Number) MarshalText

func (t Number) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*Number) String

func (t *Number) String() string

func (*Number) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

func (*Number) UnmarshalText

func (t *Number) UnmarshalText(input []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Transaction

type Transaction struct {
	Hash             Hash    `json:"hash"`
	BlockHash        Hash    `json:"blockHash"`
	BlockNumber      Number  `json:"blockNumber"`
	TransactionIndex Number  `json:"transactionIndex"`
	From             Address `json:"from"`
	To               Address `json:"to"`
	Gas              Number  `json:"gas"`
	GasPrice         Number  `json:"gasPrice"`
	Input            Bytes   `json:"input"`
	Nonce            Number  `json:"nonce"`
	Value            Number  `json:"value"`
	V                Number  `json:"v"`
	R                Number  `json:"r"`
	S                Number  `json:"s"`
}

Transaction represents a transaction.

type TransactionReceiptType

type TransactionReceiptType struct {
	TransactionHash   Hash     `json:"transactionHash"`
	TransactionIndex  Number   `json:"transactionIndex"`
	BlockHash         Hash     `json:"blockHash"`
	BlockNumber       Number   `json:"blockNumber"`
	From              Address  `json:"from"`
	To                Address  `json:"to"`
	CumulativeGasUsed Number   `json:"cumulativeGasUsed"`
	GasUsed           Number   `json:"gasUsed"`
	ContractAddress   *Address `json:"contractAddress"`
	Logs              []Log    `json:"logs"`
	LogsBloom         Bytes    `json:"logsBloom"`
	Root              *Hash    `json:"root"`
	Status            *Number  `json:"status"`
}

TransactionReceiptType represents transaction receipt.

Jump to

Keyboard shortcuts

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