Documentation
¶
Overview ¶
Package types provides type aliases to ethereum types This ensures compatibility with ethereum interfaces while allowing our own extensions
Index ¶
- Constants
- Variables
- func DeriveSha(list DerivableList, hasher TrieHasher) common.Hash
- func HashDifference(a, b []common.Hash) []common.Hash
- func Sender(signer Signer, tx *Transaction) (common.Address, error)
- type AccessList
- type AccessListTx
- type AccessTuple
- type Account
- type BlobTx
- type BlobTxSidecar
- type Block
- type BlockNonce
- type Bloom
- type Body
- type DerivableList
- type DynamicFeeTx
- type EIP155Signer
- func (s EIP155Signer) ChainID() *big.Int
- func (s EIP155Signer) Equal(s2 Signer) bool
- func (s EIP155Signer) Hash(tx *Transaction) common.Hash
- func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error)
- func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)
- type FrontierSigner
- func (s FrontierSigner) ChainID() *big.Int
- func (s FrontierSigner) Equal(s2 Signer) bool
- func (fs FrontierSigner) Hash(tx *Transaction) common.Hash
- func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error)
- func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
- type FullAccount
- type GenesisAccount
- type GenesisAlloc
- type GenesisMultiCoinBalance
- type Header
- type HomesteadSigner
- type LegacyTx
- type Log
- type Receipt
- type Receipts
- type Signer
- func LatestSigner(config *params.ChainConfig) Signer
- func LatestSignerForChainID(chainID *big.Int) Signer
- func MakeSigner(config *params.ChainConfig, blockNumber *big.Int, blockTime uint64) Signer
- func NewCancunSigner(chainId *big.Int) Signer
- func NewEIP2930Signer(chainId *big.Int) Signer
- func NewLondonSigner(chainId *big.Int) Signer
- type StateAccount
- type Transaction
- func MustSignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) *Transaction
- func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction
- func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, ...) *Transaction
- func NewTx(inner TxData) *Transaction
- func SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, error)
- func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
- func (tx *Transaction) AccessList() AccessList
- func (tx *Transaction) BlobGas() uint64
- func (tx *Transaction) BlobGasFeeCap() *big.Int
- func (tx *Transaction) BlobGasFeeCapCmp(other *Transaction) int
- func (tx *Transaction) BlobGasFeeCapIntCmp(other *big.Int) int
- func (tx *Transaction) BlobHashes() []common.Hash
- func (tx *Transaction) BlobTxSidecar() *BlobTxSidecar
- func (tx *Transaction) ChainId() *big.Int
- func (tx *Transaction) Cost() *big.Int
- func (tx *Transaction) Data() []byte
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EffectiveGasTip(baseFee *big.Int) (*big.Int, error)
- func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int) int
- func (tx *Transaction) EffectiveGasTipIntCmp(other *big.Int, baseFee *big.Int) int
- func (tx *Transaction) EffectiveGasTipValue(baseFee *big.Int) *big.Int
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (tx *Transaction) Gas() uint64
- func (tx *Transaction) GasFeeCap() *big.Int
- func (tx *Transaction) GasFeeCapCmp(other *Transaction) int
- func (tx *Transaction) GasFeeCapIntCmp(other *big.Int) int
- func (tx *Transaction) GasPrice() *big.Int
- func (tx *Transaction) GasTipCap() *big.Int
- func (tx *Transaction) GasTipCapCmp(other *Transaction) int
- func (tx *Transaction) GasTipCapIntCmp(other *big.Int) int
- func (tx *Transaction) Hash() common.Hash
- func (tx *Transaction) MarshalBinary() ([]byte, error)
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (tx *Transaction) Nonce() uint64
- func (tx *Transaction) Protected() bool
- func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)
- func (tx *Transaction) SetTime(t time.Time)
- func (tx *Transaction) Size() uint64
- func (tx *Transaction) Time() time.Time
- func (tx *Transaction) To() *common.Address
- func (tx *Transaction) Type() uint8
- func (tx *Transaction) UnmarshalBinary(b []byte) error
- func (tx *Transaction) UnmarshalJSON(input []byte) error
- func (tx *Transaction) Value() *big.Int
- func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
- func (tx *Transaction) WithoutBlobTxSidecar() *Transaction
- type Transactions
- type TrieHasher
- type TxByNonce
- type TxData
- type Withdrawal
- type Withdrawals
Constants ¶
const ( // Transaction types LegacyTxType = ethtypes.LegacyTxType AccessListTxType = ethtypes.AccessListTxType DynamicFeeTxType = ethtypes.DynamicFeeTxType BlobTxType = ethtypes.BlobTxType // Receipt status ReceiptStatusFailed = ethtypes.ReceiptStatusFailed ReceiptStatusSuccessful = ethtypes.ReceiptStatusSuccessful )
Constants
const ( BloomBitLength = ethtypes.BloomBitLength BloomByteLength = ethtypes.BloomByteLength )
Constants for bloom filters
const ( LegacyTxType = 0x00 AccessListTxType = 0x01 DynamicFeeTxType = 0x02 BlobTxType = 0x03 )
Transaction types.
Variables ¶
var ( // Hashes EmptyRootHash = ethtypes.EmptyRootHash EmptyCodeHash = ethtypes.EmptyCodeHash EmptyTxsHash = ethtypes.EmptyTxsHash EmptyReceiptsHash = ethtypes.EmptyReceiptsHash EmptyWithdrawalsHash = ethtypes.EmptyWithdrawalsHash // Errors ErrInvalidSig = ethtypes.ErrInvalidSig ErrUnexpectedProtection = ethtypes.ErrUnexpectedProtection ErrInvalidTxType = ethtypes.ErrInvalidTxType ErrTxTypeNotSupported = ethtypes.ErrTxTypeNotSupported ErrGasFeeCapTooLow = ethtypes.ErrGasFeeCapTooLow ErrInvalidChainId = ethtypes.ErrInvalidChainId )
Variables
var ( // Transaction creation NewTx = ethtypes.NewTx NewTransaction = ethtypes.NewTransaction NewContractCreation = ethtypes.NewContractCreation // Signing SignTx = ethtypes.SignTx SignNewTx = ethtypes.SignNewTx MustSignNewTx = ethtypes.MustSignNewTx Sender = ethtypes.Sender LatestSigner = ethtypes.LatestSigner LatestSignerForChainID = ethtypes.LatestSignerForChainID NewEIP155Signer = ethtypes.NewEIP155Signer NewLondonSigner = ethtypes.NewLondonSigner NewCancunSigner = ethtypes.NewCancunSigner MakeSigner = ethtypes.MakeSigner // Block functions CalcUncleHash = ethtypes.CalcUncleHash DeriveSha = ethtypes.DeriveSha )
Functions
var ( ErrInvalidSig = errors.New("invalid transaction v, r, s values") ErrUnexpectedProtection = errors.New("transaction type does not supported EIP-155 protected signatures") ErrInvalidTxType = errors.New("transaction type not valid in this context") ErrTxTypeNotSupported = errors.New("transaction type not supported") ErrGasFeeCapTooLow = errors.New("fee cap less than base fee") )
var ErrInvalidChainId = errors.New("invalid chain id for signer")
var (
NewEmptyStateAccount = ethtypes.NewEmptyStateAccount
)
Functions for accounts
Functions ¶
func DeriveSha ¶
func DeriveSha(list DerivableList, hasher TrieHasher) common.Hash
DeriveSha creates the tree hashes of transactions, receipts, and withdrawals in a block header.
func HashDifference ¶
HashDifference returns a new set which is the difference between a and b.
func Sender ¶
func Sender(signer Signer, tx *Transaction) (common.Address, error)
Sender returns the address derived from the signature (V, R, S) using secp256k1 elliptic curve and an error if it failed deriving or upon an incorrect signature.
Sender may cache the address, allowing it to be used regardless of signing method. The cache is invalidated if the cached signer does not match the signer used in the current call.
Types ¶
type AccessList ¶
type AccessList []AccessTuple
AccessList is an EIP-2930 access list.
func (AccessList) StorageKeys ¶
func (al AccessList) StorageKeys() int
StorageKeys returns the total number of storage keys in the access list.
type AccessListTx ¶
type AccessListTx struct {
ChainID *big.Int // destination chain ID
Nonce uint64 // nonce of sender account
GasPrice *big.Int // wei per gas
Gas uint64 // gas limit
To *common.Address `rlp:"nil"` // nil means contract creation
Value *big.Int // wei amount
Data []byte // contract invocation input data
AccessList AccessList // EIP-2930 access list
V, R, S *big.Int // signature values
}
AccessListTx is the data of EIP-2930 access list transactions.
type AccessTuple ¶
type AccessTuple struct {
Address common.Address `json:"address" gencodec:"required"`
StorageKeys []common.Hash `json:"storageKeys" gencodec:"required"`
}
AccessTuple is the element type of an access list.
type Account ¶
type Account struct {
Code []byte `json:"code,omitempty"`
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
Balance *big.Int `json:"balance" gencodec:"required"`
Nonce uint64 `json:"nonce,omitempty"`
// used in tests
PrivateKey []byte `json:"secretKey,omitempty"`
}
Account represents an Ethereum account and its attached data. This type is used to specify accounts in the genesis block state, and is also useful for JSON encoding/decoding of accounts.
type BlobTx ¶
type BlobTx struct {
ChainID *uint256.Int
Nonce uint64
GasTipCap *uint256.Int // a.k.a. maxPriorityFeePerGas
GasFeeCap *uint256.Int // a.k.a. maxFeePerGas
Gas uint64
To common.Address
Value *uint256.Int
Data []byte
AccessList AccessList
BlobFeeCap *uint256.Int // a.k.a. maxFeePerBlobGas
BlobHashes []common.Hash
// A blob transaction can optionally contain blobs. This field must be set when BlobTx
// is used to create a transaction for signing.
Sidecar *BlobTxSidecar `rlp:"-"`
// Signature values
V *uint256.Int `json:"v" gencodec:"required"`
R *uint256.Int `json:"r" gencodec:"required"`
S *uint256.Int `json:"s" gencodec:"required"`
}
BlobTx represents an EIP-4844 transaction.
type BlobTxSidecar ¶
type BlobTxSidecar struct {
Blobs []kzg4844.Blob // Blobs needed by the blob pool
Commitments []kzg4844.Commitment // Commitments needed by the blob pool
Proofs []kzg4844.Proof // Proofs needed by the blob pool
}
BlobTxSidecar contains the blobs of a blob transaction.
func (*BlobTxSidecar) BlobHashes ¶
func (sc *BlobTxSidecar) BlobHashes() []common.Hash
BlobHashes computes the blob hashes of the given blobs.
type BlockNonce ¶
type BlockNonce = ethtypes.BlockNonce
Core types - direct aliases to ethereum types
type DerivableList ¶
DerivableList is the input to DeriveSha. It is implemented by the 'Transactions' and 'Receipts' types. This is internal, do not use these methods.
type DynamicFeeTx ¶
type DynamicFeeTx struct {
ChainID *big.Int
Nonce uint64
GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas
GasFeeCap *big.Int // a.k.a. maxFeePerGas
Gas uint64
To *common.Address `rlp:"nil"` // nil means contract creation
Value *big.Int
Data []byte
AccessList AccessList
// Signature values
V *big.Int `json:"v" gencodec:"required"`
R *big.Int `json:"r" gencodec:"required"`
S *big.Int `json:"s" gencodec:"required"`
}
DynamicFeeTx represents an EIP-1559 transaction.
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
EIP155Signer implements Signer using the EIP-155 rules. This accepts transactions which are replay-protected as well as unprotected homestead transactions.
func NewEIP155Signer ¶
func NewEIP155Signer(chainId *big.Int) EIP155Signer
func (EIP155Signer) ChainID ¶
func (s EIP155Signer) ChainID() *big.Int
func (EIP155Signer) Equal ¶
func (s EIP155Signer) Equal(s2 Signer) bool
func (EIP155Signer) Hash ¶
func (s EIP155Signer) Hash(tx *Transaction) common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (EIP155Signer) Sender ¶
func (s EIP155Signer) Sender(tx *Transaction) (common.Address, error)
func (EIP155Signer) SignatureValues ¶
func (s EIP155Signer) SignatureValues(tx *Transaction, sig []byte) (R, S, V *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type FrontierSigner ¶
type FrontierSigner struct{}
FrontierSigner implements Signer interface using the frontier rules.
func (FrontierSigner) ChainID ¶
func (s FrontierSigner) ChainID() *big.Int
func (FrontierSigner) Equal ¶
func (s FrontierSigner) Equal(s2 Signer) bool
func (FrontierSigner) Hash ¶
func (fs FrontierSigner) Hash(tx *Transaction) common.Hash
Hash returns the hash to be signed by the sender. It does not uniquely identify the transaction.
func (FrontierSigner) Sender ¶
func (fs FrontierSigner) Sender(tx *Transaction) (common.Address, error)
func (FrontierSigner) SignatureValues ¶
func (fs FrontierSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type GenesisAccount ¶ added in v0.15.4
type GenesisAccount struct {
Code []byte `json:"code,omitempty"`
Storage map[common.Hash]common.Hash `json:"storage,omitempty"`
Balance *big.Int `json:"balance" gencodec:"required"`
MCBalance GenesisMultiCoinBalance `json:"mcbalance,omitempty"`
Nonce uint64 `json:"nonce,omitempty"`
PrivateKey []byte `json:"secretKey,omitempty"` // for tests
}
GenesisAccount is an account in the state of the genesis block.
type GenesisAlloc ¶
type GenesisAlloc map[common.Address]GenesisAccount
GenesisAlloc specifies the initial state of a genesis block.
func (*GenesisAlloc) UnmarshalJSON ¶
func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error
type GenesisMultiCoinBalance ¶ added in v0.15.4
type HomesteadSigner ¶
type HomesteadSigner struct{ FrontierSigner }
HomesteadSigner implements Signer interface using the homestead rules.
func (HomesteadSigner) ChainID ¶
func (s HomesteadSigner) ChainID() *big.Int
func (HomesteadSigner) Equal ¶
func (s HomesteadSigner) Equal(s2 Signer) bool
func (HomesteadSigner) Sender ¶
func (hs HomesteadSigner) Sender(tx *Transaction) (common.Address, error)
func (HomesteadSigner) SignatureValues ¶
func (hs HomesteadSigner) SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
SignatureValues returns signature values. This signature needs to be in the [R || S || V] format where V is 0 or 1.
type LegacyTx ¶
type LegacyTx struct {
Nonce uint64 // nonce of sender account
GasPrice *big.Int // wei per gas
Gas uint64 // gas limit
To *common.Address `rlp:"nil"` // nil means contract creation
Value *big.Int // wei amount
Data []byte // contract invocation input data
V, R, S *big.Int // signature values
}
LegacyTx is the transaction data of the original Ethereum transactions.
type Signer ¶
type Signer interface {
// Sender returns the sender address of the transaction.
Sender(tx *Transaction) (common.Address, error)
// SignatureValues returns the raw R, S, V values corresponding to the
// given signature.
SignatureValues(tx *Transaction, sig []byte) (r, s, v *big.Int, err error)
ChainID() *big.Int
// Hash returns 'signature hash', i.e. the transaction hash that is signed by the
// private key. This hash does not uniquely identify the transaction.
Hash(tx *Transaction) common.Hash
// Equal returns true if the given signer is the same as the receiver.
Equal(Signer) bool
}
Signer encapsulates transaction signature handling. The name of this type is slightly misleading because Signers don't actually sign, they're just for validating and processing of signatures.
Note that this interface is not a stable API and may change at any time to accommodate new protocol rules.
func LatestSigner ¶
func LatestSigner(config *params.ChainConfig) Signer
LatestSigner returns the 'most permissive' Signer available for the given chain configuration. Specifically, this enables support of all types of transactions when their respective forks are scheduled to occur at any block number (or time) in the chain config.
Use this in transaction-handling code where the current block number is unknown. If you have the current block number available, use MakeSigner instead.
func LatestSignerForChainID ¶
LatestSignerForChainID returns the 'most permissive' Signer available. Specifically, this enables support for EIP-155 replay protection and all implemented EIP-2718 transaction types if chainID is non-nil.
Use this in transaction-handling code where the current block number and fork configuration are unknown. If you have a ChainConfig, use LatestSigner instead. If you have a ChainConfig and know the current block number, use MakeSigner instead.
func MakeSigner ¶
MakeSigner returns a Signer based on the given chain config and block number or time.
func NewCancunSigner ¶
NewCancunSigner returns a signer that accepts - EIP-4844 blob transactions - EIP-1559 dynamic fee transactions - EIP-2930 access list transactions, - EIP-155 replay protected transactions, and - legacy Homestead transactions.
func NewEIP2930Signer ¶
NewEIP2930Signer returns a signer that accepts EIP-2930 access list transactions, EIP-155 replay protected transactions, and legacy Homestead transactions.
func NewLondonSigner ¶
NewLondonSigner returns a signer that accepts - EIP-1559 dynamic fee transactions - EIP-2930 access list transactions, - EIP-155 replay protected transactions, and - legacy Homestead transactions.
type Transaction ¶
type Transaction struct {
// contains filtered or unexported fields
}
Transaction is an Ethereum transaction.
func MustSignNewTx ¶
func MustSignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) *Transaction
MustSignNewTx creates a transaction and signs it. This panics if the transaction cannot be signed.
func NewContractCreation ¶
func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction
NewContractCreation creates an unsigned legacy transaction. Deprecated: use NewTx instead.
func NewTransaction ¶
func NewTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte) *Transaction
NewTransaction creates an unsigned legacy transaction. Deprecated: use NewTx instead.
func SignNewTx ¶
func SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, error)
SignNewTx creates a transaction and signs it.
func SignTx ¶
func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
SignTx signs the transaction using the given signer and private key.
func (*Transaction) AccessList ¶
func (tx *Transaction) AccessList() AccessList
AccessList returns the access list of the transaction.
func (*Transaction) BlobGas ¶
func (tx *Transaction) BlobGas() uint64
BlobGas returns the blob gas limit of the transaction for blob transactions, 0 otherwise.
func (*Transaction) BlobGasFeeCap ¶
func (tx *Transaction) BlobGasFeeCap() *big.Int
BlobGasFeeCap returns the blob gas fee cap per blob gas of the transaction for blob transactions, nil otherwise.
func (*Transaction) BlobGasFeeCapCmp ¶
func (tx *Transaction) BlobGasFeeCapCmp(other *Transaction) int
BlobGasFeeCapCmp compares the blob fee cap of two transactions.
func (*Transaction) BlobGasFeeCapIntCmp ¶
func (tx *Transaction) BlobGasFeeCapIntCmp(other *big.Int) int
BlobGasFeeCapIntCmp compares the blob fee cap of the transaction against the given blob fee cap.
func (*Transaction) BlobHashes ¶
func (tx *Transaction) BlobHashes() []common.Hash
BlobHashes returns the hashes of the blob commitments for blob transactions, nil otherwise.
func (*Transaction) BlobTxSidecar ¶
func (tx *Transaction) BlobTxSidecar() *BlobTxSidecar
BlobTxSidecar returns the sidecar of a blob transaction, nil otherwise.
func (*Transaction) ChainId ¶
func (tx *Transaction) ChainId() *big.Int
ChainId returns the EIP155 chain ID of the transaction. The return value will always be non-nil. For legacy transactions which are not replay-protected, the return value is zero.
func (*Transaction) Cost ¶
func (tx *Transaction) Cost() *big.Int
Cost returns (gas * gasPrice) + (blobGas * blobGasPrice) + value.
func (*Transaction) Data ¶
func (tx *Transaction) Data() []byte
Data returns the input data of the transaction.
func (*Transaction) DecodeRLP ¶
func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*Transaction) EffectiveGasTip ¶
EffectiveGasTip returns the effective miner gasTipCap for the given base fee. Note: if the effective gasTipCap is negative, this method returns both error the actual negative value, _and_ ErrGasFeeCapTooLow
func (*Transaction) EffectiveGasTipCmp ¶
func (tx *Transaction) EffectiveGasTipCmp(other *Transaction, baseFee *big.Int) int
EffectiveGasTipCmp compares the effective gasTipCap of two transactions assuming the given base fee.
func (*Transaction) EffectiveGasTipIntCmp ¶
EffectiveGasTipIntCmp compares the effective gasTipCap of a transaction to the given gasTipCap.
func (*Transaction) EffectiveGasTipValue ¶ added in v0.15.4
func (tx *Transaction) EffectiveGasTipValue(baseFee *big.Int) *big.Int
EffectiveGasTipValue is identical to EffectiveGasTip, but does not return an error in case the effective gasTipCap is negative
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) Gas ¶
func (tx *Transaction) Gas() uint64
Gas returns the gas limit of the transaction.
func (*Transaction) GasFeeCap ¶
func (tx *Transaction) GasFeeCap() *big.Int
GasFeeCap returns the fee cap per gas of the transaction.
func (*Transaction) GasFeeCapCmp ¶
func (tx *Transaction) GasFeeCapCmp(other *Transaction) int
GasFeeCapCmp compares the fee cap of two transactions.
func (*Transaction) GasFeeCapIntCmp ¶
func (tx *Transaction) GasFeeCapIntCmp(other *big.Int) int
GasFeeCapIntCmp compares the fee cap of the transaction against the given fee cap.
func (*Transaction) GasPrice ¶
func (tx *Transaction) GasPrice() *big.Int
GasPrice returns the gas price of the transaction.
func (*Transaction) GasTipCap ¶
func (tx *Transaction) GasTipCap() *big.Int
GasTipCap returns the gasTipCap per gas of the transaction.
func (*Transaction) GasTipCapCmp ¶
func (tx *Transaction) GasTipCapCmp(other *Transaction) int
GasTipCapCmp compares the gasTipCap of two transactions.
func (*Transaction) GasTipCapIntCmp ¶
func (tx *Transaction) GasTipCapIntCmp(other *big.Int) int
GasTipCapIntCmp compares the gasTipCap of the transaction against the given gasTipCap.
func (*Transaction) Hash ¶
func (tx *Transaction) Hash() common.Hash
Hash returns the transaction hash.
func (*Transaction) MarshalBinary ¶
func (tx *Transaction) MarshalBinary() ([]byte, error)
MarshalBinary returns the canonical encoding of the transaction. For legacy transactions, it returns the RLP encoding. For EIP-2718 typed transactions, it returns the type and payload.
func (*Transaction) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON with a hash.
func (*Transaction) Nonce ¶
func (tx *Transaction) Nonce() uint64
Nonce returns the sender account nonce of the transaction.
func (*Transaction) Protected ¶
func (tx *Transaction) Protected() bool
Protected says whether the transaction is replay-protected.
func (*Transaction) RawSignatureValues ¶
func (tx *Transaction) RawSignatureValues() (v, r, s *big.Int)
RawSignatureValues returns the V, R, S signature values of the transaction. The return values should not be modified by the caller. The return values may be nil or zero, if the transaction is unsigned.
func (*Transaction) SetTime ¶
func (tx *Transaction) SetTime(t time.Time)
SetTime sets the decoding time of a transaction. This is used by tests to set arbitrary times and by persistent transaction pools when loading old txs from disk.
func (*Transaction) Size ¶
func (tx *Transaction) Size() uint64
Size returns the true encoded storage size of the transaction, either by encoding and returning it, or returning a previously cached value.
func (*Transaction) Time ¶
func (tx *Transaction) Time() time.Time
Time returns the time when the transaction was first seen on the network. It is a heuristic to prefer mining older txs vs new all other things equal.
func (*Transaction) To ¶
func (tx *Transaction) To() *common.Address
To returns the recipient address of the transaction. For contract-creation transactions, To returns nil.
func (*Transaction) UnmarshalBinary ¶
func (tx *Transaction) UnmarshalBinary(b []byte) error
UnmarshalBinary decodes the canonical encoding of transactions. It supports legacy RLP transactions and EIP-2718 typed transactions.
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
func (*Transaction) Value ¶
func (tx *Transaction) Value() *big.Int
Value returns the ether amount of the transaction.
func (*Transaction) WithSignature ¶
func (tx *Transaction) WithSignature(signer Signer, sig []byte) (*Transaction, error)
WithSignature returns a new transaction with the given signature. This signature needs to be in the [R || S || V] format where V is 0 or 1.
func (*Transaction) WithoutBlobTxSidecar ¶
func (tx *Transaction) WithoutBlobTxSidecar() *Transaction
WithoutBlobTxSidecar returns a copy of tx with the blob sidecar removed.
type Transactions ¶
type Transactions []*Transaction
Transactions implements DerivableList for transactions.
func TxDifference ¶
func TxDifference(a, b Transactions) Transactions
TxDifference returns a new set which is the difference between a and b.
func (Transactions) EncodeIndex ¶
func (s Transactions) EncodeIndex(i int, w *bytes.Buffer)
EncodeIndex encodes the i'th transaction to w. Note that this does not check for errors because we assume that *Transaction will only ever contain valid txs that were either constructed by decoding or via public API in this package.
type TrieHasher ¶
TrieHasher is the tool used to calculate the hash of derivable list. This is internal, do not use.
type TxByNonce ¶
type TxByNonce Transactions
TxByNonce implements the sort interface to allow sorting a list of transactions by their nonces. This is usually only useful for sorting transactions from a single account, otherwise a nonce comparison doesn't make much sense.
type TxData ¶
type TxData interface {
// contains filtered or unexported methods
}
TxData is the underlying data of a transaction.
This is implemented by DynamicFeeTx, LegacyTx and AccessListTx.
type Withdrawal ¶
type Withdrawal = ethtypes.Withdrawal
Core types - direct aliases to ethereum types
type Withdrawals ¶
type Withdrawals = ethtypes.Withdrawals
Core types - direct aliases to ethereum types