ethrpc

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(service Service) http.Handler

Types

type Address

type Address [20]byte

func (*Address) MarshalJSON

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

func (*Address) UnmarshalJSON

func (b *Address) UnmarshalJSON(c []byte) error

type BlockData

type BlockData struct {
	Number           Number
	Hash             Bytes32
	ParentHash       Bytes32
	Nonce            []byte
	SHA3Uncles       Bytes32
	LogsBloom        []byte
	TransactionsRoot Bytes32
	StateRoot        Bytes32
	ReceiptsRoot     Bytes32
	Miner            Address
	Difficulty       Number
	TotalDifficulty  Number
	ExtraData        []byte
	Size             Number
	GasLimit         Number
	GasUsed          Number
	GasTimestamp     Number
	Transactions     []json.RawMessage
	Uncles           []Bytes32
}

func (*BlockData) Copy

func (v *BlockData) Copy() *BlockData

Copy returns a copy of the BlockData.

func (*BlockData) Equal

func (v *BlockData) Equal(u *BlockData) bool

EqualBlockData returns true if V is equal to U.

func (*BlockData) MarshalJSON

func (v *BlockData) MarshalJSON() ([]byte, error)

MarshalBinary marshals the BlockData to JSON.

func (*BlockData) UnmarshalJSON

func (v *BlockData) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals the BlockData from JSON.

type Bytes

type Bytes []byte

func (Bytes) MarshalJSON

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

func (*Bytes) UnmarshalJSON

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

type Bytes32

type Bytes32 [32]byte

func (*Bytes32) MarshalJSON

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

func (*Bytes32) UnmarshalJSON

func (b *Bytes32) UnmarshalJSON(c []byte) error

type JSONRPCClient

type JSONRPCClient struct {
	Client   jsonrpc.HTTPClient
	Endpoint string
}

func (*JSONRPCClient) AccTypedData

func (*JSONRPCClient) EthBlockNumber

func (c *JSONRPCClient) EthBlockNumber(ctx context.Context) (*Number, error)

func (*JSONRPCClient) EthChainId

func (c *JSONRPCClient) EthChainId(ctx context.Context) (*Number, error)

func (*JSONRPCClient) EthGasPrice

func (c *JSONRPCClient) EthGasPrice(ctx context.Context) (*Number, error)

func (*JSONRPCClient) EthGetBalance

func (c *JSONRPCClient) EthGetBalance(ctx context.Context, addr Address, block string) (*Number, error)

func (*JSONRPCClient) EthGetBlockByNumber

func (c *JSONRPCClient) EthGetBlockByNumber(ctx context.Context, block string, expand bool) (*BlockData, error)

type JSONRPCHandler

type JSONRPCHandler struct {
	Service Service
}

func (*JSONRPCHandler) ServeJSONRPC

func (h *JSONRPCHandler) ServeJSONRPC(ctx context.Context, method string, params json.RawMessage) (result any, err error)

type Number

type Number big.Int

func NewNumber

func NewNumber(v int64) *Number

func (*Number) Equal

func (n *Number) Equal(m *Number) bool

func (*Number) Int

func (n *Number) Int() *big.Int

func (*Number) MarshalJSON

func (n *Number) MarshalJSON() ([]byte, error)

func (*Number) UnmarshalJSON

func (n *Number) UnmarshalJSON(c []byte) error

type Service

type Service interface {
	EthChainId(ctx context.Context) (*Number, error)
	EthBlockNumber(ctx context.Context) (*Number, error)
	EthGasPrice(ctx context.Context) (*Number, error)
	EthGetBalance(ctx context.Context, addr Address, block string) (*Number, error)
	EthGetBlockByNumber(ctx context.Context, block string, expand bool) (*BlockData, error)

	AccTypedData(context.Context, *protocol.Transaction, protocol.Signature) (*encoding.EIP712Call, error)
}

func NewClient

func NewClient(endpoint string) Service

Jump to

Keyboard shortcuts

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