Documentation
¶
Overview ¶
Package ethtypes provides a collection of common Ethereum types implemented in Go. These types are essential for building various tools and modules within the Ethereum ecosystem. The library aims to standardize and simplify the development process by offering a consistent set of types that can be reused across different projects.
Index ¶
- Constants
- Variables
- type AccessList
- type AccessListEntry
- type Account
- type Address
- type Authorization
- type AuthorizationList
- type Block
- type Bloom
- type Hash
- type Header
- func (h *Header) BaseFeePerGas() *big.Int
- func (h *Header) Beneficiary() Address
- func (h *Header) BlobGasUsed() uint64
- func (h *Header) Difficulty() uint64
- func (h *Header) ExcessBlobGas() uint64
- func (h *Header) ExtraData() []byte
- func (h *Header) FromProto(pb *ethProto.Header) error
- func (h *Header) GasLimit() uint64
- func (h *Header) GasUsed() uint64
- func (h *Header) Hash() Hash
- func (h *Header) LogsBloom() Bloom
- func (h *Header) MixDigest() Hash
- func (h *Header) Nonce() uint64
- func (h *Header) Number() uint64
- func (h *Header) ParentBeaconBlockRoot() Hash
- func (h *Header) ParentHash() Hash
- func (h *Header) ReceiptsRoot() Hash
- func (h *Header) RequestsHash() Hash
- func (h *Header) StateRoot() Hash
- func (h *Header) Timestamp() int64
- func (h *Header) ToProto() (*ethProto.Header, error)
- func (h *Header) ToRLP() ([]byte, error)
- func (h *Header) TransactionsRoot() Hash
- func (h *Header) UncleHash() Hash
- func (h *Header) WithdrawalsRoot() Hash
- type HeaderEIP1559
- type HeaderEIP4844
- type HeaderEIP4895
- type HeaderEIP7685
- type HeaderLegacy
- type Log
- type Receipt
- type Transaction
- func (t *Transaction) AccessList() AccessList
- func (t *Transaction) AuthorizationList() AuthorizationList
- func (t *Transaction) BlobVersionedHashes() []Hash
- func (t *Transaction) ChainID() *big.Int
- func (t *Transaction) Cost() *big.Int
- func (t *Transaction) Data() []byte
- func (t *Transaction) From() (Address, error)
- func (t *Transaction) FromProto(pb *txProto.Transaction) error
- func (t *Transaction) Gas() uint64
- func (t *Transaction) GasPrice() *big.Int
- func (t *Transaction) Hash() Hash
- func (t *Transaction) MaxFeePerBlobGas() *big.Int
- func (t *Transaction) MaxFeePerGas() *big.Int
- func (t *Transaction) MaxPriorityFeePerGas() *big.Int
- func (t *Transaction) Nonce() uint64
- func (t *Transaction) SigValues() (v, r, s *big.Int)
- func (t *Transaction) To() *Address
- func (t *Transaction) ToProto() (*txProto.Transaction, error)
- func (t *Transaction) ToRLP() ([]byte, error)
- func (t *Transaction) ToSignedRLP() ([]byte, error)
- func (t *Transaction) TxHash() (Hash, error)
- func (t *Transaction) Type() byte
- func (t *Transaction) Value() *big.Int
- type TxEIP1559
- type TxEIP2930
- type TxEIP4844
- type TxEIP7702
- type TxLegacy
- type Withdrawal
Constants ¶
const ( TransactionLegacy = 0x00 Transaction2930 = 0x01 Transaction1559 = 0x02 Transaction4844 = 0x03 Transaction7702 = 0x04 )
const BloomByteLength = 256
Variables ¶
var ( // ZeroStorageHash is the historical Ethereum MPT value (empty trie root) ZeroStorageHash = StringToHash("0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") ZeroCodeHash = BytesToHash(keccak.New().Hash([]byte{})) // ZeroOmmerHash is the historical Ethereum MPT value (empty ommers) (keccak256(rlp([])) ZeroOmmerHash = BytesToHash(keccak.New().Hash(ethrlp.EncodeArray([][]byte{}))) )
var ( ErrNilProtoBlock = errors.New("proto block is nil") ErrNilBlockHeader = errors.New("block header is nil") ErrUnexpectedWithdrawals = errors.New("withdrawals on a pre-Shanghai block") )
var ( ErrNilProtoReceipt = errors.New("proto receipt is nil") ErrNilProtoLog = errors.New("proto log is nil") ErrInvalidLogRLPAddress = errors.New("invalid log RLP address encoding") ErrInvalidLogRLPData = errors.New("invalid log RLP data encoding") ErrInvalidLogRLPTopics = errors.New("invalid log RLP topics encoding") ErrInvalidReceiptType = errors.New("invalid receipt type") ErrInvalidReceiptRLPStatus = errors.New("invalid receipt RLP status encoding") ErrInvalidReceiptRLPGasUsed = errors.New("invalid receipt RLP cumulative gas used encoding") ErrInvalidReceiptRLPLogsBloom = errors.New("invalid receipt RLP logs bloom encoding") ErrInvalidReceiptRLPLogs = errors.New("invalid receipt RLP logs encoding") )
var ( ErrInvalidRLPChainID = errors.New("invalid chain ID RLP encoding") ErrInvalidRLPMaxPriorityFee = errors.New("invalid max priority fee per gas RLP encoding") ErrInvalidRLPMaxFeePerGas = errors.New("invalid max fee per gas RLP encoding") ErrInvalidRLPAccessList = errors.New("invalid access list RLP encoding") ErrInvalidRLPYParity = errors.New("invalid y parity param RLP encoding") ErrInvalidProtoEIP1559Tx = errors.New("invalid proto EIP-1559 tx payload") )
var ( ErrInvalidRLPMaxFeePerBlobGas = errors.New("invalid max fee per blob gas RLP encoding") ErrInvalidRLPBlobVersionedHashes = errors.New("invalid blob versioned hashes RLP encoding") ErrInvalidProtoEIP4844Tx = errors.New("invalid proto EIP-4844 tx payload") )
var ( ErrInvalidRLPAuthorizationList = errors.New("invalid authorization list RLP encoding") ErrInvalidProtoEIP7702Tx = errors.New("invalid proto EIP-7702 tx payload") )
var ( ErrInvalidRLPNonce = errors.New("invalid nonce RLP encoding") ErrInvalidRLPGasPrice = errors.New("invalid gas price RLP encoding") ErrInvalidRLPGasLimit = errors.New("invalid gas limit RLP encoding") ErrInvalidRLPTo = errors.New("invalid to address RLP encoding") ErrInvalidRLPValue = errors.New("invalid value RLP encoding") ErrInvalidRLPData = errors.New("invalid data RLP encoding") ErrInvalidRLPVParam = errors.New("invalid v sig param RLP encoding") ErrInvalidRLPRParam = errors.New("invalid r sig param RLP encoding") ErrInvalidRLPSParam = errors.New("invalid s sig param RLP encoding") ErrNilProtoTx = errors.New("proto transaction is nil") ErrInvalidProtoLegacyTx = errors.New("invalid proto legacy tx payload") )
var ErrInvalidHeaderPayload = errors.New("invalid header payload type")
var ErrInvalidProtoEIP2930Tx = errors.New("invalid proto EIP-2930 tx payload")
var ErrInvalidRLPAuthorizationAddress = errors.New("invalid authorization address RLP encoding")
var ErrNilProtoAcc = errors.New("proto account is nil")
var ErrNilProtoHeader = errors.New("proto header is nil")
var ErrNilProtoWithdrawal = errors.New("proto withdrawal is nil")
var ZeroAddress = Address{}
ZeroAddress represents a placeholder address value that contains all zero bytes
var ZeroHash = Hash{}
ZeroHash represents a placeholder hash value that contains all zero bytes
Functions ¶
This section is empty.
Types ¶
type AccessList ¶ added in v0.2.0
type AccessList []AccessListEntry
AccessList is a wrapper for access list entries
func (*AccessList) FromProto ¶ added in v0.2.0
func (l *AccessList) FromProto(protoList []*txProto.AccessListEntry)
FromProto parses the access list from the proto representation
func (*AccessList) FromRLP ¶ added in v0.2.0
func (l *AccessList) FromRLP(data []byte) error
FromRLP parses the RLP encoding of an access list
func (*AccessList) FromRLPValues ¶ added in v0.2.0
func (l *AccessList) FromRLPValues(listValues []ethrlp.Value) error
FromRLPValues parses the raw RLP values of an access list
func (AccessList) ToProto ¶ added in v0.2.0
func (l AccessList) ToProto() []*txProto.AccessListEntry
ToProto converts the access list to a proto representation
func (AccessList) ToRLP ¶ added in v0.2.0
func (l AccessList) ToRLP() []byte
ToRLP encodes the access list to RLP (RLP list)
type AccessListEntry ¶
type AccessListEntry struct {
StorageKeys []Hash `json:"storageKeys"`
Address Address `json:"address"`
}
AccessListEntry is a single access list entry, denoting the accessed storage keys (hashes) and address
func (*AccessListEntry) FromProto ¶ added in v0.2.0
func (e *AccessListEntry) FromProto(protoEntry *txProto.AccessListEntry)
FromProto parses the proto representation of an access list entry
func (*AccessListEntry) FromRLP ¶ added in v0.2.0
func (e *AccessListEntry) FromRLP(data []byte) error
FromRLP parses the RLP encoding of a single access list entry
func (AccessListEntry) ToProto ¶ added in v0.2.0
func (e AccessListEntry) ToProto() *txProto.AccessListEntry
ToProto converts the single access list entry to a proto representation
func (AccessListEntry) ToRLP ¶ added in v0.2.0
func (e AccessListEntry) ToRLP() []byte
ToRLP encodes the single access list entry to RLP (RLP Bytes)
type Account ¶ added in v0.2.0
type Account struct {
Balance *big.Int // balance in wei
Nonce uint64 // account sequence
StorageRoot Hash // hash of the root node of the account storage trie. Empty account storage is ZeroStorageHash
CodeHash Hash // hash of the EVM code of this account. For EOAs, this is the hash of an empty string
}
Account is a single Ethereum account representation
func (*Account) FromProto ¶ added in v0.3.0
FromProto loads the account data from the given proto representation
func (*Account) IsEOA ¶ added in v0.2.0
IsEOA returns a flag indicating if an account is an EOA (Externally Owned Account). Conditions for an account being an EOA:
1. The storage root is empty (zero hash)
2. The code hash is the keccak hash of an empty string
type Address ¶
type Address [addressSize]byte
func BytesToAddress ¶
BytesToAddress converts the specified address bytes into an Address representation (20B)
func StringToAddress ¶
StringToAddress converts the specified address string into an Address representation
type Authorization ¶ added in v0.3.1
type Authorization struct {
ChainID *big.Int // the ID of the chain (0 for any chain)
YParity, R, S *big.Int // the signature fields (y parity is {0, 1})
Address Address // the address of the delegated code
Nonce uint64 // the signer nonce
}
Authorization is a single signed code delegation, introduced as part of EIP-7702
type AuthorizationList ¶ added in v0.3.1
type AuthorizationList []Authorization
AuthorizationList is a wrapper for authorization entries
type Block ¶
type Block struct {
Header *Header // Associated block header
Transactions []*Transaction // List of transactions included in the block
Uncles []*Header // List of uncle headers included in the block
Withdrawals []Withdrawal // List of validator withdrawals included in the block
}
Block is a single Ethereum block, containing the header, transactions, uncles and withdrawals
func (*Block) FromProto ¶ added in v0.3.0
FromProto converts a proto Block to a block representation
type Bloom ¶
type Bloom [BloomByteLength]byte
Bloom represents an Ethereum bloom filter (for logs)
func BytesToBloom ¶ added in v0.3.0
BytesToBloom sets the bloom filter from a byte slice. If the input is not exactly 256 bytes, an empty bloom is returned
func LogsBloom ¶ added in v0.3.0
LogsBloom obtains the logs bloom from a list of log entries. The address and each topic of a log are added to the bloom filter
func NewBloom ¶ added in v0.3.0
func NewBloom() Bloom
NewBloom creates an empty Ethereum bloom filter
func (*Bloom) Test ¶ added in v0.3.0
Test checks if the given data might be in the bloom filter Returns:
- true: data might be in the set (possible false positive)
- false: data is definitely not in the set
type Hash ¶
type Hash [hashSize]byte
func BytesToHash ¶
BytesToHash converts the specified hash bytes into a Hash representation (32B)
func StringToHash ¶
StringToHash converts the specified hash string into a Hash representation
type Header ¶
type Header struct {
// contains filtered or unexported fields
}
Header is the
func NewHeader ¶ added in v0.3.0
func NewHeader(inner headerData) *Header
NewHeader creates a new header wrapper
func (*Header) BaseFeePerGas ¶ added in v0.3.0
func (*Header) Beneficiary ¶
func (*Header) BlobGasUsed ¶ added in v0.3.1
func (*Header) Difficulty ¶
func (*Header) ExcessBlobGas ¶ added in v0.3.1
func (*Header) ParentBeaconBlockRoot ¶ added in v0.3.1
func (*Header) ParentHash ¶
func (*Header) ReceiptsRoot ¶
func (*Header) RequestsHash ¶ added in v0.3.1
func (*Header) TransactionsRoot ¶
func (*Header) WithdrawalsRoot ¶ added in v0.3.0
type HeaderEIP1559 ¶ added in v0.3.0
type HeaderEIP1559 struct {
BaseFeePerGas *big.Int // Base fee per gas unit for EIP-1559 blocks
ExtraData []byte // Extra data field, often used for creator-encoded information
LogsBloom Bloom // Bloom filter for quick searching of logs in the block
ParentHash Hash // Hash of the previous block (the parent block)
UncleHash Hash // Hash of the uncles block list
StateRoot Hash // Root of the state trie (Ethereum state at the end of this block)
TransactionsRoot Hash // Root of the transactions trie (all transactions for this block)
ReceiptsRoot Hash // Root of the receipts trie (all transaction receipts for this block)
MixDigest Hash // Hash used in the proof-of-work algorithm (before Ethereum 2.0)
Coinbase Address // Address of the block creator
Difficulty uint64 // The difficulty of mining the block
Number uint64 // The block number (height of the block in the chain)
GasLimit uint64 // Gas limit for the block
GasUsed uint64 // Total gas used by all transactions in the block
Nonce uint64 // Random value used by the miner in proof-of-work (before Ethereum 2.0)
Timestamp int64 // Timestamp when the block was created
}
HeaderEIP1559 represents the EIP-1559 header, introduced as part of EIP-1559 (London hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md
func (*HeaderEIP1559) FromProto ¶ added in v0.3.0
func (h *HeaderEIP1559) FromProto(pb *ethProto.Header) error
FromProto converts a protobuf Header to an EIP-1559 header
func (*HeaderEIP1559) Hash ¶ added in v0.3.0
func (h *HeaderEIP1559) Hash() Hash
Hash constructs the EIP-1559 header hash. The hash is the keccak of the header's RLP encoding
func (*HeaderEIP1559) ToProto ¶ added in v0.3.0
func (h *HeaderEIP1559) ToProto() *ethProto.Header
ToProto converts an EIP-1559 header proto to a protobuf Header
func (*HeaderEIP1559) ToRLP ¶ added in v0.3.0
func (h *HeaderEIP1559) ToRLP() []byte
ToRLP encodes the EIP-1559 header using RLP encoding.
- RLP: [parentHash, unclesHash, coinbase, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas]
type HeaderEIP4844 ¶ added in v0.3.1
type HeaderEIP4844 struct {
BaseFeePerGas *big.Int // Base fee per gas unit for EIP-1559 blocks
ExtraData []byte // Extra data field, often used for creator-encoded information
LogsBloom Bloom // Bloom filter for quick searching of logs in the block
ParentHash Hash // Hash of the previous block (the parent block)
UncleHash Hash // Hash of the uncles block list
StateRoot Hash // Root of the state trie (Ethereum state at the end of this block)
TransactionsRoot Hash // Root of the transactions trie (all transactions for this block)
ReceiptsRoot Hash // Root of the receipts trie (all transaction receipts for this block)
MixDigest Hash // Hash used in the proof-of-work algorithm (RANDAO value after the merge)
WithdrawalsRoot Hash // Root of the withdrawals trie (for withdrawals from validators)
ParentBeaconBlockRoot Hash // Root of the parent beacon block
Coinbase Address // Address of the block creator
Difficulty uint64 // The difficulty of mining the block (0 after the merge)
Number uint64 // The block number (height of the block in the chain)
GasLimit uint64 // Gas limit for the block
GasUsed uint64 // Total gas used by all transactions in the block
Nonce uint64 // Random value used by the miner in proof-of-work (0 after the merge)
BlobGasUsed uint64 // Total blob gas used by all transactions in the block
ExcessBlobGas uint64 // Excess blob gas, used to calculate the blob base fee
Timestamp int64 // Timestamp when the block was created
}
HeaderEIP4844 represents the EIP-4844 header, introduced as part of EIP-4844 and EIP-4788 (Cancun hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4844.md https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4788.md
func (*HeaderEIP4844) FromProto ¶ added in v0.3.1
func (h *HeaderEIP4844) FromProto(pb *ethProto.Header) error
FromProto converts a protobuf Header to an EIP-4844 header
func (*HeaderEIP4844) Hash ¶ added in v0.3.1
func (h *HeaderEIP4844) Hash() Hash
Hash constructs the EIP-4844 header hash. The hash is the keccak of the header's RLP encoding
func (*HeaderEIP4844) ToProto ¶ added in v0.3.1
func (h *HeaderEIP4844) ToProto() *ethProto.Header
ToProto converts an EIP-4844 header to a protobuf Header
func (*HeaderEIP4844) ToRLP ¶ added in v0.3.1
func (h *HeaderEIP4844) ToRLP() []byte
ToRLP encodes the EIP-4844 header using RLP encoding.
- RLP: [parentHash, unclesHash, coinbase, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, withdrawalsRoot, blobGasUsed, excessBlobGas, parentBeaconBlockRoot]
type HeaderEIP4895 ¶ added in v0.3.0
type HeaderEIP4895 struct {
BaseFeePerGas *big.Int // Base fee per gas unit for EIP-1559 blocks
ExtraData []byte // Extra data field, often used for creator-encoded information
LogsBloom Bloom // Bloom filter for quick searching of logs in the block
ParentHash Hash // Hash of the previous block (the parent block)
UncleHash Hash // Hash of the uncles block list
StateRoot Hash // Root of the state trie (Ethereum state at the end of this block)
TransactionsRoot Hash // Root of the transactions trie (all transactions for this block)
ReceiptsRoot Hash // Root of the receipts trie (all transaction receipts for this block)
MixDigest Hash // Hash used in the proof-of-work algorithm (before Ethereum 2.0)
WithdrawalsRoot Hash // Root of the withdrawals trie (for withdrawals from validators)
Coinbase Address // Address of the block creator
Difficulty uint64 // The difficulty of mining the block
Number uint64 // The block number (height of the block in the chain)
GasLimit uint64 // Gas limit for the block
GasUsed uint64 // Total gas used by all transactions in the block
Nonce uint64 // Random value used by the miner in proof-of-work (before Ethereum 2.0)
Timestamp int64 // Timestamp when the block was created
}
HeaderEIP4895 represents the EIP-4895 header, introduced as part of EIP-4895 (Shanghai hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4895.md
func (*HeaderEIP4895) FromProto ¶ added in v0.3.0
func (h *HeaderEIP4895) FromProto(pb *ethProto.Header) error
FromProto converts a protobuf Header to an EIP-4895 header
func (*HeaderEIP4895) Hash ¶ added in v0.3.0
func (h *HeaderEIP4895) Hash() Hash
Hash constructs the EIP-4895 header hash. The hash is the keccak of the header's RLP encoding
func (*HeaderEIP4895) ToProto ¶ added in v0.3.0
func (h *HeaderEIP4895) ToProto() *ethProto.Header
ToProto converts an EIP-4895 header proto to a protobuf Header
func (*HeaderEIP4895) ToRLP ¶ added in v0.3.0
func (h *HeaderEIP4895) ToRLP() []byte
ToRLP encodes the EIP-4895 header using RLP encoding.
- RLP: [parentHash, unclesHash, coinbase, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, withdrawalsRoot]
type HeaderEIP7685 ¶ added in v0.3.1
type HeaderEIP7685 struct {
BaseFeePerGas *big.Int // Base fee per gas unit for EIP-1559 blocks
ExtraData []byte // Extra data field, often used for creator-encoded information
LogsBloom Bloom // Bloom filter for quick searching of logs in the block
ParentHash Hash // Hash of the previous block (the parent block)
UncleHash Hash // Hash of the uncles block list
StateRoot Hash // Root of the state trie (Ethereum state at the end of this block)
TransactionsRoot Hash // Root of the transactions trie (all transactions for this block)
ReceiptsRoot Hash // Root of the receipts trie (all transaction receipts for this block)
MixDigest Hash // Hash used in the proof-of-work algorithm (RANDAO value after the merge)
WithdrawalsRoot Hash // Root of the withdrawals trie (for withdrawals from validators)
ParentBeaconBlockRoot Hash // Root of the parent beacon block
RequestsHash Hash // Hash of the execution layer requests in the block
Coinbase Address // Address of the block creator
Difficulty uint64 // The difficulty of mining the block (0 after the merge)
Number uint64 // The block number (height of the block in the chain)
GasLimit uint64 // Gas limit for the block
GasUsed uint64 // Total gas used by all transactions in the block
Nonce uint64 // Random value used by the miner in proof-of-work (0 after the merge)
BlobGasUsed uint64 // Total blob gas used by all transactions in the block
ExcessBlobGas uint64 // Excess blob gas, used to calculate the blob base fee
Timestamp int64 // Timestamp when the block was created
}
HeaderEIP7685 represents the EIP-7685 header, introduced as part of EIP-7685 (Prague hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7685.md
func (*HeaderEIP7685) FromProto ¶ added in v0.3.1
func (h *HeaderEIP7685) FromProto(pb *ethProto.Header) error
FromProto converts a protobuf Header to an EIP-7685 header
func (*HeaderEIP7685) Hash ¶ added in v0.3.1
func (h *HeaderEIP7685) Hash() Hash
Hash constructs the EIP-7685 header hash. The hash is the keccak of the header's RLP encoding
func (*HeaderEIP7685) ToProto ¶ added in v0.3.1
func (h *HeaderEIP7685) ToProto() *ethProto.Header
ToProto converts an EIP-7685 header to a protobuf Header
func (*HeaderEIP7685) ToRLP ¶ added in v0.3.1
func (h *HeaderEIP7685) ToRLP() []byte
ToRLP encodes the EIP-7685 header using RLP encoding.
- RLP: [parentHash, unclesHash, coinbase, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce, baseFeePerGas, withdrawalsRoot, blobGasUsed, excessBlobGas, parentBeaconBlockRoot, requestsHash]
type HeaderLegacy ¶ added in v0.3.0
type HeaderLegacy struct {
ExtraData []byte // Extra data field, often used for creator-encoded information
LogsBloom Bloom // Bloom filter for quick searching of logs in the block
ParentHash Hash // Hash of the previous block (the parent block)
UncleHash Hash // Hash of the uncles block list
StateRoot Hash // Root of the state trie (Ethereum state at the end of this block)
TransactionsRoot Hash // Root of the transactions trie (all transactions for this block)
ReceiptsRoot Hash // Root of the receipts trie (all transaction receipts for this block)
MixDigest Hash // Hash used in the proof-of-work algorithm (before Ethereum 2.0)
Coinbase Address // Address of the block creator
Difficulty uint64 // The difficulty of mining the block
Number uint64 // The block number (height of the block in the chain)
GasLimit uint64 // Gas limit for the block
GasUsed uint64 // Total gas used by all transactions in the block
Nonce uint64 // Random value used by the miner in proof-of-work (before Ethereum 2.0)
Timestamp int64 // Timestamp when the block was created
}
HeaderLegacy represents the legacy header type (pre EIP-1559)
func (*HeaderLegacy) FromProto ¶ added in v0.3.0
func (h *HeaderLegacy) FromProto(pb *ethProto.Header) error
FromProto converts a protobuf Header to a legacy header
func (*HeaderLegacy) Hash ¶ added in v0.3.0
func (h *HeaderLegacy) Hash() Hash
Hash constructs the legacy header hash. The hash is the keccak of the header's RLP encoding
func (*HeaderLegacy) ToProto ¶ added in v0.3.0
func (h *HeaderLegacy) ToProto() *ethProto.Header
ToProto converts a legacy header proto to a protobuf Header
func (*HeaderLegacy) ToRLP ¶ added in v0.3.0
func (h *HeaderLegacy) ToRLP() []byte
ToRLP encodes the legacy header using RLP encoding.
- RLP: [parentHash, unclesHash, coinbase, stateRoot, transactionsRoot, receiptsRoot, logsBloom, difficulty, number, gasLimit, gasUsed, timestamp, extraData, mixHash, nonce]
type Log ¶
type Log struct {
Topics []Hash // the topics referenced in the log
Data []byte // the data contained in the log (event data)
Address Address // the originating address of the event (SC)
}
Log are a mechanism for smart contracts to emit structured data during their execution
type Receipt ¶ added in v0.3.0
type Receipt struct {
PostState *Hash // State root after the transaction (before Byzantium)
Logs []*Log // List of logs generated by the transaction
LogsBloom Bloom // Bloom filter for logs generated by this transaction
CumulativeGasUsed uint64 // Total gas used when this transaction was executed
Type byte // Receipt type (same as the transaction type)
Status bool // true -> 1 (success); false -> 0 (failure)
}
Receipt represents a transaction receipt, which contains information about a transaction after it has been processed and included in a block
func (*Receipt) FromRLP ¶ added in v0.3.0
FromRLP parses the RLP encoding of a receipt. It expects the structure to be:
[status, cumulativeGasUsed, logsBloom, logs] (4 elements)
with the receipt type as the first byte, if not legacy
func (*Receipt) ToProto ¶ added in v0.3.0
ToProto converts a Receipt struct to its Protocol Buffer representation
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
func NewTransaction ¶ added in v0.3.0
func NewTransaction(inner transactionData) *Transaction
NewTransaction creates a new transaction wrapper
func (*Transaction) AccessList ¶ added in v0.2.0
func (t *Transaction) AccessList() AccessList
func (*Transaction) AuthorizationList ¶ added in v0.3.1
func (t *Transaction) AuthorizationList() AuthorizationList
func (*Transaction) BlobVersionedHashes ¶ added in v0.3.1
func (t *Transaction) BlobVersionedHashes() []Hash
func (*Transaction) ChainID ¶ added in v0.2.0
func (t *Transaction) ChainID() *big.Int
func (*Transaction) Cost ¶
func (t *Transaction) Cost() *big.Int
func (*Transaction) Data ¶ added in v0.2.0
func (t *Transaction) Data() []byte
func (*Transaction) From ¶ added in v0.3.0
func (t *Transaction) From() (Address, error)
From returns the sender address (origin) of the transaction. The sender address is derived from the signature values of the transaction, if any are set.
Assumes transaction signature values (V, R, S) are verified
func (*Transaction) FromProto ¶ added in v0.3.0
func (t *Transaction) FromProto(pb *txProto.Transaction) error
FromProto converts a proto Transaction into a Transaction
func (*Transaction) Gas ¶ added in v0.2.0
func (t *Transaction) Gas() uint64
func (*Transaction) GasPrice ¶ added in v0.2.0
func (t *Transaction) GasPrice() *big.Int
func (*Transaction) Hash ¶ added in v0.2.0
func (t *Transaction) Hash() Hash
Hash returns the transaction signing hash (signature payload)
func (*Transaction) MaxFeePerBlobGas ¶ added in v0.3.1
func (t *Transaction) MaxFeePerBlobGas() *big.Int
func (*Transaction) MaxFeePerGas ¶ added in v0.2.0
func (t *Transaction) MaxFeePerGas() *big.Int
func (*Transaction) MaxPriorityFeePerGas ¶ added in v0.2.0
func (t *Transaction) MaxPriorityFeePerGas() *big.Int
func (*Transaction) Nonce ¶ added in v0.2.0
func (t *Transaction) Nonce() uint64
func (*Transaction) SigValues ¶ added in v0.2.0
func (t *Transaction) SigValues() (v, r, s *big.Int)
func (*Transaction) To ¶ added in v0.2.0
func (t *Transaction) To() *Address
To returns the To address of the transaction. If none is set (ex. contract deployment), it returns nil
func (*Transaction) ToProto ¶ added in v0.3.0
func (t *Transaction) ToProto() (*txProto.Transaction, error)
ToProto converts the Transaction into its proto representation
func (*Transaction) ToRLP ¶ added in v0.3.0
func (t *Transaction) ToRLP() ([]byte, error)
ToRLP encodes the transaction using RLP encoding
func (*Transaction) ToSignedRLP ¶ added in v0.3.1
func (t *Transaction) ToSignedRLP() ([]byte, error)
ToSignedRLP encodes the signed transaction using RLP encoding
func (*Transaction) TxHash ¶ added in v0.3.1
func (t *Transaction) TxHash() (Hash, error)
TxHash returns the transaction hash, which is the keccak of the signed transaction RLP encoding
func (*Transaction) Type ¶ added in v0.2.0
func (t *Transaction) Type() byte
func (*Transaction) Value ¶ added in v0.2.0
func (t *Transaction) Value() *big.Int
type TxEIP1559 ¶ added in v0.2.0
type TxEIP1559 struct {
ChainID *big.Int // the ID of the chain
MaxPriorityFeePerGas *big.Int // the max priority fee per gas
MaxFeePerGas *big.Int // the max fee per gas
Value *big.Int // value of the transfer (if any)
YParity, R, S *big.Int // the signature fields (y parity is {0, 1})
To *Address // recipient address (nil means contract deployment)
Data []byte // data (payload) of the tx, if any
AccessList AccessList // the allowed access list for the tx, if any
Nonce uint64 // the sender nonce
Gas uint64 // the gas limit of the tx
}
TxEIP1559 represents a dynamic fee transaction, introduced as part of EIP-1559 (London hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md
func (*TxEIP1559) FromProto ¶ added in v0.2.0
func (tx *TxEIP1559) FromProto(pb *txProto.Transaction) error
FromProto converts a proto Transaction (assumed to be EIP-1559) into a TxEIP1559
func (*TxEIP1559) FromRLP ¶ added in v0.2.0
FromRLP parses an EIP-1559 transaction from the transaction data RLP encoding. It expects the structure to be:
[chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gas, to, value, data, accessList, yParity, r, s] (12 elements)
func (*TxEIP1559) SignaturePayload ¶ added in v0.2.0
SignaturePayload constructs the EIP-1559 transaction signature payload. The signature payload (what's being signed) is the keccak of a specific RLP encoding.
keccak256(0x02 || rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList]))
func (*TxEIP1559) ToProto ¶ added in v0.2.0
func (tx *TxEIP1559) ToProto() *txProto.Transaction
ToProto converts the TxEIP1559 into its proto Transaction representation
func (*TxEIP1559) ToRLP ¶ added in v0.3.0
ToRLP encodes the EIP-1559 transaction using RLP encoding.
rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList])
0x02 (transaction type) is appended as the first byte of the RLP encoding
func (*TxEIP1559) ToSignedRLP ¶ added in v0.3.1
ToSignedRLP encodes the signed EIP-1559 transaction using RLP encoding.
rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, yParity, r, s])
0x02 (transaction type) is appended as the first byte of the RLP encoding
type TxEIP2930 ¶ added in v0.2.0
type TxEIP2930 struct {
ChainID *big.Int // the ID of the chain
GasPrice *big.Int // the gas price of the tx
Value *big.Int // value of the transfer (if any)
YParity, R, S *big.Int // the signature fields (y parity is {0, 1})
To *Address // recipient address (nil means contract deployment)
Data []byte // data (payload) of the tx, if any
AccessList AccessList // the allowed access list of the tx, if any
Nonce uint64 // the sender nonce
Gas uint64 // the gas limit of the tx
}
TxEIP2930 represents an access list transaction, introduced as part of EIP-2930 https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2930.md
func (*TxEIP2930) FromProto ¶ added in v0.2.0
func (tx *TxEIP2930) FromProto(pb *txProto.Transaction) error
FromProto converts a proto Transaction (assumed to be EIP-2930) into a TxEIP2930
func (*TxEIP2930) FromRLP ¶ added in v0.2.0
FromRLP parses an EIP-2930 transaction from the transaction data RLP encoding. It expects the structure to be:
[chainID, nonce, gasPrice, gas, to, value, data, accessList, yParity, r, s] (11 elements)
func (*TxEIP2930) SignaturePayload ¶ added in v0.2.0
SignaturePayload constructs the EIP-2930 transaction signature payload. The signature payload (what's being signed) is the keccak of a specific RLP encoding.
keccak256(0x01 || rlp([chainID, nonce, gasPrice, gas, to, value, data, accessList]))
func (*TxEIP2930) ToProto ¶ added in v0.2.0
func (tx *TxEIP2930) ToProto() *txProto.Transaction
ToProto converts the TxEIP2930 into its proto Transaction representation
func (*TxEIP2930) ToRLP ¶ added in v0.3.0
ToRLP encodes the EIP-2930 transaction using RLP encoding.
rlp([chainID, nonce, gasPrice, gas, to, value, data, accessList])
0x01 (transaction type) is appended as the first byte of the RLP encoding
func (*TxEIP2930) ToSignedRLP ¶ added in v0.3.1
ToSignedRLP encodes the signed EIP-2930 transaction using RLP encoding.
rlp([chainID, nonce, gasPrice, gas, to, value, data, accessList, yParity, r, s])
0x01 (transaction type) is appended as the first byte of the RLP encoding
type TxEIP4844 ¶ added in v0.3.1
type TxEIP4844 struct {
ChainID *big.Int // the ID of the chain
MaxPriorityFeePerGas *big.Int // the max priority fee per gas
MaxFeePerGas *big.Int // the max fee per gas
MaxFeePerBlobGas *big.Int // the max fee per blob gas
Value *big.Int // value of the transfer (if any)
YParity, R, S *big.Int // the signature fields (y parity is {0, 1})
Data []byte // data (payload) of the tx, if any
AccessList AccessList // the allowed access list for the tx, if any
BlobVersionedHashes []Hash // the versioned hashes of the blobs
To Address // recipient address (contract deployment is not allowed)
Nonce uint64 // the sender nonce
Gas uint64 // the gas limit of the tx
}
TxEIP4844 represents a blob transaction, introduced as part of EIP-4844 (Cancun hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4844.md
func (*TxEIP4844) FromProto ¶ added in v0.3.1
func (tx *TxEIP4844) FromProto(pb *txProto.Transaction) error
FromProto converts a proto Transaction (assumed to be EIP-4844) into a TxEIP4844
func (*TxEIP4844) FromRLP ¶ added in v0.3.1
FromRLP parses an EIP-4844 transaction from the transaction data RLP encoding. It expects the structure to be:
[chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gas, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes, yParity, r, s] (14 elements)
func (*TxEIP4844) SignaturePayload ¶ added in v0.3.1
SignaturePayload constructs the EIP-4844 transaction signature payload. The signature payload (what's being signed) is the keccak of a specific RLP encoding.
keccak256(0x03 || rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes]))
func (*TxEIP4844) ToProto ¶ added in v0.3.1
func (tx *TxEIP4844) ToProto() *txProto.Transaction
ToProto converts the TxEIP4844 into its proto Transaction representation
func (*TxEIP4844) ToRLP ¶ added in v0.3.1
ToRLP encodes the EIP-4844 transaction using RLP encoding.
rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes])
0x03 (transaction type) is appended as the first byte of the RLP encoding
func (*TxEIP4844) ToSignedRLP ¶ added in v0.3.1
ToSignedRLP encodes the signed EIP-4844 transaction using RLP encoding.
rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, maxFeePerBlobGas, blobVersionedHashes, yParity, r, s])
0x03 (transaction type) is appended as the first byte of the RLP encoding
type TxEIP7702 ¶ added in v0.3.1
type TxEIP7702 struct {
ChainID *big.Int // the ID of the chain
MaxPriorityFeePerGas *big.Int // the max priority fee per gas
MaxFeePerGas *big.Int // the max fee per gas
Value *big.Int // value of the transfer (if any)
YParity, R, S *big.Int // the signature fields (y parity is {0, 1})
Data []byte // data (payload) of the tx, if any
AccessList AccessList // the allowed access list for the tx, if any
AuthorizationList AuthorizationList // the authorization list of the tx
To Address // recipient address (contract deployment is not allowed)
Nonce uint64 // the sender nonce
Gas uint64 // the gas limit of the tx
}
TxEIP7702 represents a set-code transaction, introduced as part of EIP-7702 (Prague hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7702.md
func (*TxEIP7702) FromProto ¶ added in v0.3.1
func (tx *TxEIP7702) FromProto(pb *txProto.Transaction) error
FromProto converts a proto Transaction (assumed to be EIP-7702) into a TxEIP7702
func (*TxEIP7702) FromRLP ¶ added in v0.3.1
FromRLP parses an EIP-7702 transaction from the transaction data RLP encoding. It expects the structure to be:
[chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gas, to, value, data, accessList, authorizationList, yParity, r, s] (13 elements)
func (*TxEIP7702) SignaturePayload ¶ added in v0.3.1
SignaturePayload constructs the EIP-7702 transaction signature payload. The signature payload (what's being signed) is the keccak of a specific RLP encoding.
keccak256(0x04 || rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, authorizationList]))
func (*TxEIP7702) ToProto ¶ added in v0.3.1
func (tx *TxEIP7702) ToProto() *txProto.Transaction
ToProto converts the TxEIP7702 into its proto Transaction representation
func (*TxEIP7702) ToRLP ¶ added in v0.3.1
ToRLP encodes the EIP-7702 transaction using RLP encoding.
rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, authorizationList])
0x04 (transaction type) is appended as the first byte of the RLP encoding
func (*TxEIP7702) ToSignedRLP ¶ added in v0.3.1
ToSignedRLP encodes the signed EIP-7702 transaction using RLP encoding.
rlp([chainID, nonce, maxPriorityFeePerGas, maxFeePerGas, gasLimit, to, value, data, accessList, authorizationList, yParity, r, s])
0x04 (transaction type) is appended as the first byte of the RLP encoding
type TxLegacy ¶ added in v0.2.0
type TxLegacy struct {
GasPrice *big.Int // the gas price of the tx
Value *big.Int // value of the transfer (if any)
V, R, S *big.Int // the signature fields
To *Address // recipient address (nil means contract deployment)
Data []byte // data (payload) of the tx, if any
Nonce uint64 // the sender nonce
Gas uint64 // the gas limit of the tx
}
TxLegacy represents the legacy transaction type (pre EIP-2930, and pre EIP-1559)
func (*TxLegacy) FromProto ¶ added in v0.2.0
func (tx *TxLegacy) FromProto(pb *txProto.Transaction) error
FromProto converts a proto Transaction (assumed to be legacy) into the legacy format
func (*TxLegacy) FromRLP ¶ added in v0.2.0
FromRLP parses a legacy transaction from the transaction data RLP encoding. It expects the structure to be:
[nonce, gasPrice, gas, to, value, data, v, r, s] (9 elements)
func (*TxLegacy) SignaturePayload ¶ added in v0.2.0
SignaturePayload constructs the legacy transaction signature payload. The signature payload (what's being signed) is the keccak of a specific RLP encoding
func (*TxLegacy) ToProto ¶ added in v0.2.0
func (tx *TxLegacy) ToProto() *txProto.Transaction
ToProto converts the TxLegacy into its proto Transaction representation
func (*TxLegacy) ToRLP ¶ added in v0.3.0
ToRLP encodes the legacy transaction using RLP encoding.
- Pre-EIP-155 (Homestead) RLP: [nonce, gasPrice, gas, to, value, data] (6 elements)
- EIP-155 RLP: [nonce, gasPrice, gas, to, value, data, chainID, 0, 0] (9 elements)
func (*TxLegacy) ToSignedRLP ¶ added in v0.3.1
ToSignedRLP encodes the signed legacy transaction using RLP encoding.
rlp([nonce, gasPrice, gas, to, value, data, v, r, s])
type Withdrawal ¶ added in v0.3.1
type Withdrawal struct {
Address Address // the recipient address
Index uint64 // the withdrawal index
ValidatorIndex uint64 // the validator index
Amount uint64 // the withdrawn amount (in gwei)
}
Withdrawal represents a validator withdrawal, introduced as part of EIP-4895 (Shanghai hardfork) https://github.com/ethereum/EIPs/blob/master/EIPS/eip-4895.md
func (*Withdrawal) FromProto ¶ added in v0.3.1
func (w *Withdrawal) FromProto(pb *ethProto.Withdrawal) error
FromProto converts a proto Withdrawal to a withdrawal
func (Withdrawal) ToProto ¶ added in v0.3.1
func (w Withdrawal) ToProto() *ethProto.Withdrawal
ToProto converts the withdrawal to its proto representation
func (Withdrawal) ToRLP ¶ added in v0.3.1
func (w Withdrawal) ToRLP() []byte
ToRLP encodes the withdrawal using RLP encoding.
rlp([index, validatorIndex, address, amount])
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package hex provides the common hex manipulation functionality.
|
Package hex provides the common hex manipulation functionality. |
|
Package keccak provides a utility wrapper for the sha256 legacy keccak implementation.
|
Package keccak provides a utility wrapper for the sha256 legacy keccak implementation. |
|
proto
|
|