-
Notifications
You must be signed in to change notification settings - Fork 22
Networks: ChainId
The ChainId
enum provides constants of Chain IDs for blockchains supported by the SDK.
All Chain IDs defined in this namespace are of the standard JS number
type. This is to enable simple interoperability of these values between various codebases.
ChainId can be imported like so:
import { ChainId } from "@synapseprotocol/sdk";
// or, for potentially better tree shaking:
import { ChainId } from "@synapseprotocol/sdk/common/chainid";
import { ChainId } from "@synapseprotocol/sdk";
import { BigNumber, BigNumberish } from "@ethersproject/bignumber";
// Check a normal `number` argument against a known Chain ID.
function example(chainId: number) {
if (chainId === ChainId.BSC) {
console.log(`${chainId} is the Chain ID of the Binance Smart Chain!`);
}
}
// Check a BigNumberish (which could be a whole host of types)
// against a known Chain ID.
function example2(chainId: BigNumberish) {
let paramAsNum = BigNumber.from(chainId).toNumber();
if (paramAsNum === ChainId.FANTOM) {
console.log(`${paramAsNum} is the Chain ID of the Fantom network!`);
}
}
All of the below are standard NodeJS number
s, exported as members of the ChainId
enum. All of these Chain IDs
are supported and useable on the Synapse Protocol.
-
ETH
(Ethereum mainnet)- Value:
1
- Value:
-
OPTIMISM
(Optimism mainnet)- Value:
10
- Value:
-
CRONOS
(Cronos mainnet)- Value:
25
- Value:
-
BSC
(Binance Smart Chain mainnet)- Value:
56
- Value:
-
POLYGON
(Polygon Mainnet)- Value:
137
- Value:
-
FANTOM
(Fantom mainnet)- Value:
250
- Value:
-
BOBA
(Boba mainnet)- Value:
288
- Value:
-
METIS
(Metis Mainnet)- Value:
1088
- Value:
-
MOONBEAM
(Moonbeam mainnet)- Value:
1284
- Value:
-
MOONRIVER
(Moonriver mainnet)- Value:
1285
- Value:
-
ARBITRUM
(Arbitrum mainnet)- Value:
42161
- Value:
-
AVALANCHE
(Avalanche C-Chain mainnet)- Value:
43114
- Value:
-
AURORA
(Aurora mainnet)- Value:
1313161554
- Value:
-
HARMONY
(Harmony mainnet)- Value:
1666600000
- Value:
-
supportedChainIds
- Returns an array of
numbers
corresponding to the chain ids of all networks supported by the Synapse Protocol. - Returns:
-
number[]
- Array which contains the pre-defined chain id enum members
ETH
,OPTIMISM
,CRONOS
,BSC
,POLYGON
,FANTOM
,BOBA
,METIS
,MOONBEAM
,MOONRIVER
,ARBITRUM
,AVALANCHE
,AURORA
, andHARMONY
.
- Array which contains the pre-defined chain id enum members
-
- Returns an array of