-
Notifications
You must be signed in to change notification settings - Fork 287
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a306ca
commit 074b056
Showing
4 changed files
with
418 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
Oops, something went wrong.