eth_chainId RPC 方法
To use the eth_chainId method on the Avalanche C-Chain, ensure that the end of your URL includes ext/bc/C/rpc.
參數
此方法不接受任何參數
退貨
chainId
字串
載入中...
請求
1curl https://docs-demo.avalanche-mainnet.quiknode.pro \2-X POST \3-H "Content-Type: application/json" \4--data '{5"method": "eth_chainId",6"params": [],7"id": 1,8"jsonrpc": "2.0"9}'
1curl https://docs-demo.avalanche-mainnet.quiknode.pro \2-X POST \3-H "Content-Type: application/json" \4--data '{5"method": "eth_chainId",6"params": [],7"id": 1,8"jsonrpc": "2.0"9}'
1import { 核心 } from '@quicknode/sdk'23const 核心 = new Core({4endpointUrl: "https://docs-demo.avalanche-mainnet.quiknode.pro",5})67core.client.getChainId()8
1import { 核心 } from '@quicknode/sdk'23const 核心 = new Core({4endpointUrl: "https://docs-demo.avalanche-mainnet.quiknode.pro",5})67core.client.getChainId()8
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider(4"https://docs-demo.avalanche-mainnet.quiknode.pro"5);6const network = await provider.send("eth_chainId");7console.log(network);8})();9
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider(4"https://docs-demo.avalanche-mainnet.quiknode.pro"5);6const network = await provider.send("eth_chainId");7console.log(network);8})();9
1出自 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.avalanche-mainnet.quiknode.pro'))3print (w3.eth.chain_id)
1出自 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.avalanche-mainnet.quiknode.pro'))3print (w3.eth.chain_id)