Table of contents

Chain Functions

Chain Functions

toEnvironmentName

toEnvironmentName(chainNameOrId): SpaceportChainType

Helper function to safely convert a chain name from utils/chain to a valid environment name

Parameters

NameType
chainNameOrIdstring | number

Returns

SpaceportChainType

getChainId

getChainId(chain): number

Get the numeric chain ID from a SpaceportChainType name

Parameters

NameTypeDescription
chainnumber | SpaceportChainTypeChain name

Returns

number

Chain ID as a number

getChainName

getChainName(chainId): string

Get the chain name from a chain ID

Parameters

NameTypeDescription
chainIdnumberChain ID

Returns

string

Chain name

createChainConfig

createChainConfig(chainName): Object

Create a chain configuration for the given environment

Parameters

NameTypeDescription
chainNameSpaceportChainTypeChain name

Returns

Object

Chain configuration

NameType
idnumber
namestring
networkstring
nativeCurrency{ name: string ; symbol: string ; decimals: number }
nativeCurrency.namestring
nativeCurrency.symbolstring
nativeCurrency.decimalsnumber
rpcUrls{ default: { http: string[] } }
rpcUrls.default{ http: string[] }
rpcUrls.default.httpstring[]