Cross-Chain EVM Requests
All our API methods are supported for cross-chain calls. You only need to specify the chain
parameter. For example, this request will query block info on Polygon:
import Moralis from "moralis";
import { EvmChain } from "@moralisweb3/common-evm-utils";
evmApi.block.getBlock({
blockNumberOrHash: "33000000",
chain: EvmChain.POLYGON,
});
If no chain
is specified, it will, by default, be set to the defaultEvmApiChain
, which is set in your config (defaults to "Ethereum mainnet").
Change the Default Chain
To change the default chain, you can specify defaultEvmApiChain
in your config:
import Moralis from "moralis";
import { EvmChain } from "@moralisweb3/common-evm-utils";
Moralis.start({
apiKey: "YOUR_API_KEY",
defaultEvmApiChain: EvmChain.POLYGON,
});
Moralis.EvmApi.block.getBlock({
blockNumberOrHash: "33000000",
});
Supported EVM Chains
Name | Chain Id (Int) | Chain Id (Hex) | EvmChain | Type |
---|---|---|---|---|
Ethereum Mainnet | 1 | 0x1 | EvmChain.ETHEREUM | Mainnet |
Ethereum Görli | 5 | 0x5 | EvmChain.GOERLI | Testnet |
Ethereum Sepolia | 11155111 | 0xaa36a7 | EvmChain.SEPOLIA | Testnet |
Polygon Mainnet | 137 | 0x89 | EvmChain.POLYGON | Mainnet |
Polygon Mumbai | 80001 | 0x13881 | EvmChain.MUMBAI | Testnet |
Binance Smart Chain Mainnet | 56 | 0x38 | EvmChain.BSC | Mainnet |
Binance Smart Chain Testnet | 97 | 0x61 | EvmChain.BSC_TESTNET | Testnet |
Avalanche C-Chain | 43114 | 0xa86a | EvmChain.AVALANCHE | Mainnet |
Fantom | 250 | 0xfa | EvmChain.FANTOM | Mainnet |
Cronos Mainnet | 25 | 0x19 | EvmChain.CRONOS | Mainnet |
Palm | 11297108109 | 0x2a15c308d | EvmChain.PALM | Mainnet |
Arbitrum | 42161 | 0xa4b1 | EvmChain.ARBITRUM | Mainnet |
Solana
Change the Default Network
We have two networks for the Solana API, which you can configure similarly. You can specify the mainnet or devnet:
import Moralis from "moralis";
import { SolNetwork } from "@moralisweb3/common-sol-utils";
Moralis.start({
apiKey: "YOUR_API_KEY",
defaultSolNetwork: SolNetwork.DEVNET,
});
Moralis.SolApi.account.getBalance({
address: "ADDRESS",
});
Supported Solana Networks
Name | SolNetwork | Type |
---|---|---|
Solana mainnet | SolNetwork.MAINNET | Mainnet |
Solana devnet | SolNetwork.DEVNET | Testnet |