import React from 'react' import ReactDOM from 'react-dom' import { Mainnet, DAppProvider, useEthers, Config, useEtherBalance, Goerli } from '@usedapp/core' // Regular import crashes the app with "Buffer is not defined" error. import WalletConnectProvider from '@walletconnect/web3-provider/dist/umd/index.min.js' import { formatEther } from '@ethersproject/units' import { getDefaultProvider } from 'ethers' import { AccountIcon } from './components/AccountIcon' const config: Config = { readOnlyChainId: Mainnet.chainId, readOnlyUrls: { [Mainnet.chainId]: getDefaultProvider('mainnet'), [Goerli.chainId]: getDefaultProvider('goerli'), }, } ReactDOM.render( , document.getElementById('root') ) function App() { const { account, activate, deactivate, chainId } = useEthers() const etherBalance = useEtherBalance(account) if (!config.readOnlyUrls[chainId]) { return

Please use either Mainnet or Goerli testnet.

} async function onConnect() { try { const provider = new WalletConnectProvider({ infuraId: 'd8df2cb7844e4a54ab0a782f608749dd', }) await provider.enable() await activate(provider) } catch (error) { console.error(error) } } const ConnectButton = () => (
) const WalletConnectConnect = () => (
{account && (
 
{account}

)} {!account && } {account && }
) return (
{etherBalance && (

Balance:

{formatEther(etherBalance)} ETH

)}
) }