eth

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2022 License: MIT Imports: 11 Imported by: 12

Documentation

Overview

Package eth implements RPC API bindings for methods in the "eth" namespace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Balance

func Balance(addr common.Address, blockNumber *big.Int) core.CallFactoryReturns[big.Int]

Balance requests the balance of the given common.Address addr at the given blockNumber. If blockNumber is nil, the balance at the latest known block is requested.

func BlockByHash added in v0.2.0

BlockByHash requests the block with full transactions with the given hash.

func BlockByNumber added in v0.2.0

func BlockByNumber(number *big.Int) interface {
	core.CallFactoryReturns[types.Block]
	core.CallFactoryReturnsRAW[RPCBlock]
}

BlockByNumber requests the block with full transactions with the given number.

func BlockNumber

func BlockNumber() core.CallFactoryReturns[big.Int]

BlockNumber requests the number of the most recent block.

func Call

func Call(msg ethereum.CallMsg, blockNumber *big.Int, overrides AccountOverrides) core.CallFactoryReturns[[]byte]

Call requests the output data of the given message at the given blockNumber. If blockNumber is nil, the output of the message at the latest known block is requested.

func ChainID

func ChainID() core.CallFactoryReturns[uint64]

ChainID requests the chains ID.

func Code

func Code(addr common.Address, blockNumber *big.Int) core.CallFactoryReturns[[]byte]

Code requests the code of the given common.Address addr at the given blockNumber. If blockNumber is nil, the code at the latest known block is requested.

func GasPrice

func GasPrice() core.CallFactoryReturns[big.Int]

GasPrice requests the current gas price in wei.

func HeaderByHash added in v0.2.0

HeaderByHash requests the header with the given hash.

func HeaderByNumber added in v0.2.0

func HeaderByNumber(number *big.Int) interface {
	core.CallFactoryReturns[types.Header]
	core.CallFactoryReturnsRAW[RPCHeader]
}

HeaderByNumber requests the header with the given number.

func Logs added in v0.2.0

func Logs(q ethereum.FilterQuery) core.CallFactoryReturns[[]types.Log]

Logs requests the logs of the given ethereum.FilterQuery q.

func Nonce

func Nonce(addr common.Address, blockNumber *big.Int) core.CallFactoryReturns[uint64]

Nonce requests the nonce of the given common.Address addr at the given blockNumber. If blockNumber is nil, the nonce at the latest known block is requested.

func SendRawTransaction added in v0.2.0

func SendRawTransaction(rawTx []byte) core.CallFactoryReturns[common.Hash]

SendRawTransaction sends a raw transaction to the network.

func SendTransaction added in v0.2.0

func SendTransaction(tx *types.Transaction) core.CallFactoryReturns[common.Hash]

SendTransaction sends a signed transaction to the network.

func StorageAt

func StorageAt(addr common.Address, slot common.Hash, blockNumber *big.Int) core.CallFactoryReturns[common.Hash]

StorageAt requests the storage of the given common.Address addr at the given common.Hash slot at the given blockNumber. If block number is nil, the slot at the latest known block is requested.

func TransactionByHash added in v0.2.0

TransactionByHash requests the transaction with the given hash.

func TransactionReceipt added in v0.2.0

func TransactionReceipt(hash common.Hash) interface {
	core.CallFactoryReturns[types.Receipt]
	core.CallFactoryReturnsRAW[RPCReceipt]
}

TransactionReceipt requests the receipt of the transaction with the given hash.

Types

type Account added in v0.6.0

type Account struct {
	Nonce     *uint64
	Code      []byte
	Balance   *big.Int
	State     map[common.Hash]common.Hash
	StateDiff map[common.Hash]common.Hash
}

func (Account) MarshalJSON added in v0.6.0

func (oa Account) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler.

type AccountOverrides added in v0.6.0

type AccountOverrides map[common.Address]Account

AccountOverrides is the collection of overridden accounts.

type CallFuncFactory

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

func CallFunc

func CallFunc(fn core.Func, contract common.Address, args ...any) *CallFuncFactory

CallFunc requests the returns of Func fn at common.Address contract with the given args.

func (*CallFuncFactory) AtBlock

func (f *CallFuncFactory) AtBlock(blockNumber *big.Int) *CallFuncFactory

func (*CallFuncFactory) CreateRequest

func (f *CallFuncFactory) CreateRequest() (rpc.BatchElem, error)

CreateRequest implements the core.RequestCreator interface.

func (*CallFuncFactory) From added in v0.6.0

func (*CallFuncFactory) HandleResponse

func (f *CallFuncFactory) HandleResponse(elem rpc.BatchElem) error

HandleResponse implements the core.ResponseHandler interface.

func (*CallFuncFactory) Overrides added in v0.6.0

func (f *CallFuncFactory) Overrides(overrides AccountOverrides) *CallFuncFactory

func (*CallFuncFactory) Returns

func (f *CallFuncFactory) Returns(returns ...any) core.Caller

type RPCBlock added in v0.5.0

type RPCBlock struct {
	Hash         common.Hash      `json:"hash"`
	Transactions []RPCTransaction `json:"transactions"`
	UncleHashes  []common.Hash    `json:"uncles"`

	ParentHash  common.Hash      `json:"parentHash"       gencodec:"required"`
	UncleHash   common.Hash      `json:"sha3Uncles"       gencodec:"required"`
	Coinbase    common.Address   `json:"miner"            gencodec:"required"`
	Root        common.Hash      `json:"stateRoot"        gencodec:"required"`
	TxHash      common.Hash      `json:"transactionsRoot" gencodec:"required"`
	ReceiptHash common.Hash      `json:"receiptsRoot"     gencodec:"required"`
	Bloom       types.Bloom      `json:"logsBloom"        gencodec:"required"`
	Difficulty  *big.Int         `json:"difficulty"       gencodec:"required"`
	Number      *big.Int         `json:"number"           gencodec:"required"`
	GasLimit    uint64           `json:"gasLimit"         gencodec:"required"`
	GasUsed     uint64           `json:"gasUsed"          gencodec:"required"`
	Time        uint64           `json:"timestamp"        gencodec:"required"`
	Extra       []byte           `json:"extraData"        gencodec:"required"`
	MixDigest   common.Hash      `json:"mixHash"`
	Nonce       types.BlockNonce `json:"nonce"`
	BaseFee     *big.Int         `json:"baseFeePerGas" rlp:"optional"`
}

func (RPCBlock) MarshalJSON added in v0.5.0

func (r RPCBlock) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*RPCBlock) UnmarshalJSON added in v0.5.0

func (r *RPCBlock) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type RPCHeader added in v0.5.0

type RPCHeader struct {
	Hash              common.Hash   `json:"hash"`
	TransactionHashes []common.Hash `json:"transactions"`
	UncleHashes       []common.Hash `json:"uncles"`

	ParentHash  common.Hash      `json:"parentHash"       gencodec:"required"`
	UncleHash   common.Hash      `json:"sha3Uncles"       gencodec:"required"`
	Coinbase    common.Address   `json:"miner"            gencodec:"required"`
	Root        common.Hash      `json:"stateRoot"        gencodec:"required"`
	TxHash      common.Hash      `json:"transactionsRoot" gencodec:"required"`
	ReceiptHash common.Hash      `json:"receiptsRoot"     gencodec:"required"`
	Bloom       types.Bloom      `json:"logsBloom"        gencodec:"required"`
	Difficulty  *big.Int         `json:"difficulty"       gencodec:"required"`
	Number      *big.Int         `json:"number"           gencodec:"required"`
	GasLimit    uint64           `json:"gasLimit"         gencodec:"required"`
	GasUsed     uint64           `json:"gasUsed"          gencodec:"required"`
	Time        uint64           `json:"timestamp"        gencodec:"required"`
	Extra       []byte           `json:"extraData"        gencodec:"required"`
	MixDigest   common.Hash      `json:"mixHash"`
	Nonce       types.BlockNonce `json:"nonce"`
	BaseFee     *big.Int         `json:"baseFeePerGas" rlp:"optional"`
}

func (RPCHeader) MarshalJSON added in v0.5.0

func (r RPCHeader) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*RPCHeader) UnmarshalJSON added in v0.5.0

func (r *RPCHeader) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type RPCReceipt added in v0.5.0

type RPCReceipt struct {
	TransactionHash   common.Hash     `json:"transactionHash"`
	TransactionIndex  uint64          `json:"transactionIndex"`
	BlockHash         common.Hash     `json:"blockHash"`
	BlockNumber       *big.Int        `json:"blockNumber"`
	From              common.Address  `json:"from"`
	To                *common.Address `json:"to"`
	CumulativeGasUsed uint64          `json:"cumulativeGasUsed"`
	GasUsed           uint64          `json:"gasUsed"`
	ContractAddress   *common.Address `json:"contractAddress"`
	Logs              []*types.Log    `json:"logs"`
	LogsBloom         types.Bloom     `json:"logsBloom"`
	Type              uint64          `json:"type"`
	Status            uint64          `json:"status"` // 1 (success) or 0 (failure)
}

func (RPCReceipt) MarshalJSON added in v0.5.0

func (r RPCReceipt) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*RPCReceipt) UnmarshalJSON added in v0.5.0

func (r *RPCReceipt) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type RPCTransaction added in v0.5.0

type RPCTransaction struct {
	BlockHash        *common.Hash      `json:"blockHash"`
	BlockNumber      *big.Int          `json:"blockNumber"`
	From             common.Address    `json:"from"`
	Gas              uint64            `json:"gas"`
	GasPrice         *big.Int          `json:"gasPrice"`
	GasFeeCap        *big.Int          `json:"maxFeePerGas,omitempty"`
	GasTipCap        *big.Int          `json:"maxPriorityFeePerGas,omitempty"`
	Hash             common.Hash       `json:"hash"`
	Input            []byte            `json:"input"`
	Nonce            uint64            `json:"nonce"`
	To               *common.Address   `json:"to"`
	TransactionIndex *uint64           `json:"transactionIndex"`
	Value            *big.Int          `json:"value"`
	Type             uint64            `json:"type"`
	Accesses         *types.AccessList `json:"accessList,omitempty"`
	ChainID          *big.Int          `json:"chainId,omitempty"`
	V                *big.Int          `json:"v"`
	R                *big.Int          `json:"r"`
	S                *big.Int          `json:"s"`
}

func (RPCTransaction) MarshalJSON added in v0.5.0

func (r RPCTransaction) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*RPCTransaction) UnmarshalJSON added in v0.5.0

func (r *RPCTransaction) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

Jump to

Keyboard shortcuts

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