Skip to content

Commit

Permalink
Automatically pull chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Electron authored Dec 2, 2023
1 parent 5a306ca commit 074b056
Show file tree
Hide file tree
Showing 4 changed files with 418 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/build/getting-started/networks-endpoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ keywords:
---

import { AddToMetaMaskButton, EVMNetworks } from '@theme/AddToMetaMaskButton';
import { ChainId } from '@theme/ChainId';

# Networks & Endpoints

Expand Down Expand Up @@ -57,7 +58,7 @@ Mainnet.

| Base Token | Protocol | Chain ID | RPC URL | Explorer |
| ------------- | --------- | -------- | ----------------------------------------------------------------------------- | ------------------------------------ |
| Shimmer Token | ISC / EVM | 148 | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network |
| Shimmer Token | ISC / EVM | <ChainId url='https://json-rpc.evm.shimmer.network'/> | https://json-rpc.evm.shimmer.network or wss://ws.json-rpc.evm.shimmer.network | https://explorer.evm.shimmer.network |

## Public Testnet

Expand Down Expand Up @@ -86,7 +87,7 @@ This network is subject to occasional resets (no data retention) which are usual

| Base Token | Protocol | Chain ID | RPC URL | Faucet | Explorer |
| ------------------------- | --------- | -------- | -------------------------------------------- | ------------------------------------------ | -------------------------------------------- |
| Testnet Tokens (no value) | ISC / EVM | 1073 | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network |
| Testnet Tokens (no value) | ISC / EVM | <ChainId url='https://json-rpc.evm.testnet.shimmer.network'/> | https://json-rpc.evm.testnet.shimmer.network | https://evm-faucet.testnet.shimmer.network | https://explorer.evm.testnet.shimmer.network |

## DevNet

Expand Down
3 changes: 2 additions & 1 deletion theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"@metamask/providers": "^10.2.1",
"clsx": "^1.2.1",
"html-react-parser": "^4.2.10",
"react-markdown": "6"
"react-markdown": "6",
"web3": "^4.2.2"
},
"devDependencies": {
"@docusaurus/types": "2.4.1",
Expand Down
20 changes: 20 additions & 0 deletions theme/src/theme/ChainId/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useEffect, useState } from 'react';
import { Web3 } from 'web3';

interface ChainIdProps {
url: string;
}

export function ChainId(props: ChainIdProps) {
const [value, setValue] = useState<string | null>(null);

useEffect(() => {
const web3 = new Web3(props.url);
web3.eth
.getChainId()
.then((chainId) => setValue(chainId.toString()))
.catch((error) => setValue(`Error: ${error.message}`));
}, []);

return value;
}
Loading

0 comments on commit 074b056

Please sign in to comment.