Collection Details
Namespace:
zixu
Dataset:
Collection:
zimu
Owner:
0xad61e60ed8e8ad1cbfe6fcd1afe51d2a8d80f704
Timestamp:
Jun.11.2024 01:42:02 PM
Status:
OnChain
Collection Documents
_iddescriptionexternal_urlimagenameziView
c98be34fc3b5161d034c94e87f849e45dce4525adfa37d6c4af25a00fc6cc17a2
卡哇伊
https://glacier.io/
https://raw.githubusercontent.com/Glacier-Labs/resource/main/nft1.jpg
zimu
View
c98be34fc3b5161d034c94e87f849e45dce4525adfa37d6c4af25a00fc6cc17a1
import { useState, useEffect, useCallback } from 'react'; import { MetaMaskInpageProvider } from '@metamask/providers'; export default function useMetaMask() { const [account, setAccount] = useState<string>(); const [provider, setProvider] = useState<MetaMaskInpageProvider>(); const connect = useCallback(async () => { const accounts = await window.ethereum.request<string[]>({ method: 'eth_requestAccounts', params: [], }); if (accounts) setAccount(accounts[0]); }, []); const eagerConnect = useCallback(async () => { if (!window.ethereum) return; const accounts = await window.ethereum?.request<string[]>({ method: 'eth_accounts', params: [], }); if (accounts) setAccount(accounts[0]); setProvider(window.ethereum); }, []); useEffect(() => { window.ethereum?.on('accountsChanged', (args) => { const accounts = args as string[]; if (accounts) setAccount(accounts[0]); setProvider(window.ethereum); }); }, []); return { account, provider, connect, eagerConnect, }; }
View