customethclient

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: GPL-3.0, LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*ethclient.Client
}

Client wraps the ethclient.Client interface to provide extra data types (in header, block body). If you want to use the standardized Ethereum RPC functionality without extra types, use ethclient.Client instead.

Example
package main

import (
	"context"
	"fmt"

	"github.com/ava-labs/coreth/plugin/evm/customtypes"
)

const FujiAPIURI = "https://api.avax-test.network"

func main() {
	ethC, err := Dial(FujiAPIURI + "/ext/bc/C/rpc")
	if err != nil {
		panic(err)
	}
	bc, err := ethC.BlockByNumber(context.Background(), nil)
	if err != nil {
		panic(err)
	}
	extData := customtypes.GetHeaderExtra(bc.Header())
	// Header extra data
	fmt.Printf("Block Gas Cost: %d\n", extData.BlockGasCost)
	fmt.Printf("Extra data hash: %x\n", extData.ExtDataHash)
	fmt.Printf("Extra data gas used: %d\n", extData.ExtDataGasUsed)

	// Block Body extra data
	fmt.Printf("Block Extra Data: %x\n", customtypes.BlockExtData(bc))
	fmt.Printf("Block Version: %d\n", customtypes.BlockVersion(bc))
}

func Dial

func Dial(rawurl string) (*Client, error)

Dial connects a client to the given URL.

func DialContext

func DialContext(ctx context.Context, rawurl string) (*Client, error)

DialContext connects a client to the given URL with context.

func New

func New(c *rpc.Client) *Client

New creates a client that uses the given RPC client.

Jump to

Keyboard shortcuts

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