Networks: ChainId
The ChainId namespace provides constants of Chain IDs for blockchains supported by the SDK.
All Chain IDs defined in this namespace are exported as the standard JS number type. This is to enable simple interoperability of these values between various codebases.

Import

The ChainId namespace can be imported like so:
1
import { ChainId } from "@synapseprotocol/sdk";
2
3
// or, for potentially better tree shaking:
4
import { ChainId } from "@synapseprotocol/sdk/common";
Copied!

Example Usage

1
import { ChainId } from "@synapseprotocol/sdk";
2
import { BigNumberish } from "@ethersproject/bignumber";
3
4
// Check a normal `number` argument against a known Chain ID.
5
function example(chainId: number) {
6
if (chainId === ChainId.BSC) {
7
console.log(`${chainId} is the Chain ID of the Binance Smart Chain!`);
8
}
9
}
10
11
// Check a BigNumberish (which could be a whole host of types)
12
// against a known Chain ID.
13
function example2(chainId: BigNumberish) {
14
let paramAsNum = ChainId.asNumber(chainId);
15
16
if (paramAsNum === ChainId.FANTOM) {
17
console.log(`${paramAsNum} is the Chain ID of the Fantom network!`);
18
}
19
}
Copied!

Currently Supported Chain IDs

All of the below are standard NodeJS numbers, exported as constants from the ChainId namespace. All of these Chain IDs are supported and useable on the Synapse Protocol.
  • ETH (Ethereum mainnet)
    • Value: 1
  • OPTIMISM (Optimism mainnet)
    • Value: 10
  • BSC (Binance Smart Chain mainnet)
    • Value: 56
  • POLYGON (Polygon Mainnet)
    • Value: 137
  • FANTOM (Fantom mainnet)
    • Value: 250
  • BOBA (Boba mainnet)
    • Value: 288
  • MOONBEAM (Moonbeam mainnet)
    • Value: 1284
  • MOONRIVER (Moonriver mainnet)
    • Value: 1285
  • ARBITRUM (Arbitrum mainnet)
    • Value: 42161
  • AVALANCHE (Avalanche C-Chain mainnet)
    • Value: 43114
  • AURORA (Aurora mainnet)
    • Value: 1313161554
  • HARMONY (Harmony mainnet)
    • Value: 1666600000

Functions

  • asBigNumber
    • Converts the passed BigNumberish into a BigNumber.
    • Params:
      • n: BigNumberish
    • Returns:
      • BigNumber
      • n casted into a BigNumber instance.
  • asBigNumber
    • Converts the passed BigNumberish into a number.
    • Params:
      • n: BigNumberish
    • Returns:
      • number
      • n returned as a standard NodeJS number.
  • 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 constants ETH, OPTIMISM, BSC, POLYGON, FANTOM, BOBA, MOONBEAM, MOONRIVER, ARBITRUM, AVALANCHE, AURORA, and HARMONY.