Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

300
Visualizações
Error initializing Alchemy Provider in next.js

I want to init alchemy json Provider in next.js

the alchemy url with key is stored inside env.local like so-

ALCHEMY_URL=https://polygon-mumbai.g.alchemy.com/v2/myAlchemyKey

page: /nft

 const alchemyUrl = process.env.ALCHEMY_URL

 console.log("** ethersAlchemyProvider **")
 const ethersAlchemyProvider =  new 
 ethers.providers.JsonRpcProvider(alchemyUrl)
 // console.log(ALCHEMY_URL)
 //console.log(ethersAlchemyProvider)

If the above is not possible in next.js, can you show me how I should init ethers provider serverSide and pass it inside the /nft page as prop, this what I tried-

 export async function getServerSideProps() {
  var ethers = require('ethers')

   // init alchemy provider here
  const ethersAlchemyProvider =  new ethers.providers.JsonRpcProvider(process.env.ALCHEMY_URL)
  
   // Pass data to the page via props
   return { props: { ethersAlchemyProvider } }
 }

It gives me this error-

enter image description here

Basically I want to initialize the ethers-provider using that alchemy-key inside env.local.

am using "next": "12.0.10"

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda