chain

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package chain contains tools to obtain metadata for Ethereum chains.

Index

Constants

View Source
const (
	ChainIdEthereumMainnet = 1
	ChainIdHolesky         = 17000
	ChainIdSepolia         = 11155111
)

well-known ChainId

Variables

View Source
var (
	EthereumMainnet func() *Chain
	Holesky         func() *Chain
	Sepolia         func() *Chain
)

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Url string `json:"url"`
}

type Chain

type Chain struct {
	ChainMini
	Chain     string     `json:"chain"`
	Ens       Ens        `json:"ens,omitempty"`
	Explorers []Explorer `json:"explorers,omitempty"`
	Features  []Feature  `json:"features,omitempty"`
	Icon      string     `json:"icon,omitempty"`
	Parent    Parent     `json:"parent,omitempty"`
	Slip44    uint64     `json:"slip44,omitempty"`
	Status    string     `json:"status,omitempty"`
}

func ChainById

func ChainById(chainId uint64) (*Chain, error)

ChainById returns Chain by 'chainId'.

Chains data ('chains.json' file) are stored in current directory.

func Chains

func Chains() ([]Chain, error)

Chains returns slice of Chain.

Chains data are loaded from 'chains.json' file in current directory (if it does not exist, it is downloaded from 'https://chainid.network/chains.json'). To renew 'chains.json' file, remove it.

func ChainsDir added in v0.2.0

func ChainsDir(dir string) ([]Chain, error)

ChainsDir returns slice of Chain.

Chains data are loaded from 'chains.json' file in 'dir' directory (if it does not exist, it is downloaded from 'https://chainid.network/chains.json'). To renew 'chains.json' file, remove it.

type ChainMini

type ChainMini struct {
	ChainId        uint64   `json:"chainId"`
	Faucets        []string `json:"faucets"`
	InfoURL        string   `json:"infoURL"`
	Name           string   `json:"name"`
	NativeCurrency Currency `json:"nativeCurrency"`
	NetworkId      uint64   `json:"networkId"`
	Rpc            []string `json:"rpc"`
	ShortName      string   `json:"shortName"`
}

func ChainMiniById

func ChainMiniById(chainId uint64) (*ChainMini, error)

ChainMiniById returns ChainMini by 'chainId'.

ChainsMini data ('chains_mini.json' file) are stored in current directory.

func ChainsMini

func ChainsMini() ([]ChainMini, error)

ChainsMini returns slice of ChainMini.

ChainsMini data are loaded from 'chains_mini.json' file in current directory (if it does not exist, it is downloaded from 'https://chainid.network/chains_mini.json'). To renew 'chains_mini.json' file, remove it.

func ChainsMiniDir added in v0.2.0

func ChainsMiniDir(dir string) ([]ChainMini, error)

ChainsMiniDir returns slice of ChainMini.

ChainsMini data are loaded from 'chains_mini.json' file in 'dir' directory (if it does not exist, it is downloaded from 'https://chainid.network/chains_mini.json'). To renew 'chains_mini.json' file, remove it.

type Currency

type Currency struct {
	Decimals uint64 `json:"decimals"`
	Name     string `json:"name"`
	Symbol   string `json:"symbol"`
}

type Ens

type Ens struct {
	Registry string `json:"registry"`
}

Ethereum Name Service

type Explorer

type Explorer struct {
	Icon     string `json:"icon,omitempty"`
	Name     string `json:"name"`
	Standard string `json:"standard"`
	Url      string `json:"url"`
}

type Feature

type Feature struct {
	Name string `json:"name"`
}

type Parent

type Parent struct {
	Bridges []Bridge `json:"bridges,omitempty"`
	Chain   string   `json:"chain"`
	Type    string   `json:"type"`
}

Jump to

Keyboard shortcuts

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