client

package
v0.0.0-...-57b907f Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a JSON-RPC Client that supports fallback

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a Client and applies all options

func (*Client) Request

func (c *Client) Request(ctx context.Context, method types.RPCMethod, params ...any) (json.RawMessage, error)

Request calls all Transports in sequence and returns the first successful result

func (*Client) SendETH

func (c *Client) SendETH(ctx context.Context, to common.Address, amount, chainID *big.Int, gasLimit, nonce uint64, maxFeePerGas, maxPriorityFeePerGas *big.Int) (common.Hash, error)

SendETH sends ETH

func (*Client) SendETH1559

func (c *Client) SendETH1559(ctx context.Context, to common.Address,
	amount, maxFeePerGas, maxPriorityFeePerGas, chainID *big.Int, gasLimit, nonce uint64,
	accessList ethTypes.AccessList) (common.Hash, error)

SendETH1559 sends an EIP-1559 transaction

func (*Client) SendRawTransaction

func (c *Client) SendRawTransaction(ctx context.Context, tx *ethTypes.Transaction, out *common.Hash) error

SendRawTransaction sends a raw transaction method: eth_sendRawTransaction

func (*Client) SignMessage

func (c *Client) SignMessage(msg []byte) ([]byte, error)

SignMessage signs a message

func (*Client) SignTypedData

func (c *Client) SignTypedData(typedDataJSON string) ([]byte, error)

SignTypedData signs EIP-712 structured data

type HTTPTransport

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

HTTPTransport struct

func NewHTTPTransport

func NewHTTPTransport(endpoint string) (*HTTPTransport, error)

NewHTTPTransport create a new HTTPTransport instance

func (*HTTPTransport) Request

func (t *HTTPTransport) Request(ctx context.Context, method types.RPCMethod, params ...any) (json.RawMessage, error)

Request implements the Transport interface's Request method

type IPCTransport

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

IPCTransport struct

func NewIPCTransport

func NewIPCTransport(path string) (*IPCTransport, error)

NewIPCTransport create a new IPCTransport instance

func (*IPCTransport) Request

func (t *IPCTransport) Request(ctx context.Context, method types.RPCMethod, params ...any) (json.RawMessage, error)

Request implements the Transport interface's Request method

type Option

type Option func(*config) error

Option config function type

func WithPollingInterval

func WithPollingInterval(d time.Duration) Option

WithPollingInterval sets the polling interval

func WithPrivateKey

func WithPrivateKey(privateKeyHex string) Option

WithPrivateKey sets the private key

func WithRetryCount

func WithRetryCount(count int) Option

WithRetryCount sets the retry count

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the request timeout

func WithTransport

func WithTransport(t ...Transport) Option

WithTransport adds Transport

type Transport

type Transport interface {
	Request(ctx context.Context, method types.RPCMethod, params ...any) (json.RawMessage, error)
}

Transport is a JSON-RPC Client interface

type WebSocketTransport

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

WebSocketTransport struct

func NewWebSocketTransport

func NewWebSocketTransport(endpoint string) (*WebSocketTransport, error)

NewWebSocketTransport create a new WebSocketTransport instance

func (*WebSocketTransport) Request

func (t *WebSocketTransport) Request(ctx context.Context, method types.RPCMethod, params ...any) (json.RawMessage, error)

Request implements the Transport interface's Request method

Jump to

Keyboard shortcuts

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