ethrpc

package
v1.29.7 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: LGPL-3.0, MIT Imports: 25 Imported by: 23

Documentation

Index

Examples

Constants

View Source
const ENSContractAddress = "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"

Variables

View Source
var (
	ErrNotFound                 = ethereum.NotFound
	ErrEmptyResponse            = errors.New("ethrpc: empty response")
	ErrUnsupportedMethodOnChain = errors.New("ethrpc: method is unsupported on this chain")
	ErrRequestFail              = errors.New("ethrpc: request fail")
)
View Source
var Networks = map[uint64]Network{
	1: {
		Name:                "mainnet",
		ChainID:             1,
		NumBlocksToFinality: 20,
	},
	3: {
		Name:                "ropsten",
		ChainID:             3,
		NumBlocksToFinality: 20,
	},
	4: {
		Name:                "rinkeby",
		ChainID:             4,
		NumBlocksToFinality: 20,
	},
	5: {
		Name:                "goerli",
		ChainID:             5,
		NumBlocksToFinality: 20,
	},
	42: {
		Name:                "kovan",
		ChainID:             42,
		NumBlocksToFinality: 20,
	},
	11155111: {
		Name:                "sepolia",
		ChainID:             11155111,
		NumBlocksToFinality: 50,
	},
	137: {
		Name:                "polygon",
		ChainID:             137,
		NumBlocksToFinality: 100,
	},
	80001: {
		Name:                "polygon-mumbai",
		ChainID:             80001,
		NumBlocksToFinality: 100,
	},
	56: {
		Name:                "bsc",
		ChainID:             56,
		NumBlocksToFinality: 50,
	},
	97: {
		Name:                "bsc-testnet",
		ChainID:             97,
		NumBlocksToFinality: 50,
	},
	10: {
		Name:                "optimism",
		ChainID:             10,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
	69: {
		Name:                "optimism-testnet",
		ChainID:             69,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
	42161: {
		Name:                "arbitrum",
		ChainID:             42161,
		NumBlocksToFinality: 50,
	},
	421613: {
		Name:                "arbitrum-testnet",
		ChainID:             421613,
		NumBlocksToFinality: 50,
	},
	42170: {
		Name:                "arbitrum-nova",
		ChainID:             42170,
		NumBlocksToFinality: 50,
	},
	43114: {
		Name:                "avalanche",
		ChainID:             43114,
		NumBlocksToFinality: 50,
	},
	43113: {
		Name:                "avalanche-testnet",
		ChainID:             43113,
		NumBlocksToFinality: 50,
	},
	250: {
		Name:                "fantom",
		ChainID:             250,
		NumBlocksToFinality: 100,
	},
	4002: {
		Name:                "fantom-testnet",
		ChainID:             4002,
		NumBlocksToFinality: 100,
	},
	100: {
		Name:                "gnosis",
		ChainID:             100,
		NumBlocksToFinality: 100,
	},
	1313161554: {
		Name:                "aurora",
		ChainID:             1313161554,
		NumBlocksToFinality: 50,
	},
	1313161556: {
		Name:                "aurora-testnet",
		ChainID:             1313161556,
		NumBlocksToFinality: 50,
	},
	8453: {
		Name:                "base",
		ChainID:             8453,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
	84531: {
		Name:                "base-goerli",
		ChainID:             84531,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
	84532: {
		Name:                "base-sepolia",
		ChainID:             84532,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
	19011: {
		Name:                "homeverse",
		ChainID:             19011,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
	40875: {
		Name:                "homeverse-testnet",
		ChainID:             40875,
		NumBlocksToFinality: 50,
		OptimismChain:       true,
	},
}
View Source
var Pending = big.NewInt(-1)
View Source
var StrictnessLevels = map[uint8]string{
	0: "NONE",
	1: "SEMI",
	2: "STRICT",
}

Functions

func IntoBlock added in v1.22.0

func IntoBlock(raw json.RawMessage, ret **types.Block, strictness StrictnessLevel) error

func IntoHeader added in v1.29.0

func IntoHeader(raw json.RawMessage, ret **types.Header, strictness StrictnessLevel) error

func IntoJSONRawMessage added in v1.22.0

func IntoJSONRawMessage(raw json.RawMessage, ret *json.RawMessage, strictness StrictnessLevel) error

func IntoTransaction added in v1.22.0

func IntoTransaction(raw json.RawMessage, tx **types.Transaction, strictness StrictnessLevel) error

func IntoTransactionWithPending added in v1.22.0

func IntoTransactionWithPending(raw json.RawMessage, tx **types.Transaction, pending *bool, strictness StrictnessLevel) error

func NameHash added in v1.17.8

func NameHash(name string) (hash [32]byte, err error)

NameHash generates a hash from a name that can be used to look up the name in ENS

func Normalize added in v1.17.8

func Normalize(input string) (output string, err error)

Normalize normalizes a name according to the ENS rules

func ResolveEnsAddress added in v1.17.8

func ResolveEnsAddress(ctx context.Context, ens string, provider *Provider) (common.Address, bool, error)

func WaitForTxnReceipt added in v1.3.6

func WaitForTxnReceipt(ctx context.Context, provider *Provider, txHash common.Hash) (*types.Receipt, error)

Types

type BatchCall added in v1.19.0

type BatchCall []*Call
Example
Output:

polygon ID: 137
error at 2: not found

func (*BatchCall) ErrorOrNil added in v1.19.0

func (b *BatchCall) ErrorOrNil() error

func (*BatchCall) MarshalJSON added in v1.19.0

func (b *BatchCall) MarshalJSON() ([]byte, error)

func (*BatchCall) UnmarshalJSON added in v1.19.0

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

type BatchError added in v1.19.0

type BatchError map[int]*Call

func (BatchError) Error added in v1.19.0

func (e BatchError) Error() string

func (BatchError) ErrorMap added in v1.19.0

func (e BatchError) ErrorMap() map[int]error

func (BatchError) Unwrap added in v1.19.0

func (e BatchError) Unwrap() error

type Call added in v1.19.0

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

func NewCall added in v1.19.0

func NewCall(method string, params ...any) Call

func SendTransaction added in v1.19.0

func SendTransaction(tx *types.Transaction) Call

func (*Call) Error added in v1.19.0

func (c *Call) Error() string

func (Call) Strict added in v1.29.0

func (c Call) Strict(strictness StrictnessLevel) Call

func (*Call) Unwrap added in v1.19.0

func (c *Call) Unwrap() error

type CallBuilder added in v1.19.0

type CallBuilder[T any] struct {
	// contains filtered or unexported fields
}

func BalanceAt added in v1.19.0

func BalanceAt(account common.Address, blockNum *big.Int) CallBuilder[*big.Int]

func BlockByHash added in v1.19.0

func BlockByHash(hash common.Hash) CallBuilder[*types.Block]

func BlockByNumber added in v1.19.0

func BlockByNumber(blockNum *big.Int) CallBuilder[*types.Block]

func BlockNumber added in v1.19.0

func BlockNumber() CallBuilder[uint64]

func CallContract added in v1.19.0

func CallContract(msg ethereum.CallMsg, blockNum *big.Int) CallBuilder[[]byte]

func CallContractAtHash added in v1.19.0

func CallContractAtHash(msg ethereum.CallMsg, blockHash common.Hash) CallBuilder[[]byte]

func ChainID added in v1.19.0

func ChainID() CallBuilder[*big.Int]

func CodeAt added in v1.19.0

func CodeAt(account common.Address, blockNum *big.Int) CallBuilder[[]byte]

func ContractQuery added in v1.22.5

func ContractQuery(contractAddress common.Address, inputAbiExpr, outputAbiExpr string, args interface{}) (CallBuilder[[]string], error)

func DebugTraceBlockByHash added in v1.29.1

func DebugTraceBlockByHash(hash common.Hash) CallBuilder[[]*TransactionDebugTrace]

func DebugTraceBlockByNumber added in v1.29.1

func DebugTraceBlockByNumber(blockNum *big.Int) CallBuilder[[]*TransactionDebugTrace]

func DebugTraceTransaction added in v1.29.1

func DebugTraceTransaction(txHash common.Hash) CallBuilder[*CallDebugTrace]

func EstimateGas added in v1.19.0

func EstimateGas(msg ethereum.CallMsg) CallBuilder[uint64]

func FeeHistory added in v1.19.0

func FeeHistory(blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) CallBuilder[*ethereum.FeeHistory]

func FilterLogs added in v1.19.0

func FilterLogs(q ethereum.FilterQuery) CallBuilder[[]types.Log]

func HeaderByHash added in v1.19.0

func HeaderByHash(hash common.Hash) CallBuilder[*types.Header]

func HeaderByNumber added in v1.19.0

func HeaderByNumber(blockNum *big.Int) CallBuilder[*types.Header]

func NetworkID added in v1.19.0

func NetworkID() CallBuilder[*big.Int]

func NewCallBuilder added in v1.19.0

func NewCallBuilder[T any](method string, intoFn IntoFn[T], params ...any) CallBuilder[T]

func NonceAt added in v1.19.0

func NonceAt(account common.Address, blockNum *big.Int) CallBuilder[uint64]

func PeerCount added in v1.19.0

func PeerCount() CallBuilder[uint64]

func PendingBalanceAt added in v1.19.0

func PendingBalanceAt(account common.Address) CallBuilder[*big.Int]

func PendingCallContract added in v1.19.0

func PendingCallContract(msg ethereum.CallMsg) CallBuilder[[]byte]

func PendingCodeAt added in v1.19.0

func PendingCodeAt(account common.Address) CallBuilder[[]byte]

func PendingNonceAt added in v1.19.0

func PendingNonceAt(account common.Address) CallBuilder[uint64]

func PendingStorageAt added in v1.19.0

func PendingStorageAt(account common.Address, key common.Hash) CallBuilder[[]byte]

func PendingTransactionCount added in v1.19.0

func PendingTransactionCount() CallBuilder[uint]

func RawBlockByHash added in v1.22.0

func RawBlockByHash(hash common.Hash) CallBuilder[json.RawMessage]

func RawBlockByNumber added in v1.22.0

func RawBlockByNumber(blockNum *big.Int) CallBuilder[json.RawMessage]

func RawFilterLogs added in v1.22.0

func RawFilterLogs(q ethereum.FilterQuery) CallBuilder[json.RawMessage]

func SendRawTransaction added in v1.19.0

func SendRawTransaction(signedTxHex string) CallBuilder[common.Hash]

func StorageAt added in v1.19.0

func StorageAt(account common.Address, key common.Hash, blockNum *big.Int) CallBuilder[[]byte]

func SuggestGasPrice added in v1.19.0

func SuggestGasPrice() CallBuilder[*big.Int]

func SuggestGasTipCap added in v1.19.0

func SuggestGasTipCap() CallBuilder[*big.Int]

func SyncProgress added in v1.19.0

func SyncProgress() CallBuilder[*ethereum.SyncProgress]

func TransactionCount added in v1.19.0

func TransactionCount(blockHash common.Hash) CallBuilder[uint]

func TransactionInBlock added in v1.19.0

func TransactionInBlock(blockHash common.Hash, index uint) CallBuilder[*types.Transaction]

func TransactionReceipt added in v1.19.0

func TransactionReceipt(txHash common.Hash) CallBuilder[*types.Receipt]

func TransactionSender added in v1.19.0

func TransactionSender(tx *types.Transaction, block common.Hash, index uint) CallBuilder[common.Address]

func (CallBuilder[T]) Into added in v1.19.0

func (b CallBuilder[T]) Into(ret *T) Call

func (CallBuilder[T]) Strict added in v1.29.0

func (b CallBuilder[T]) Strict(strictness StrictnessLevel) CallBuilder[T]

type CallBuilder2 added in v1.19.0

type CallBuilder2[T1, T2 any] struct {
	// contains filtered or unexported fields
}

func TransactionByHash added in v1.19.0

func TransactionByHash(hash common.Hash) CallBuilder2[*types.Transaction, bool]

func (CallBuilder2[T1, T2]) Into added in v1.19.0

func (b CallBuilder2[T1, T2]) Into(ret1 *T1, ret2 *T2) Call

func (CallBuilder2[T1, T2]) Strict added in v1.29.0

func (b CallBuilder2[T1, T2]) Strict(strictness StrictnessLevel) CallBuilder2[T1, T2]

type CallDebugTrace added in v1.29.1

type CallDebugTrace struct {
	Type         string            `json:"type"`
	From         common.Address    `json:"from"`
	To           common.Address    `json:"to"`
	Value        *hexutil.Big      `json:"value"`
	Gas          *hexutil.Big      `json:"gas"`
	GasUsed      *hexutil.Big      `json:"gasUsed"`
	Input        hexutil.Bytes     `json:"input"`
	Output       hexutil.Bytes     `json:"output"`
	Error        string            `json:"error"`
	RevertReason string            `json:"revertReason"`
	Calls        []*CallDebugTrace `json:"calls"`
}

type DebugInterface added in v1.29.1

type DebugInterface interface {
	DebugTraceBlockByNumber(ctx context.Context, blockNum *big.Int) ([]*TransactionDebugTrace, error)
	DebugTraceBlockByHash(ctx context.Context, blockHash common.Hash) ([]*TransactionDebugTrace, error)
	DebugTraceTransaction(ctx context.Context, txHash common.Hash) (*CallDebugTrace, error)
}

DebugInterface provides additional debugging methods

type DebugTracer added in v1.29.1

type DebugTracer string
const (
	DebugTracerCallTracer     DebugTracer = "callTracer"
	DebugTracerPreStateTracer DebugTracer = "prestateTracer"
)

type Interface added in v1.19.0

type Interface interface {
	// ..
	Do(ctx context.Context, calls ...Call) ([]byte, error)

	// ChainID = eth_chainId
	ChainID(ctx context.Context) (*big.Int, error)

	// BlockByHash = eth_getBlockByHash (true)
	BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

	// BlockByNumber = eth_getBlockByNumber (true)
	BlockByNumber(ctx context.Context, blockNum *big.Int) (*types.Block, error)

	// BlockNumber = eth_blockNumber
	BlockNumber(ctx context.Context) (uint64, error)

	// BlocksByNumbers = batch of eth_getBlockByNumber
	BlocksByNumbers(ctx context.Context, blockNumbers []*big.Int) ([]*types.Block, error)

	// BlocksByNumberRange = batch of eth_getBlockByNumber
	BlocksByNumberRange(ctx context.Context, fromBlockNumber, toBlockNumber *big.Int) ([]*types.Block, error)

	// PeerCount = net_peerCount
	PeerCount(ctx context.Context) (uint64, error)

	// HeaderByHash = eth_getBlockByHash (false)
	HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

	// HeaderByNumber = eth_getBlockByHash (true)
	HeaderByNumber(ctx context.Context, blockNum *big.Int) (*types.Header, error)

	// HeadersByNumbers = batch of eth_getHeaderByNumber
	HeadersByNumbers(ctx context.Context, blockNumbers []*big.Int) ([]*types.Header, error)

	// HeadersByNumberRange = batch of eth_getHeaderByNumber
	HeadersByNumberRange(ctx context.Context, fromBlockNumber, toBlockNumber *big.Int) ([]*types.Header, error)

	// TransactionByHash = eth_getTransactionByHash
	TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, pending bool, err error)

	// TransactionSender is a wrapper for eth_getTransactionByBlockHashAndIndex
	TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)

	// TransactionCount = eth_getBlockTransactionCountByHash
	TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)

	// TransactionInBlock = eth_getTransactionByBlockHashAndIndex
	TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)

	// TransactionReceipt = eth_getTransactionReceipt
	TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

	// SyncProgress = eth_syncing
	SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)

	// NetworkID = net_version
	NetworkID(ctx context.Context) (*big.Int, error)

	// BalanceAt = eth_getBalance
	BalanceAt(ctx context.Context, account common.Address, blockNum *big.Int) (*big.Int, error)

	// StorageAt = eth_getStorageAt
	StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNum *big.Int) ([]byte, error)

	// CodeAt = eth_getCode
	CodeAt(ctx context.Context, account common.Address, blockNum *big.Int) ([]byte, error)

	// NonceAt = eth_getTransactionCount
	NonceAt(ctx context.Context, account common.Address, blockNum *big.Int) (uint64, error)

	// FilterLogs = eth_getLogs
	FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)

	// PendingBalanceAt = eth_getBalance ("pending")
	PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)

	// PendingStorageAt = eth_getStorageAt ("pending")
	PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)

	// PendingCodeAt = eth_getCode ("pending")
	PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

	// PendingNonceAt = eth_getTransactionCount ("pending")
	PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

	// PendingTransactionCount = eth_getBlockTransactionCountByNumber ("pending")
	PendingTransactionCount(ctx context.Context) (uint, error)

	// CallContract = eth_call (blockNumber)
	CallContract(ctx context.Context, msg ethereum.CallMsg, blockNum *big.Int) ([]byte, error)

	// CallContractAtHash = eth_call (blockHash)
	CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)

	// PendingCallContract = eth_call ("pending")
	PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)

	// SuggestGasPrice = eth_gasPrice
	SuggestGasPrice(ctx context.Context) (*big.Int, error)

	// SuggestGasTipCap = eth_maxPriorityFeePerGas
	SuggestGasTipCap(ctx context.Context) (*big.Int, error)

	// FeeHistory = eth_feeHistory
	FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)

	// EstimateGas = eth_estimateGas
	EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

	// SendTransaction = eth_sendRawTransaction
	SendTransaction(ctx context.Context, tx *types.Transaction) error

	// SendRawTransaction = eth_sendRawTransaction
	SendRawTransaction(ctx context.Context, signedTxHex string) (common.Hash, error)

	// ..
	IsStreamingEnabled() bool

	// ..
	SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

	// ..
	SubscribeNewHeads(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

	// ..
	CloseStreamConns()
}

TODO: rename to either Provider, and rename the current Provider to Client

type IntoFn added in v1.19.0

type IntoFn[T any] func(raw json.RawMessage, ret *T, strictness StrictnessLevel) error

type Network added in v1.17.0

type Network struct {
	Name                string
	ChainID             uint64
	NumBlocksToFinality int
	OptimismChain       bool
}

type Option added in v1.19.0

type Option func(*Provider)

func WithBreaker added in v1.19.0

func WithBreaker(br breaker.Breaker) Option

func WithHTTPClient added in v1.19.0

func WithHTTPClient(c httpClient) Option

func WithJWTAuthorization added in v1.22.3

func WithJWTAuthorization(jwtToken string) Option

func WithLogger added in v1.19.0

func WithLogger(log logger.Logger) Option

func WithSemiValidation added in v1.29.0

func WithSemiValidation() Option

func WithStreaming added in v1.24.0

func WithStreaming(nodeWebsocketURL string) Option

func WithStrictValidation added in v1.29.0

func WithStrictValidation() Option

func WithStrictness added in v1.29.0

func WithStrictness(strictness StrictnessLevel) Option

0: disabled, no validation (default) 1: semi-strict transactions – validates only transaction V, R, S values 2: strict block and transactions – validates block hash, sender address, and transaction signatures

type Provider

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

func NewProvider

func NewProvider(nodeURL string, options ...Option) (*Provider, error)

func (*Provider) BalanceAt added in v1.19.0

func (p *Provider) BalanceAt(ctx context.Context, account common.Address, blockNum *big.Int) (*big.Int, error)

func (*Provider) BlockByHash added in v1.1.7

func (p *Provider) BlockByHash(ctx context.Context, hash common.Hash) (*types.Block, error)

func (*Provider) BlockByNumber

func (p *Provider) BlockByNumber(ctx context.Context, blockNum *big.Int) (*types.Block, error)

func (*Provider) BlockNumber added in v1.19.0

func (p *Provider) BlockNumber(ctx context.Context) (uint64, error)

func (*Provider) BlocksByNumberRange added in v1.29.6

func (p *Provider) BlocksByNumberRange(ctx context.Context, fromBlockNumber, toBlockNumber *big.Int) ([]*types.Block, error)

func (*Provider) BlocksByNumbers added in v1.29.6

func (p *Provider) BlocksByNumbers(ctx context.Context, blockNumbers []*big.Int) ([]*types.Block, error)

func (*Provider) CallContract added in v1.19.0

func (p *Provider) CallContract(ctx context.Context, msg ethereum.CallMsg, blockNum *big.Int) ([]byte, error)

func (*Provider) CallContractAtHash added in v1.19.0

func (p *Provider) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error)

func (*Provider) ChainID

func (p *Provider) ChainID(ctx context.Context) (*big.Int, error)

func (*Provider) CloseStreamConns added in v1.27.9

func (p *Provider) CloseStreamConns()

func (*Provider) CodeAt added in v1.19.0

func (p *Provider) CodeAt(ctx context.Context, account common.Address, blockNum *big.Int) ([]byte, error)

func (*Provider) ContractQuery added in v1.19.0

func (p *Provider) ContractQuery(ctx context.Context, contractAddress string, inputAbiExpr, outputAbiExpr string, args interface{}) ([]string, error)

ie, ContractQuery(context.Background(), "0xabcdef..", "balanceOf(uint256)", "uint256", []string{"1"}) TODO: add common methods in helpers util, and also use generics to convert the return for us

func (*Provider) DebugTraceBlockByHash added in v1.29.1

func (p *Provider) DebugTraceBlockByHash(ctx context.Context, blockHash common.Hash) ([]*TransactionDebugTrace, error)

func (*Provider) DebugTraceBlockByNumber added in v1.29.1

func (p *Provider) DebugTraceBlockByNumber(ctx context.Context, blockNum *big.Int) ([]*TransactionDebugTrace, error)

func (*Provider) DebugTraceTransaction added in v1.29.1

func (p *Provider) DebugTraceTransaction(ctx context.Context, txHash common.Hash) (*CallDebugTrace, error)

func (*Provider) Do added in v1.19.0

func (p *Provider) Do(ctx context.Context, calls ...Call) ([]byte, error)

func (*Provider) EstimateGas added in v1.19.0

func (p *Provider) EstimateGas(ctx context.Context, msg ethereum.CallMsg) (uint64, error)

func (*Provider) FeeHistory added in v1.19.0

func (p *Provider) FeeHistory(ctx context.Context, blockCount uint64, lastBlock *big.Int, rewardPercentiles []float64) (*ethereum.FeeHistory, error)

func (*Provider) FilterLogs added in v1.19.0

func (p *Provider) FilterLogs(ctx context.Context, q ethereum.FilterQuery) ([]types.Log, error)

func (*Provider) HeaderByHash added in v1.19.0

func (p *Provider) HeaderByHash(ctx context.Context, hash common.Hash) (*types.Header, error)

func (*Provider) HeaderByNumber added in v1.19.0

func (p *Provider) HeaderByNumber(ctx context.Context, blockNum *big.Int) (*types.Header, error)

func (*Provider) HeadersByNumberRange added in v1.25.0

func (p *Provider) HeadersByNumberRange(ctx context.Context, fromBlockNumber, toBlockNumber *big.Int) ([]*types.Header, error)

func (*Provider) HeadersByNumbers added in v1.25.0

func (p *Provider) HeadersByNumbers(ctx context.Context, blockNumbers []*big.Int) ([]*types.Header, error)

func (*Provider) IsStreamingEnabled added in v1.24.0

func (p *Provider) IsStreamingEnabled() bool

...

func (*Provider) NetworkID added in v1.19.0

func (p *Provider) NetworkID(ctx context.Context) (*big.Int, error)

func (*Provider) NonceAt added in v1.19.0

func (p *Provider) NonceAt(ctx context.Context, account common.Address, blockNum *big.Int) (uint64, error)

func (*Provider) PeerCount added in v1.19.0

func (p *Provider) PeerCount(ctx context.Context) (uint64, error)

func (*Provider) PendingBalanceAt added in v1.19.0

func (p *Provider) PendingBalanceAt(ctx context.Context, account common.Address) (*big.Int, error)

func (*Provider) PendingCallContract added in v1.19.0

func (p *Provider) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error)

func (*Provider) PendingCodeAt added in v1.19.0

func (p *Provider) PendingCodeAt(ctx context.Context, account common.Address) ([]byte, error)

func (*Provider) PendingNonceAt added in v1.19.0

func (p *Provider) PendingNonceAt(ctx context.Context, account common.Address) (uint64, error)

func (*Provider) PendingStorageAt added in v1.19.0

func (p *Provider) PendingStorageAt(ctx context.Context, account common.Address, key common.Hash) ([]byte, error)

func (*Provider) PendingTransactionCount added in v1.19.0

func (p *Provider) PendingTransactionCount(ctx context.Context) (uint, error)

func (*Provider) RawBlockByHash added in v1.22.0

func (p *Provider) RawBlockByHash(ctx context.Context, hash common.Hash) (json.RawMessage, error)

func (*Provider) RawBlockByNumber added in v1.22.0

func (p *Provider) RawBlockByNumber(ctx context.Context, blockNum *big.Int) (json.RawMessage, error)

func (*Provider) RawFilterLogs added in v1.22.0

func (p *Provider) RawFilterLogs(ctx context.Context, q ethereum.FilterQuery) (json.RawMessage, error)

func (*Provider) SendRawTransaction added in v1.3.6

func (p *Provider) SendRawTransaction(ctx context.Context, signedTxHex string) (common.Hash, error)

func (*Provider) SendTransaction added in v1.19.0

func (p *Provider) SendTransaction(ctx context.Context, tx *types.Transaction) error

func (*Provider) SetHTTPClient added in v1.19.0

func (s *Provider) SetHTTPClient(httpClient *http.Client)

func (*Provider) StorageAt added in v1.19.0

func (p *Provider) StorageAt(ctx context.Context, account common.Address, key common.Hash, blockNum *big.Int) ([]byte, error)

func (*Provider) StrictnessLevel added in v1.29.0

func (p *Provider) StrictnessLevel() StrictnessLevel

func (*Provider) SubscribeFilterLogs added in v1.19.0

func (p *Provider) SubscribeFilterLogs(ctx context.Context, query ethereum.FilterQuery, ch chan<- types.Log) (ethereum.Subscription, error)

SubscribeFilterLogs is stubbed below so we can adhere to the bind.ContractBackend interface. NOTE: the p.nodeWSURL is setup with a wss:// prefix, which tells the gethRPC to use a websocket connection.

The connection will be closed and unsubscribed when the context is cancelled.

func (*Provider) SubscribeNewHeads added in v1.24.0

func (p *Provider) SubscribeNewHeads(ctx context.Context, ch chan<- *types.Header) (ethereum.Subscription, error)

SubscribeNewHeads listens for new blocks via websocket client. NOTE: the p.nodeWSURL is setup with a wss:// prefix, which tells the gethRPC to use a websocket connection.

The connection will be closed and unsubscribed when the context is cancelled.

func (*Provider) SuggestGasPrice added in v1.19.0

func (p *Provider) SuggestGasPrice(ctx context.Context) (*big.Int, error)

func (*Provider) SuggestGasTipCap added in v1.19.0

func (p *Provider) SuggestGasTipCap(ctx context.Context) (*big.Int, error)

func (*Provider) SyncProgress added in v1.19.0

func (p *Provider) SyncProgress(ctx context.Context) (*ethereum.SyncProgress, error)

func (*Provider) TransactionByHash added in v1.19.0

func (p *Provider) TransactionByHash(ctx context.Context, hash common.Hash) (tx *types.Transaction, pending bool, err error)

func (*Provider) TransactionCount added in v1.19.0

func (p *Provider) TransactionCount(ctx context.Context, blockHash common.Hash) (uint, error)

func (*Provider) TransactionInBlock added in v1.19.0

func (p *Provider) TransactionInBlock(ctx context.Context, blockHash common.Hash, index uint) (*types.Transaction, error)

func (*Provider) TransactionReceipt added in v1.19.0

func (p *Provider) TransactionReceipt(ctx context.Context, txHash common.Hash) (*types.Receipt, error)

func (*Provider) TransactionSender added in v1.19.0

func (p *Provider) TransactionSender(ctx context.Context, tx *types.Transaction, block common.Hash, index uint) (common.Address, error)

type RawInterface added in v1.22.0

type RawInterface interface {
	Interface
	RawBlockByHash(ctx context.Context, hash common.Hash) (json.RawMessage, error)
	RawBlockByNumber(ctx context.Context, blockNum *big.Int) (json.RawMessage, error)
	RawFilterLogs(ctx context.Context, q ethereum.FilterQuery) (json.RawMessage, error)
}

RawInterface also returns the bytes of the response body payload

type StreamCloser added in v1.27.9

type StreamCloser interface {
	Close()
}

type StreamUnsubscriber added in v1.27.9

type StreamUnsubscriber interface {
	Unsubscribe()
}

type StrictnessLevel added in v1.29.0

type StrictnessLevel uint8

StrictnessLevel is the level of strictness for validation when unmarshalling blocks and transactions from RPC responses from a node.

const (
	StrictnessLevel_None   StrictnessLevel = iota // 0: disabled, no validation on blocks or transactions (default)
	StrictnessLevel_Semi                          // 1: semi-strict transactions – validates only transaction V, R, S values
	StrictnessLevel_Strict                        // 2: strict block and transactions – validates block hash, sender address, and transaction signatures
)

func (StrictnessLevel) String added in v1.29.0

func (x StrictnessLevel) String() string

type StrictnessLevelGetter added in v1.29.0

type StrictnessLevelGetter interface {
	StrictnessLevel() StrictnessLevel
}

type TransactionDebugTrace added in v1.29.1

type TransactionDebugTrace struct {
	TxHash common.Hash    `json:"txHash"`
	Result CallDebugTrace `json:"result"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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