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 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 SignNewTx(prv *ecdsa.PrivateKey, s Signer, txdata TxData) (*Transaction, error)
- func SignTx(tx *Transaction, s Signer, prv *ecdsa.PrivateKey) (*Transaction, error)
- 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
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 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 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 = ethtypes.Transaction
Transaction types
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) MarshalJSON ¶
func (tx *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON marshals as JSON with a hash.
func (*Transaction) UnmarshalJSON ¶
func (tx *Transaction) UnmarshalJSON(input []byte) error
UnmarshalJSON unmarshals from JSON.
type Transactions ¶
type Transactions = ethtypes.Transactions
Core types - direct aliases to ethereum types
type TrieHasher ¶
TrieHasher is the tool used to calculate the hash of derivable list. This is internal, do not use.
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