import { EthereumClient, w3mConnectors, w3mProvider } from '@web3modal/ethereum'
_app.tsx
:
const chains = [sepolia,polygonMumbai, goerli,arbitrum, mainnet, polygon,localhost]
const projectId = ''
const { publicClient } = configureChains(chains, [w3mProvider({ projectId })])
const wagmiConfig = createConfig({
autoConnect: true,
connectors: w3mConnectors({ projectId, chains }),
publicClient
})
export default function App({ Component, pageProps }: AppProps) {
return (
<WagmiConfig config={wagmiConfig}>
<Component {...pageProps} />
import { usePrepareContractWrite, useContractWrite } from "wagmi";
const { data:max_tickets, isError, isLoading } = useContractRead({
address: router.query.contract as `0x${string}`,
abi: Event_data.abi,
functionName: 'max_tickets',
})
const { data: data1, write: set_tickets } = useContractWrite({ address: router.query.contract as `0x${string}`, abi: Event_data.abi, functionName: 'set_tickets' });
const { data, write, isSuccess } = useContractWrite({
address: contract_addr.event_factory as `0x${string}`,
abi: Event_data.abi,
functionName: 'createEvent',
})
const { isError, isLoading } = useWaitForTransaction({
hash: data?.hash,
})
Ref