types

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 9 Imported by: 46

Documentation

Index

Constants

View Source
const AddressLength = 20

AddressLength is the length of an Ethereum address in bytes.

View Source
const HashLength = 32

Variables

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

ZeroAddress is an address with all zeros.

View Source
var ZeroHash = Hash{}

ZeroHash is a hash with all zeros.

Functions

This section is empty.

Types

type AccessList

type AccessList []AccessTuple

AccessList is an EIP-2930 access list.

func (*AccessList) Copy added in v0.4.0

func (a *AccessList) Copy() AccessList

func (*AccessList) DecodeRLP

func (a *AccessList) DecodeRLP(data []byte) (int, error)

func (AccessList) EncodeRLP

func (a AccessList) EncodeRLP() ([]byte, error)

type AccessTuple

type AccessTuple struct {
	Address     Address `json:"address"`
	StorageKeys []Hash  `json:"storageKeys"`
}

AccessTuple is the element type of access list.

func (*AccessTuple) Copy added in v0.4.0

func (a *AccessTuple) Copy() AccessTuple

func (*AccessTuple) DecodeRLP

func (a *AccessTuple) DecodeRLP(data []byte) (int, error)

func (AccessTuple) EncodeRLP

func (a AccessTuple) EncodeRLP() ([]byte, error)

type Address

type Address [AddressLength]byte

Address represents an Ethereum address encoded as a 20 byte array.

func AddressFromBytes

func AddressFromBytes(b []byte) (Address, error)

AddressFromBytes converts a byte slice to an Address type.

func AddressFromBytesPtr

func AddressFromBytesPtr(b []byte) *Address

AddressFromBytesPtr converts a byte slice to an *Address type. It returns nil if the address is invalid.

func AddressFromHex

func AddressFromHex(h string) (a Address, err error)

AddressFromHex parses an address in hex format and returns an Address type.

func AddressFromHexPtr

func AddressFromHexPtr(h string) *Address

AddressFromHexPtr parses an address in hex format and returns an *Address type. It returns nil if the address is invalid.

func MustAddressFromBytes

func MustAddressFromBytes(b []byte) Address

MustAddressFromBytes converts a byte slice to an Address type. It panics if the address is invalid.

func MustAddressFromBytesPtr

func MustAddressFromBytesPtr(b []byte) *Address

MustAddressFromBytesPtr converts a byte slice to an *Address type. It panics if the address is invalid.

func MustAddressFromHex

func MustAddressFromHex(h string) Address

MustAddressFromHex parses an address in hex format and returns an Address type. It panics if the address is invalid.

func MustAddressFromHexPtr

func MustAddressFromHexPtr(h string) *Address

MustAddressFromHexPtr parses an address in hex format and returns an *Address type. It panics if the address is invalid.

func (Address) Bytes

func (t Address) Bytes() []byte

Bytes returns the byte representation of the address.

func (Address) Checksum

func (t Address) Checksum(h HashFunc) string

Checksum returns the address with the checksum calculated according to EIP-55.

HashFunc is the hash function used to calculate the checksum, most likely crypto.Keccak256.

func (*Address) DecodeRLP

func (t *Address) DecodeRLP(data []byte) (int, error)

func (Address) EncodeRLP

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

func (Address) IsZero

func (t Address) IsZero() bool

IsZero returns true if the address is the zero address.

func (Address) MarshalJSON

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

func (Address) MarshalText

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

func (Address) String

func (t Address) String() string

String returns the hex representation of the address.

func (*Address) UnmarshalJSON

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

func (*Address) UnmarshalText

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

type Block

type Block struct {
	Number            *big.Int             // Block is the block number.
	Hash              Hash                 // Hash is the hash of the block.
	ParentHash        Hash                 // ParentHash is the hash of the parent block.
	StateRoot         Hash                 // StateRoot is the root hash of the state trie.
	ReceiptsRoot      Hash                 // ReceiptsRoot is the root hash of the receipts trie.
	TransactionsRoot  Hash                 // TransactionsRoot is the root hash of the transactions trie.
	MixHash           Hash                 // MixHash is the hash of the seed used for the DAG.
	Sha3Uncles        Hash                 // Sha3Uncles is the SHA3 hash of the uncles data in the block.
	Nonce             *big.Int             // Nonce is the block's nonce.
	Miner             Address              // Miner is the address of the beneficiary to whom the mining rewards were given.
	LogsBloom         []byte               // LogsBloom is the bloom filter for the logs of the block.
	Difficulty        *big.Int             // Difficulty is the difficulty for this block.
	TotalDifficulty   *big.Int             // TotalDifficulty is the total difficulty of the chain until this block.
	Size              uint64               // Size is the size of the block in bytes.
	GasLimit          uint64               // GasLimit is the maximum gas allowed in this block.
	GasUsed           uint64               // GasUsed is the total used gas by all transactions in this block.
	Timestamp         time.Time            // Timestamp is the time at which the block was collated.
	Uncles            []Hash               // Uncles is the list of uncle hashes.
	Transactions      []OnChainTransaction // Transactions is the list of transactions in the block.
	TransactionHashes []Hash               // TransactionHashes is the list of transaction hashes in the block.
	ExtraData         []byte               // ExtraData is the "extra data" field of this block.
}

func (Block) MarshalJSON

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

func (*Block) UnmarshalJSON

func (b *Block) UnmarshalJSON(data []byte) error

type BlockNumber

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

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

func BlockNumberFromBigInt

func BlockNumberFromBigInt(x *big.Int) BlockNumber

BlockNumberFromBigInt converts a big.Int to a BlockNumber type.

func BlockNumberFromBigIntPtr

func BlockNumberFromBigIntPtr(x *big.Int) *BlockNumber

BlockNumberFromBigIntPtr converts a big.Int to a *BlockNumber type.

func BlockNumberFromHex

func BlockNumberFromHex(h string) (BlockNumber, error)

BlockNumberFromHex converts a string to a BlockNumber type. The string can be a hex number or one of the following strings: "earliest", "latest", "safe", "finalized", "pending". If the string is not a valid block number, it returns an error.

func BlockNumberFromHexPtr

func BlockNumberFromHexPtr(h string) *BlockNumber

BlockNumberFromHexPtr converts a string to a *BlockNumber type. The string can be a hex number or one of the following strings: "earliest", "latest", "safe", "finalized", "pending". If the string is not a valid block number, it returns nil.

func BlockNumberFromUint64

func BlockNumberFromUint64(x uint64) BlockNumber

BlockNumberFromUint64 converts an uint64 to a BlockNumber type.

func BlockNumberFromUint64Ptr

func BlockNumberFromUint64Ptr(x uint64) *BlockNumber

BlockNumberFromUint64Ptr converts an uint64 to a *BlockNumber type.

func MustBlockNumberFromHex

func MustBlockNumberFromHex(h string) BlockNumber

MustBlockNumberFromHex converts a string to a BlockNumber type. The string can be a hex number or one of the following strings: "earliest", "latest", "safe", "finalized", "pending". It panics if the string is not a valid block number.

func MustBlockNumberFromHexPtr

func MustBlockNumberFromHexPtr(h string) *BlockNumber

MustBlockNumberFromHexPtr converts a string to a *BlockNumber type. The string can be a hex number or one of the following strings: "earliest", "latest", "safe", "finalized", "pending". It panics if the string is not a valid block number.

func (*BlockNumber) Big

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

Big returns the big.Int representation of the block number.

func (*BlockNumber) IsEarliest

func (t *BlockNumber) IsEarliest() bool

IsEarliest returns true if the block tag is "earliest".

func (*BlockNumber) IsFinalized added in v0.6.1

func (t *BlockNumber) IsFinalized() bool

IsFinalized returns true if the block tag is "finalized".

func (*BlockNumber) IsLatest

func (t *BlockNumber) IsLatest() bool

IsLatest returns true if the block tag is "latest".

func (*BlockNumber) IsPending

func (t *BlockNumber) IsPending() bool

IsPending returns true if the block tag is "pending".

func (*BlockNumber) IsSafe added in v0.6.1

func (t *BlockNumber) IsSafe() bool

IsSafe returns true if the block tag is "safe".

func (*BlockNumber) IsTag

func (t *BlockNumber) IsTag() bool

IsTag returns true if the block tag is used.

func (BlockNumber) MarshalJSON

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

func (BlockNumber) MarshalText

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

func (*BlockNumber) String

func (t *BlockNumber) String() string

String returns the string representation of the block number.

func (*BlockNumber) UnmarshalJSON

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

func (*BlockNumber) UnmarshalText

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

type Bytes

type Bytes []byte

Bytes represents a hex-encoded byte slice. This type is used for marshaling and unmarshalling JSON numbers. When possible, use byte slices instead.

func BytesFromHex

func BytesFromHex(h string) (Bytes, error)

BytesFromHex converts a hex string to a Bytes type.

func BytesFromHexPtr

func BytesFromHexPtr(h string) *Bytes

BytesFromHexPtr converts a hex string to a *Bytes type. If the input is not a valid hex string, it returns nil.

func BytesFromString

func BytesFromString(s string) Bytes

BytesFromString converts a string to a Bytes type.

func BytesFromStringPtr

func BytesFromStringPtr(s string) *Bytes

BytesFromStringPtr converts a string to a *Bytes type.

func MustBytesFromHex

func MustBytesFromHex(h string) Bytes

MustBytesFromHex converts a hex string to a Bytes type. It panics if the input is not a valid hex string.

func MustBytesFromHexPtr

func MustBytesFromHexPtr(h string) *Bytes

MustBytesFromHexPtr converts a hex string to a *Bytes type. It panics if the input is not a valid hex string.

func (*Bytes) Bytes

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

Bytes returns the byte slice.

func (Bytes) MarshalJSON

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

func (Bytes) MarshalText

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

func (Bytes) PadLeft

func (b Bytes) PadLeft(n int) Bytes

PadLeft returns a new byte slice padded with zeros to the given length. If the byte slice is longer than the given length, it is truncated leaving the rightmost bytes.

func (Bytes) PadRight

func (b Bytes) PadRight(n int) Bytes

PadRight returns a new byte slice padded with zeros to the given length. If the byte slice is longer than the given length, it is truncated leaving the leftmost bytes.

func (*Bytes) String

func (b *Bytes) String() string

String returns the hex-encoded string representation of the byte slice.

func (*Bytes) UnmarshalJSON

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

func (*Bytes) UnmarshalText

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

type Call

type Call struct {
	From     *Address // From is the sender address.
	To       *Address // To is the recipient address. nil means contract creation.
	GasLimit *uint64  // GasLimit is the gas limit, if 0, there is no limit.
	GasPrice *big.Int // GasPrice is the gas price in wei per gas unit.
	Value    *big.Int // Value is the amount of wei to send.
	Input    []byte   // Input is the input data.

	// EIP-2930 fields:
	AccessList AccessList // AccessList is the list of addresses and storage keys that the transaction can access.

	// EIP-1559 fields:
	MaxPriorityFeePerGas *big.Int // MaxPriorityFeePerGas is the maximum priority fee per gas the sender is willing to pay.
	MaxFeePerGas         *big.Int // MaxFeePerGas is the maximum fee per gas the sender is willing to pay.
}

Call represents a call to a contract or a contract creation if To is nil.

func NewCall added in v0.5.0

func NewCall() *Call

func (Call) Copy added in v0.4.0

func (c Call) Copy() *Call

func (Call) MarshalJSON

func (c Call) MarshalJSON() ([]byte, error)

func (*Call) SetAccessList

func (c *Call) SetAccessList(accessList AccessList) *Call

func (*Call) SetFrom

func (c *Call) SetFrom(from Address) *Call

func (*Call) SetGasLimit

func (c *Call) SetGasLimit(gasLimit uint64) *Call

func (*Call) SetGasPrice

func (c *Call) SetGasPrice(gasPrice *big.Int) *Call

func (*Call) SetInput

func (c *Call) SetInput(input []byte) *Call

func (*Call) SetMaxFeePerGas

func (c *Call) SetMaxFeePerGas(maxFeePerGas *big.Int) *Call

func (*Call) SetMaxPriorityFeePerGas

func (c *Call) SetMaxPriorityFeePerGas(maxPriorityFeePerGas *big.Int) *Call

func (*Call) SetTo

func (c *Call) SetTo(to Address) *Call

func (*Call) SetValue

func (c *Call) SetValue(value *big.Int) *Call

func (*Call) UnmarshalJSON

func (c *Call) UnmarshalJSON(data []byte) error

type FeeHistory

type FeeHistory struct {
	OldestBlock   uint64       // OldestBlock is the oldest block number for which the base fee and gas used are returned.
	Reward        [][]*big.Int // Reward is the reward for each block in the range [OldestBlock, LatestBlock].
	BaseFeePerGas []*big.Int   // BaseFeePerGas is the base fee per gas for each block in the range [OldestBlock, LatestBlock].
	GasUsedRatio  []float64    // GasUsedRatio is the gas used ratio for each block in the range [OldestBlock, LatestBlock].
}

FeeHistory represents the result of the feeHistory Client call.

func (FeeHistory) MarshalJSON

func (f FeeHistory) MarshalJSON() ([]byte, error)

func (*FeeHistory) UnmarshalJSON

func (f *FeeHistory) UnmarshalJSON(input []byte) error

type FilterLogsQuery

type FilterLogsQuery struct {
	Address   []Address
	FromBlock *BlockNumber
	ToBlock   *BlockNumber
	Topics    [][]Hash
	BlockHash *Hash
}

FilterLogsQuery represents a query to filter logs.

func NewFilterLogsQuery added in v0.5.0

func NewFilterLogsQuery() *FilterLogsQuery

func (*FilterLogsQuery) AddAddresses

func (q *FilterLogsQuery) AddAddresses(addresses ...Address) *FilterLogsQuery

func (*FilterLogsQuery) AddTopics

func (q *FilterLogsQuery) AddTopics(topics ...[]Hash) *FilterLogsQuery

func (FilterLogsQuery) MarshalJSON

func (q FilterLogsQuery) MarshalJSON() ([]byte, error)

func (*FilterLogsQuery) SetAddresses

func (q *FilterLogsQuery) SetAddresses(addresses ...Address) *FilterLogsQuery

func (*FilterLogsQuery) SetBlockHash

func (q *FilterLogsQuery) SetBlockHash(blockHash *Hash) *FilterLogsQuery

func (*FilterLogsQuery) SetFromBlock

func (q *FilterLogsQuery) SetFromBlock(fromBlock *BlockNumber) *FilterLogsQuery

func (*FilterLogsQuery) SetToBlock

func (q *FilterLogsQuery) SetToBlock(toBlock *BlockNumber) *FilterLogsQuery

func (*FilterLogsQuery) SetTopics

func (q *FilterLogsQuery) SetTopics(topics ...[]Hash) *FilterLogsQuery

func (*FilterLogsQuery) UnmarshalJSON

func (q *FilterLogsQuery) UnmarshalJSON(input []byte) error

type Hash

type Hash [HashLength]byte

Hash represents the 32 byte Keccak256 hash of arbitrary data.

func HashFromBigInt

func HashFromBigInt(i *big.Int) (Hash, error)

HashFromBigInt converts a big.Int to a Hash type. Negative numbers are represented as two's complement.

func HashFromBigIntPtr

func HashFromBigIntPtr(i *big.Int) *Hash

HashFromBigIntPtr converts a big.Int to a *Hash type. Negative numbers are represented as two's complement. It returns nil if the hash is invalid.

func HashFromBytes

func HashFromBytes(b []byte, pad Pad) (Hash, error)

HashFromBytes converts a byte slice to a Hash type. If bytes is longer than 32 bytes, it returns an error.

func HashFromBytesPtr

func HashFromBytesPtr(b []byte, pad Pad) *Hash

HashFromBytesPtr converts a byte slice to a *Hash type. If bytes is longer than 32 bytes, it returns an error. It returns nil if the hash is invalid.

func HashFromHex

func HashFromHex(h string, pad Pad) (Hash, error)

HashFromHex parses a hash in hex format and returns a Hash type. If hash is longer than 32 bytes, it returns an error.

func HashFromHexPtr

func HashFromHexPtr(h string, pad Pad) *Hash

HashFromHexPtr parses a hash in hex format and returns a *Hash type. If hash is longer than 32 bytes, it returns an error. It returns nil if the hash is invalid.

func MustHashFromBigInt

func MustHashFromBigInt(i *big.Int) Hash

MustHashFromBigInt converts a big.Int to a Hash type. Negative numbers are represented as two's complement. It panics if the hash is invalid.

func MustHashFromBigIntPtr

func MustHashFromBigIntPtr(i *big.Int) *Hash

MustHashFromBigIntPtr converts a big.Int to a *Hash type. Negative numbers are represented as two's complement. It panics if the hash is invalid.

func MustHashFromBytes

func MustHashFromBytes(b []byte, pad Pad) Hash

MustHashFromBytes converts a byte slice to a Hash type. If bytes is longer than 32 bytes, it returns an error. It panics if the hash is invalid.

func MustHashFromBytesPtr

func MustHashFromBytesPtr(b []byte, pad Pad) *Hash

MustHashFromBytesPtr converts a byte slice to a *Hash type. If bytes is longer than 32 bytes, it returns an error. It panics if the hash is invalid.

func MustHashFromHex

func MustHashFromHex(h string, pad Pad) Hash

MustHashFromHex parses a hash in hex format and returns a Hash type. If hash is longer than 32 bytes, it returns an error. It panics if the hash is invalid.

func MustHashFromHexPtr

func MustHashFromHexPtr(h string, pad Pad) *Hash

MustHashFromHexPtr parses a hash in hex format and returns a *Hash type. If hash is longer than 32 bytes, it returns an error. It panics if the hash is invalid.

func (Hash) Bytes

func (t Hash) Bytes() []byte

Bytes returns hash as a byte slice.

func (*Hash) DecodeRLP

func (t *Hash) DecodeRLP(data []byte) (int, error)

func (Hash) EncodeRLP

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

func (Hash) IsZero

func (t Hash) IsZero() bool

IsZero returns true if the hash is the zero hash.

func (Hash) MarshalJSON

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

func (Hash) MarshalText

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

func (Hash) String

func (t Hash) String() string

String returns the hex string representation of the hash.

func (*Hash) UnmarshalJSON

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

func (*Hash) UnmarshalText

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

type HashFunc

type HashFunc func(data ...[]byte) Hash

HashFunc returns the hash for the given input.

type Log

type Log struct {
	Address          Address  // Address of the contract that generated the event
	Topics           []Hash   // Topics provide information about the event type.
	Data             []byte   // Data contains the non-indexed arguments of the event.
	BlockHash        *Hash    // BlockHash is the hash of the block where this log was in. Nil when pending.
	BlockNumber      *big.Int // BlockNumber is the block number where this log was in. Nil when pending.
	TransactionHash  *Hash    // TransactionHash is the hash of the transaction that generated this log. Nil when pending.
	TransactionIndex *uint64  // TransactionIndex is the index of the transaction in the block. Nil when pending.
	LogIndex         *uint64  // LogIndex is the index of the log in the block. Nil when pending.
	Removed          bool     // Removed is true if the log was reverted due to a chain reorganization. False if unknown.
}

Log represents a contract log event.

func (Log) MarshalJSON

func (l Log) MarshalJSON() ([]byte, error)

func (*Log) UnmarshalJSON

func (l *Log) UnmarshalJSON(input []byte) error

type Number

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

Number represents a hex-encoded number. This type is used for marshaling and unmarshalling JSON numbers. When possible, use big.Int or regular integers instead.

func MustNumberFromHex

func MustNumberFromHex(h string) Number

MustNumberFromHex converts a hex string to a Number type. It panics if the conversion fails.

func MustNumberFromHexPtr

func MustNumberFromHexPtr(h string) *Number

MustNumberFromHexPtr converts a hex string to a *Number type. It panics if the conversion fails.

func NumberFromBigInt

func NumberFromBigInt(x *big.Int) Number

NumberFromBigInt converts a big.Int to a Number type.

func NumberFromBigIntPtr

func NumberFromBigIntPtr(x *big.Int) *Number

NumberFromBigIntPtr converts a big.Int to a *Number type.

func NumberFromBytes

func NumberFromBytes(b []byte) Number

NumberFromBytes converts a byte slice to a Number type.

func NumberFromBytesPtr

func NumberFromBytesPtr(b []byte) *Number

NumberFromBytesPtr converts a byte slice to a *Number type.

func NumberFromHex

func NumberFromHex(h string) (Number, error)

NumberFromHex converts a hex string to a Number type.

func NumberFromHexPtr

func NumberFromHexPtr(h string) *Number

NumberFromHexPtr converts a hex string to a *Number type.

func NumberFromUint64

func NumberFromUint64(x uint64) Number

NumberFromUint64 converts an uint64 to a Number type.

func NumberFromUint64Ptr

func NumberFromUint64Ptr(x uint64) *Number

NumberFromUint64Ptr converts an uint64 to a *Number type.

func (*Number) Big

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

Big returns the big.Int representation of the number.

func (*Number) Bytes

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

Bytes returns the byte representation of the number.

func (Number) MarshalJSON

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

func (Number) MarshalText

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

func (*Number) String

func (t *Number) String() string

String returns the hex representation of the number.

func (*Number) UnmarshalJSON

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

func (*Number) UnmarshalText

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

type OnChainTransaction

type OnChainTransaction struct {
	Transaction

	// On-chain fields, only available when the transaction is included in a block:
	Hash             *Hash    // Hash of the transaction.
	BlockHash        *Hash    // BlockHash is the hash of the block where this transaction was in.
	BlockNumber      *big.Int // BlockNumber is the block number where this transaction was in.
	TransactionIndex *uint64  // TransactionIndex is the index of the transaction in the block.
}

OnChainTransaction represents a transaction that is included in a block.

func (OnChainTransaction) MarshalJSON

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

func (*OnChainTransaction) UnmarshalJSON

func (t *OnChainTransaction) UnmarshalJSON(data []byte) error

type Pad

type Pad uint8

Pad is a padding type.

const (
	PadNone  Pad = 0 // PadNone does not allow padding.
	PadLeft  Pad = 1 // PadLeft pads the input with zeros on the left.
	PadRight Pad = 2 // PadRight pads the input with zeros on the right.
)

type Signature

type Signature struct {
	V *big.Int
	R *big.Int
	S *big.Int
}

Signature represents the transaction signature.

func MustSignatureFromBytes

func MustSignatureFromBytes(b []byte) Signature

MustSignatureFromBytes returns Signature from bytes. Byte representation of the signature is [R || S || V]. It panics if the length of the bytes is not 65.

func MustSignatureFromBytesPtr

func MustSignatureFromBytesPtr(b []byte) *Signature

MustSignatureFromBytesPtr returns *Signature from bytes. Byte representation of the signature is [R || S || V]. It panics if the length of the bytes is not 65.

func MustSignatureFromHex

func MustSignatureFromHex(h string) Signature

MustSignatureFromHex parses a hex string into a Signature. Hex representation of the signature is hex([R || S || V]). It panics if the string is not a valid signature.

func MustSignatureFromHexPtr

func MustSignatureFromHexPtr(h string) *Signature

MustSignatureFromHexPtr parses a hex string into a *Signature. Hex representation of the signature is hex([R || S || V]). It panics if the string is not a valid signature.

func SignatureFromBytes

func SignatureFromBytes(b []byte) (Signature, error)

SignatureFromBytes returns Signature from bytes. Byte representation of the signature is [R || S || V].

func SignatureFromBytesPtr

func SignatureFromBytesPtr(b []byte) *Signature

SignatureFromBytesPtr returns *Signature from bytes. Byte representation of the signature is [R || S || V]. It returns nil if the length of the bytes is not 65.

func SignatureFromHex

func SignatureFromHex(h string) (Signature, error)

SignatureFromHex parses a hex string into a Signature. Hex representation of the signature is hex([R || S || V]).

func SignatureFromHexPtr

func SignatureFromHexPtr(h string) *Signature

SignatureFromHexPtr parses a hex string into a *Signature. Hex representation of the signature is hex([R || S || V]). It returns nil if the string is not a valid signature.

func SignatureFromVRS

func SignatureFromVRS(v, r, s *big.Int) Signature

SignatureFromVRS returns Signature from V, R, S values.

func SignatureFromVRSPtr

func SignatureFromVRSPtr(v, r, s *big.Int) *Signature

SignatureFromVRSPtr returns *Signature from V, R, S values.

func (Signature) Bytes

func (s Signature) Bytes() []byte

Bytes returns the byte representation of the signature. The byte representation is [R || S || V].

func (Signature) Copy added in v0.4.0

func (s Signature) Copy() *Signature

func (Signature) Equal added in v0.6.1

func (s Signature) Equal(c Signature) bool

Equal returns true if the signature is equal to the given signature.

Nil values are considered as zero.

func (Signature) IsZero

func (s Signature) IsZero() bool

IsZero returns true if the signature is zero.

func (Signature) MarshalJSON

func (s Signature) MarshalJSON() ([]byte, error)

func (Signature) MarshalText

func (s Signature) MarshalText() ([]byte, error)

func (Signature) String

func (s Signature) String() string

String returns the hex representation of the signature. The hex representation is hex([R || S || V]).

func (*Signature) UnmarshalJSON

func (s *Signature) UnmarshalJSON(input []byte) error

func (*Signature) UnmarshalText

func (s *Signature) UnmarshalText(input []byte) error

type SyncStatus added in v0.6.1

type SyncStatus struct {
	StartingBlock BlockNumber `json:"startingBlock"`
	CurrentBlock  BlockNumber `json:"currentBlock"`
	HighestBlock  BlockNumber `json:"highestBlock"`
}

SyncStatus represents the sync status of a node.

type Transaction

type Transaction struct {
	Call

	// Transaction data:
	Type      TransactionType // Type is the transaction type.
	Nonce     *uint64         // Nonce is the number of transactions made by the sender prior to this one.
	Signature *Signature      // Signature of the transaction.

	// EIP-2930 fields:
	ChainID *uint64 // ChainID is the chain ID of the transaction.
}

Transaction represents a transaction.

func NewTransaction added in v0.5.0

func NewTransaction() *Transaction

func (*Transaction) Copy added in v0.4.0

func (t *Transaction) Copy() *Transaction

func (*Transaction) DecodeRLP

func (t *Transaction) DecodeRLP(data []byte) (int, error)

func (Transaction) EncodeRLP

func (t Transaction) EncodeRLP() ([]byte, error)

func (Transaction) Hash

func (t Transaction) Hash(h HashFunc) (Hash, error)

Hash returns the hash of the transaction (transaction ID).

func (Transaction) MarshalJSON

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

func (Transaction) Raw

func (t Transaction) Raw() ([]byte, error)

Raw returns the raw transaction data that could be sent to the network.

func (*Transaction) SetAccessList

func (t *Transaction) SetAccessList(accessList AccessList) *Transaction

func (*Transaction) SetChainID

func (t *Transaction) SetChainID(chainID uint64) *Transaction

func (*Transaction) SetFrom

func (t *Transaction) SetFrom(from Address) *Transaction

func (*Transaction) SetGasLimit

func (t *Transaction) SetGasLimit(gasLimit uint64) *Transaction

func (*Transaction) SetGasPrice

func (t *Transaction) SetGasPrice(gasPrice *big.Int) *Transaction

func (*Transaction) SetInput

func (t *Transaction) SetInput(input []byte) *Transaction

func (*Transaction) SetMaxFeePerGas

func (t *Transaction) SetMaxFeePerGas(maxFeePerGas *big.Int) *Transaction

func (*Transaction) SetMaxPriorityFeePerGas

func (t *Transaction) SetMaxPriorityFeePerGas(maxPriorityFeePerGas *big.Int) *Transaction

func (*Transaction) SetNonce

func (t *Transaction) SetNonce(nonce uint64) *Transaction

func (*Transaction) SetSignature

func (t *Transaction) SetSignature(signature Signature) *Transaction

func (*Transaction) SetTo

func (t *Transaction) SetTo(to Address) *Transaction

func (*Transaction) SetType

func (t *Transaction) SetType(transactionType TransactionType) *Transaction

func (*Transaction) SetValue

func (t *Transaction) SetValue(value *big.Int) *Transaction

func (*Transaction) UnmarshalJSON

func (t *Transaction) UnmarshalJSON(data []byte) error

type TransactionReceipt

type TransactionReceipt struct {
	TransactionHash   Hash     // TransactionHash is the hash of the transaction.
	TransactionIndex  uint64   // TransactionIndex is the index of the transaction in the block.
	BlockHash         Hash     // BlockHash is the hash of the block.
	BlockNumber       *big.Int // BlockNumber is the number of the block.
	From              Address  // From is the sender of the transaction.
	To                Address  // To is the recipient of the transaction.
	CumulativeGasUsed uint64   // CumulativeGasUsed is the total amount of gas used when this transaction was executed in the block.
	EffectiveGasPrice *big.Int // EffectiveGasPrice is the effective gas price of the transaction.
	GasUsed           uint64   // GasUsed is the amount of gas used by this specific transaction alone.
	ContractAddress   *Address // ContractAddress is the contract address created, if the transaction was a contract creation, otherwise nil.
	Logs              []Log    // Logs is the list of logs generated by the transaction.
	LogsBloom         []byte   // LogsBloom is the bloom filter for the logs of the transaction.
	Root              *Hash    // Root is the root of the state trie after the transaction.
	Status            *uint64  // Status is the status of the transaction.
}

TransactionReceipt represents transaction receipt.

func (TransactionReceipt) MarshalJSON

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

func (*TransactionReceipt) UnmarshalJSON

func (t *TransactionReceipt) UnmarshalJSON(data []byte) error

type TransactionType

type TransactionType uint64

TransactionType is the type of transaction.

const (
	LegacyTxType TransactionType = iota
	AccessListTxType
	DynamicFeeTxType
)

Transaction types.

Jump to

Keyboard shortcuts

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