chain_selectors

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 3 Imported by: 29

README

Chain Selectors

CCIP uses its own set of chain selectors represented by uint64 to identify blockchains. This repository contains a mapping between the custom chain identifiers (chainSelectorId) and the chain identifiers used by the blockchains themselves (chainId).

Please refer to the official documentation to learn more about supported networks and their selectors.

Installation

go get github.com/smartcontractkit/chain-selectors

Usage
import (
    chainselectors "github.com/smartcontractkit/chain-selectors"
)

func main() {
    // Getting selector based on ChainId
    selector, err := chainselectors.SelectorFromChainId(420)

    // Getting ChainId based on ChainSelector
    chainId, err := chainselectors.ChainIdFromSelector(2664363617261496610)

    // Accessing mapping directly
    lookupChainId := uint64(1337)
    if chainSelector, exists := chainselectors.EvmChainIdToChainSelector()[lookupChainId]; exists {
        fmt.Println("Found chain selector for chain", lookupChainId, ":", chainSelector)
    }
}
Contributing

Any new chains and selectors should be always added to selectors.yml and client libraries should load details from this file. This ensures that all client libraries are in sync and use the same mapping.

If you need a support for a new language, please open a PR with the following changes:

  • Library codebase is in a separate directory
  • Library uses selectors.yml as a source of truth
  • Proper Github workflow is present to make sure code compiles and tests pass

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChainIdFromSelector

func ChainIdFromSelector(chainSelectorId uint64) (uint64, error)

func EvmChainIdToChainSelector

func EvmChainIdToChainSelector() map[uint64]uint64

func SelectorFromChainId

func SelectorFromChainId(chainId uint64) (uint64, error)

func TestChainIds added in v1.0.2

func TestChainIds() []uint64

Types

This section is empty.

Jump to

Keyboard shortcuts

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