You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Wondering what y'all are doing to use this in API routes, getServerSideProps etc. As far as I'm aware you can't use hooks in any of those locations, right?
I ran into the same problem with useDapp previously and had to do something like this using the typechain factory and manually creating a new readonly JsonRpcProvider. would we benefit from wagmi including a non-hooksy abstraction?
import{providers}from'ethers';import{GenerativeEdition,GenerativeEdition__factory,}from'@aspects/sol/typechain';import{THRESHOLDS_ADDRESS}from'../utils/contracts';import{networkConfig}from'../pages/_app';// useDapp's config, not wagmi'sexportfunctionthresholdsContractReadonly(): GenerativeEdition{constreadNetworkUrl=networkConfig.readOnlyChainId&&networkConfig.readOnlyUrls&&networkConfig.readOnlyUrls[networkConfig.readOnlyChainId];returnGenerativeEdition__factory.connect(THRESHOLDS_ADDRESS,newproviders.JsonRpcProvider(readNetworkUrl));}constHandler: NextApiHandler<Metadata>=async(req,res)=>{consttokenId=req.query.tokenIdasstring;try{constcontract=thresholdsContractReadonly();consttokenInfo=awaitcontract.tokenInfo(tokenId);consttokenHash=tokenInfo.hash.toString();res.status(200).json({name: `Aspects ${tokenId}`,description: `Aspects. Visit https://${baseUrl}/view/${tokenId} to view the real-time artwork.`,
tokenHash,});}catch(err){res.status(404);}};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Wondering what y'all are doing to use this in API routes, getServerSideProps etc. As far as I'm aware you can't use hooks in any of those locations, right?
I ran into the same problem with
useDapp
previously and had to do something like this using the typechain factory and manually creating a new readonly JsonRpcProvider. would we benefit from wagmi including a non-hooksy abstraction?Beta Was this translation helpful? Give feedback.
All reactions