Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically pull chain id #1360

Merged
merged 4 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2",
"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