ethproviders

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: LGPL-3.0, MIT Imports: 4 Imported by: 0 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainInfo

type ChainInfo struct {
	// ID is the globally unique chain ID. See https://chainlist.wtf
	ID uint64 `json:"id"`

	// Name is the canonical name of the chain. See https://docs.sequence.xyz
	Name string `json:"name"`

	// Testnet is true if the chain is a testnet.
	Testnet bool `json:"testnet"`
}

type Config

type Config map[string]NetworkConfig

func (Config) GetByID

func (n Config) GetByID(id uint64) (NetworkConfig, bool)

func (Config) GetByName

func (n Config) GetByName(name string) (NetworkConfig, bool)

type NetworkConfig

type NetworkConfig struct {
	// ID is the globally unique chain ID. See https://chainlist.wtf
	ID uint64 `toml:"id" json:"id"`

	// URL is the URL for the blockchain node JSON-RPC endpoint
	URL string `toml:"url" json:"url"`

	// WSEnabled marks the chain to support websocket connections.
	// NOTE: you may leave `WSURL` empty and it will use the `URL`
	// of the node as the WSURL by default. Or you can set `WSURL` to
	// another URL for websocket connections
	WSEnabled bool `toml:"ws_enabled" json:"wsEnabled"`

	// WSURL is the URL for the websocket. You must also set `WSEnabled`
	// to `true`
	WSURL string `toml:"ws_url" json:"wsUrl"`

	// Testnet marks the chain as a testnet.
	Testnet bool `toml:"testnet" json:"testnet"`

	// Disabled marks the chain as disabled, and will not be included
	// in the list of providers at runtime.
	Disabled bool `toml:"disabled" json:"disabled"`
}

type Providers

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

func NewProviders

func NewProviders(cfg Config, opts ...ethrpc.Option) (*Providers, error)

func (*Providers) ChainList

func (p *Providers) ChainList() []ChainInfo

func (*Providers) FindChain

func (p *Providers) FindChain(chainHandle string, optSkipTestnets ...bool) (uint64, ChainInfo, error)

func (*Providers) Get

func (p *Providers) Get(chainHandle string) *ethrpc.Provider

Get is a helper method which will allow you to fetch the provider for a chain by either the chain canonical name, or by the chain canonical id. This works because at the time of configuring the providers list in `NewProviders` we assign the name and string-id to the byName mapping.

func (*Providers) GetByChainID

func (p *Providers) GetByChainID(chainID uint64) *ethrpc.Provider

func (*Providers) GetByChainName

func (p *Providers) GetByChainName(chainName string) *ethrpc.Provider

func (*Providers) MainnetChainIDs added in v1.33.0

func (p *Providers) MainnetChainIDs() []uint64

func (*Providers) MainnetChainList added in v1.33.0

func (p *Providers) MainnetChainList() []ChainInfo

func (*Providers) MainnetStringChainIDs added in v1.33.0

func (p *Providers) MainnetStringChainIDs() []string

func (*Providers) ProviderMap

func (p *Providers) ProviderMap() map[uint64]*ethrpc.Provider

func (*Providers) TestnetChainIDs added in v1.33.0

func (p *Providers) TestnetChainIDs() []uint64

func (*Providers) TestnetChainList added in v1.33.0

func (p *Providers) TestnetChainList() []ChainInfo

func (*Providers) TestnetStringChainIDs added in v1.33.0

func (p *Providers) TestnetStringChainIDs() []string

Jump to

Keyboard shortcuts

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