Skip to content

Commit 60a3cd6

Browse files
author
Nguyen Anh Tu
committed
use rpc method to get chain id
1 parent 6e4e8f4 commit 60a3cd6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

demo/vue-app-new/src/services/ethHandlers.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export const getAccounts = async (provider: IProvider, uiConsole: any): Promise<
5656
};
5757
export const getChainId = async (provider: IProvider, uiConsole: any): Promise<string | undefined> => {
5858
try {
59-
const { chainId } = provider;
59+
// eth_chainId
60+
const ethProvider = new BrowserProvider(provider);
61+
const args = ethProvider.provider.getRpcRequest({ method: "chainId" });
62+
const chainId = (await provider.request(args!)) as string;
6063
uiConsole("chainId", chainId.toString());
6164
return chainId.toString();
6265
} catch (error) {

0 commit comments

Comments
 (0)