Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateTransactionAndSigner(nonce uint64, to *Address, value *big.Int, data []byte) (*Transaction, *Signer, error)
- func InitEIP155Signer(chainId *big.Int)
- func MarshalObjects[T any, Constraint CodecObjectConstraint[T]](objs []*T) ([]byte, error)
- func MarshalReceipts(objs []*Receipt) ([]byte, error)
- func MarshalTransactions(objs []*Transaction) ([]byte, error)
- func PrefixedRlpHash(prefix byte, x interface{}) *common.Hash
- func RecoverPlain(hash []byte, R, S, Vb *big.Int, homestead bool) ([]byte, error)
- func RlpHash(x interface{}) *common.Hash
- func UnmarshalObjects[T any, Constraint CodecObjectConstraint[T]](data []byte) ([]*T, error)
- type AccessListTx
- func (tx *AccessListTx) GetAccessList() types.AccessList
- func (tx *AccessListTx) GetChainID() *big.Int
- func (tx *AccessListTx) GetData() []byte
- func (tx *AccessListTx) GetGas() uint64
- func (tx *AccessListTx) GetGasFeeCap() *big.Int
- func (tx *AccessListTx) GetGasPrice() *big.Int
- func (tx *AccessListTx) GetGasTipCap() *big.Int
- func (tx *AccessListTx) GetNonce() uint64
- func (tx *AccessListTx) GetTo() *common.Address
- func (tx *AccessListTx) GetValue() *big.Int
- func (tx *AccessListTx) RawSignatureValues() (v, r, s *big.Int)
- func (tx *AccessListTx) TxType() byte
- type Address
- type Block
- type BlockHeader
- type Bloom
- type CallArgs
- type ChainMeta
- type CodecObject
- type CodecObjectConstraint
- type CommitEvent
- type DynamicFeeTx
- func (tx *DynamicFeeTx) GetAccessList() types.AccessList
- func (tx *DynamicFeeTx) GetChainID() *big.Int
- func (tx *DynamicFeeTx) GetData() []byte
- func (tx *DynamicFeeTx) GetGas() uint64
- func (tx *DynamicFeeTx) GetGasFeeCap() *big.Int
- func (tx *DynamicFeeTx) GetGasPrice() *big.Int
- func (tx *DynamicFeeTx) GetGasTipCap() *big.Int
- func (tx *DynamicFeeTx) GetNonce() uint64
- func (tx *DynamicFeeTx) GetTo() *common.Address
- func (tx *DynamicFeeTx) GetValue() *big.Int
- func (tx *DynamicFeeTx) RawSignatureValues() (v, r, s *big.Int)
- func (tx *DynamicFeeTx) TxType() byte
- type EIP155Signer
- type Event
- type EventType
- type EvmLog
- type Hash
- func (h *Hash) Bytes() []byte
- func (h *Hash) CalculateHash() ([]byte, error)
- func (h *Hash) ETHHash() common.Hash
- func (h *Hash) Equals(other mt.Content) (bool, error)
- func (h *Hash) MarshalJSON() ([]byte, error)
- func (h *Hash) SetBytes(b []byte)
- func (h *Hash) Size() int
- func (h *Hash) String() string
- func (h *Hash) UnmarshalJSON(data []byte) error
- type KeccakState
- type LegacyTx
- func (tx *LegacyTx) GetAccessList() types.AccessList
- func (tx *LegacyTx) GetChainID() *big.Int
- func (tx *LegacyTx) GetData() []byte
- func (tx *LegacyTx) GetGas() uint64
- func (tx *LegacyTx) GetGasFeeCap() *big.Int
- func (tx *LegacyTx) GetGasPrice() *big.Int
- func (tx *LegacyTx) GetGasTipCap() *big.Int
- func (tx *LegacyTx) GetNonce() uint64
- func (tx *LegacyTx) GetTo() *common.Address
- func (tx *LegacyTx) GetValue() *big.Int
- func (tx *LegacyTx) RawSignatureValues() (v, r, s *big.Int)
- func (tx *LegacyTx) TxType() byte
- type Receipt
- type ReceiptStatus
- type Signer
- type Transaction
- func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
- func (tx *Transaction) EncodeRLP(w io.Writer) error
- func (e *Transaction) FromCallArgs(callArgs CallArgs)
- func (e *Transaction) GetChainID() *big.Int
- func (e *Transaction) GetExtra() []byte
- func (e *Transaction) GetFrom() *Address
- func (e *Transaction) GetGas() uint64
- func (e *Transaction) GetGasFeeCap() *big.Int
- func (e *Transaction) GetGasPrice() *big.Int
- func (e *Transaction) GetGasTipCap() *big.Int
- func (e *Transaction) GetHash() *Hash
- func (e *Transaction) GetInner() TxData
- func (e *Transaction) GetNonce() uint64
- func (e *Transaction) GetPayload() []byte
- func (e *Transaction) GetRawSignature() (v, r, s *big.Int)
- func (e *Transaction) GetSignHash() *Hash
- func (e *Transaction) GetSignature() []byte
- func (e *Transaction) GetTimeStamp() int64
- func (e *Transaction) GetTo() *Address
- func (e *Transaction) GetType() byte
- func (e *Transaction) GetValue() *big.Int
- func (e *Transaction) GetVersion() []byte
- func (tx *Transaction) Marshal() ([]byte, error)
- func (tx *Transaction) MarshalBinary() ([]byte, error)
- func (tx *Transaction) MarshalJSON() ([]byte, error)
- func (e *Transaction) Protected() bool
- func (tx *Transaction) RbftGetData() []byte
- func (tx *Transaction) RbftGetFrom() string
- func (tx *Transaction) RbftGetNonce() uint64
- func (tx *Transaction) RbftGetSize() int
- func (tx *Transaction) RbftGetTimeStamp() int64
- func (tx *Transaction) RbftGetTxHash() string
- func (tx *Transaction) RbftIsConfigTx() bool
- func (tx *Transaction) RbftMarshal() ([]byte, error)
- func (tx *Transaction) RbftUnmarshal(raw []byte) error
- func (tx *Transaction) Sign(prv *ecdsa.PrivateKey) error
- func (e *Transaction) Size() int
- func (tx *Transaction) Unmarshal(buf []byte) error
- func (tx *Transaction) UnmarshalBinary(b []byte) error
- func (e *Transaction) VerifySignature() error
- type TransactionMeta
- type TxData
- type VpInfo
Constants ¶
const ( LegacyTxType = iota AccessListTxType DynamicFeeTxType )
Transaction types.
const (
BloomByteLength = 256
)
Lengths of hashes and addresses in bytes.
Variables ¶
var ( ErrSyntax = fmt.Errorf("invalid hex string") ErrMissingPrefix = fmt.Errorf("hex string without 0x prefix") ErrOddLength = fmt.Errorf("hex string of odd length") )
hasherPool holds LegacyKeccak256 hashers for rlpHash.
Functions ¶
func InitEIP155Signer ¶
func MarshalObjects ¶
func MarshalObjects[T any, Constraint CodecObjectConstraint[T]](objs []*T) ([]byte, error)
func MarshalReceipts ¶
func MarshalTransactions ¶
func MarshalTransactions(objs []*Transaction) ([]byte, error)
func PrefixedRlpHash ¶
PrefixedRlpHash writes the prefix into the hasher before rlp-encoding x. It's used for typed transactions.
func RecoverPlain ¶
func UnmarshalObjects ¶
func UnmarshalObjects[T any, Constraint CodecObjectConstraint[T]](data []byte) ([]*T, error)
Types ¶
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 types.AccessList // EIP-2930 access list V, R, S *big.Int // signature values }
AccessListTx is the data of EIP-2930 access list transactions.
func (*AccessListTx) GetAccessList ¶
func (tx *AccessListTx) GetAccessList() types.AccessList
func (*AccessListTx) GetChainID ¶
func (tx *AccessListTx) GetChainID() *big.Int
func (*AccessListTx) GetData ¶
func (tx *AccessListTx) GetData() []byte
func (*AccessListTx) GetGas ¶
func (tx *AccessListTx) GetGas() uint64
func (*AccessListTx) GetGasFeeCap ¶
func (tx *AccessListTx) GetGasFeeCap() *big.Int
func (*AccessListTx) GetGasPrice ¶
func (tx *AccessListTx) GetGasPrice() *big.Int
func (*AccessListTx) GetGasTipCap ¶
func (tx *AccessListTx) GetGasTipCap() *big.Int
func (*AccessListTx) GetNonce ¶
func (tx *AccessListTx) GetNonce() uint64
func (*AccessListTx) GetTo ¶
func (tx *AccessListTx) GetTo() *common.Address
func (*AccessListTx) GetValue ¶
func (tx *AccessListTx) GetValue() *big.Int
func (*AccessListTx) RawSignatureValues ¶
func (tx *AccessListTx) RawSignatureValues() (v, r, s *big.Int)
func (*AccessListTx) TxType ¶
func (tx *AccessListTx) TxType() byte
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func NewAddress ¶
BytesToAddress returns Address with value b. If b is larger than len(h), b will be cropped address the left.
func NewAddressByStr ¶
func (*Address) ETHAddress ¶
func (*Address) MarshalJSON ¶
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (*Address) String ¶
String returns an EIP55-compliant hex string representation of the address.
func (*Address) UnmarshalJSON ¶
type Block ¶
type Block struct { BlockHeader *BlockHeader Transactions []*Transaction BlockHash *Hash Signature []byte Extra []byte }
type BlockHeader ¶
type BlockHeader struct { Number uint64 StateRoot *Hash TxRoot *Hash ReceiptRoot *Hash ParentHash *Hash Timestamp int64 Version []byte Bloom *Bloom GasPrice int64 }
func (*BlockHeader) Hash ¶
func (h *BlockHeader) Hash() *Hash
func (*BlockHeader) Marshal ¶
func (h *BlockHeader) Marshal() ([]byte, error)
func (*BlockHeader) Unmarshal ¶
func (h *BlockHeader) Unmarshal(data []byte) error
type Bloom ¶
type Bloom [BloomByteLength]byte
type CallArgs ¶
type CallArgs struct { From *common.Address `json:"from"` To *common.Address `json:"to"` Gas *hexutil.Uint64 `json:"gas"` GasPrice *hexutil.Big `json:"gasPrice"` MaxFeePerGas *hexutil.Big `json:"maxFeePerGas"` MaxPriorityFeePerGas *hexutil.Big `json:"maxPriorityFeePerGas"` Value *hexutil.Big `json:"value"` Nonce *hexutil.Uint64 `json:"nonce"` Data *hexutil.Bytes `json:"data"` Input *hexutil.Bytes `json:"input"` AccessList *types.AccessList `json:"accessList"` ChainID *hexutil.Big `json:"chainId,omitempty"` }
CallArgs represents the arguments for a call.
func (*CallArgs) ToTransaction ¶
func (args *CallArgs) ToTransaction() *types.Transaction
ToTransaction converts the arguments to a transaction. This assumes that setDefaults has been called.
type CodecObject ¶
type CodecObjectConstraint ¶
type CodecObjectConstraint[T any] interface { *T CodecObject }
type CommitEvent ¶
type DynamicFeeTx ¶
type DynamicFeeTx struct { ChainID *big.Int Nonce uint64 GasTipCap *big.Int GasFeeCap *big.Int Gas uint64 To *common.Address `rlp:"nil"` // nil means contract creation Value *big.Int Data []byte AccessList types.AccessList // Signature values V *big.Int `json:"v" gencodec:"required"` R *big.Int `json:"r" gencodec:"required"` S *big.Int `json:"s" gencodec:"required"` }
func (*DynamicFeeTx) GetAccessList ¶
func (tx *DynamicFeeTx) GetAccessList() types.AccessList
func (*DynamicFeeTx) GetChainID ¶
func (tx *DynamicFeeTx) GetChainID() *big.Int
func (*DynamicFeeTx) GetData ¶
func (tx *DynamicFeeTx) GetData() []byte
func (*DynamicFeeTx) GetGas ¶
func (tx *DynamicFeeTx) GetGas() uint64
func (*DynamicFeeTx) GetGasFeeCap ¶
func (tx *DynamicFeeTx) GetGasFeeCap() *big.Int
func (*DynamicFeeTx) GetGasPrice ¶
func (tx *DynamicFeeTx) GetGasPrice() *big.Int
func (*DynamicFeeTx) GetGasTipCap ¶
func (tx *DynamicFeeTx) GetGasTipCap() *big.Int
func (*DynamicFeeTx) GetNonce ¶
func (tx *DynamicFeeTx) GetNonce() uint64
func (*DynamicFeeTx) GetTo ¶
func (tx *DynamicFeeTx) GetTo() *common.Address
func (*DynamicFeeTx) GetValue ¶
func (tx *DynamicFeeTx) GetValue() *big.Int
func (*DynamicFeeTx) RawSignatureValues ¶
func (tx *DynamicFeeTx) RawSignatureValues() (v, r, s *big.Int)
type EIP155Signer ¶
type EIP155Signer struct {
// contains filtered or unexported fields
}
type EvmLog ¶
type EvmLog struct { Address *Address Topics []*Hash Data []byte BlockNumber uint64 TransactionHash *Hash TransactionIndex uint64 BlockHash *Hash LogIndex uint64 Removed bool }
func (*EvmLog) MarshalJSON ¶
MarshalJSON marshals as JSON.
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
func NewHashByStr ¶
func (*Hash) CalculateHash ¶
CalculateHash hashes the values of a TestContent
func (*Hash) MarshalJSON ¶
func (*Hash) UnmarshalJSON ¶
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 regular Ethereum transactions.
func (*LegacyTx) GetAccessList ¶
func (tx *LegacyTx) GetAccessList() types.AccessList
func (*LegacyTx) GetChainID ¶
func (*LegacyTx) GetGasFeeCap ¶
func (*LegacyTx) GetGasPrice ¶
func (*LegacyTx) GetGasTipCap ¶
func (*LegacyTx) RawSignatureValues ¶
type Receipt ¶
type Receipt struct { Version []byte TxHash *Hash Ret []byte Status ReceiptStatus Events []*Event GasUsed uint64 EvmLogs []*EvmLog Bloom *Bloom ContractAddress *Address }
func UnmarshalReceipts ¶
type ReceiptStatus ¶
type ReceiptStatus int32
const ( ReceiptSUCCESS ReceiptStatus = 0 ReceiptFAILED ReceiptStatus = 1 )
func (ReceiptStatus) String ¶
func (x ReceiptStatus) String() string
type Transaction ¶
type Transaction struct { Inner TxData // Consensus contents of a transaction Time time.Time // Time first seen locally (spam avoidance) // contains filtered or unexported fields }
Transaction is an Ethereum transaction.
func GenerateEmptyTransactionAndSigner ¶
func GenerateEmptyTransactionAndSigner() (*Transaction, error)
func UnmarshalTransactions ¶
func UnmarshalTransactions(data []byte) ([]*Transaction, error)
func (*Transaction) DecodeRLP ¶
func (tx *Transaction) DecodeRLP(s *rlp.Stream) error
DecodeRLP implements rlp.Decoder
func (*Transaction) EncodeRLP ¶
func (tx *Transaction) EncodeRLP(w io.Writer) error
EncodeRLP implements rlp.Encoder
func (*Transaction) FromCallArgs ¶
func (e *Transaction) FromCallArgs(callArgs CallArgs)
func (*Transaction) GetChainID ¶
func (e *Transaction) GetChainID() *big.Int
func (*Transaction) GetExtra ¶
func (e *Transaction) GetExtra() []byte
func (*Transaction) GetFrom ¶
func (e *Transaction) GetFrom() *Address
func (*Transaction) GetGas ¶
func (e *Transaction) GetGas() uint64
func (*Transaction) GetGasFeeCap ¶
func (e *Transaction) GetGasFeeCap() *big.Int
func (*Transaction) GetGasPrice ¶
func (e *Transaction) GetGasPrice() *big.Int
func (*Transaction) GetGasTipCap ¶
func (e *Transaction) GetGasTipCap() *big.Int
func (*Transaction) GetHash ¶
func (e *Transaction) GetHash() *Hash
func (*Transaction) GetInner ¶
func (e *Transaction) GetInner() TxData
func (*Transaction) GetNonce ¶
func (e *Transaction) GetNonce() uint64
func (*Transaction) GetPayload ¶
func (e *Transaction) GetPayload() []byte
func (*Transaction) GetRawSignature ¶
func (e *Transaction) GetRawSignature() (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.
func (*Transaction) GetSignHash ¶
func (e *Transaction) GetSignHash() *Hash
func (*Transaction) GetSignature ¶
func (e *Transaction) GetSignature() []byte
func (*Transaction) GetTimeStamp ¶
func (e *Transaction) GetTimeStamp() int64
func (*Transaction) GetTo ¶
func (e *Transaction) GetTo() *Address
func (*Transaction) GetType ¶
func (e *Transaction) GetType() byte
Type returns the transaction type.
func (*Transaction) GetValue ¶
func (e *Transaction) GetValue() *big.Int
func (*Transaction) GetVersion ¶
func (e *Transaction) GetVersion() []byte
func (*Transaction) Marshal ¶
func (tx *Transaction) Marshal() ([]byte, error)
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)
func (*Transaction) Protected ¶
func (e *Transaction) Protected() bool
Protected says whether the transaction is replay-protected.
func (*Transaction) RbftGetData ¶
func (tx *Transaction) RbftGetData() []byte
func (*Transaction) RbftGetFrom ¶
func (tx *Transaction) RbftGetFrom() string
func (*Transaction) RbftGetNonce ¶
func (tx *Transaction) RbftGetNonce() uint64
func (*Transaction) RbftGetSize ¶
func (tx *Transaction) RbftGetSize() int
func (*Transaction) RbftGetTimeStamp ¶
func (tx *Transaction) RbftGetTimeStamp() int64
func (*Transaction) RbftGetTxHash ¶
func (tx *Transaction) RbftGetTxHash() string
func (*Transaction) RbftIsConfigTx ¶
func (tx *Transaction) RbftIsConfigTx() bool
func (*Transaction) RbftMarshal ¶
func (tx *Transaction) RbftMarshal() ([]byte, error)
func (*Transaction) RbftUnmarshal ¶
func (tx *Transaction) RbftUnmarshal(raw []byte) error
func (*Transaction) Sign ¶
func (tx *Transaction) Sign(prv *ecdsa.PrivateKey) error
func (*Transaction) Size ¶
func (e *Transaction) Size() int
func (*Transaction) Unmarshal ¶
func (tx *Transaction) Unmarshal(buf []byte) error
func (*Transaction) UnmarshalBinary ¶
func (tx *Transaction) UnmarshalBinary(b []byte) error
UnmarshalBinary decodes the canonical encoding of transactions. It supports legacy RLP transactions and EIP2718 typed transactions.
func (*Transaction) VerifySignature ¶
func (e *Transaction) VerifySignature() error
type TransactionMeta ¶
func (*TransactionMeta) Marshal ¶
func (m *TransactionMeta) Marshal() ([]byte, error)
func (*TransactionMeta) Unmarshal ¶
func (m *TransactionMeta) Unmarshal(data []byte) error
type TxData ¶
type TxData interface { TxType() byte // returns the type ID GetChainID() *big.Int GetAccessList() types.AccessList GetData() []byte GetGas() uint64 GetGasPrice() *big.Int GetGasTipCap() *big.Int GetGasFeeCap() *big.Int GetValue() *big.Int GetNonce() uint64 GetTo() *common.Address RawSignatureValues() (v, r, s *big.Int) // contains filtered or unexported methods }
TxData is the underlying data of a transaction.
This is implemented by DynamicFeeTx, LegacyTx and AccessListTx.