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

137
Visualizações
Cloud functions builds and lints, but no URL is generated

I'm experimenting with ethers.js contract deployment inside a firebase cloud function. My functions build and compiles, but when I run either firebase serve --only functions or firebase deploy --only functions, it deploys one of the contracts exported in index.ts, ("helloWorld") but not the other one ("greet"), which is what I'm trying to test.

No errors are generated in the build step, and when I run firebase serve, I get a URL for helloWorld, but nothing (nor any error messages) on 'greet'.

Here's the contents of index.ts:

import {ethers, Wallet} from "ethers";
import * as functions from "firebase-functions";
import greetJson from "../contracts/greeter.json";

export const greet = functions.https.onRequest(async (request, response) => {
  const provider = new ethers.providers.JsonRpcProvider("http://localhost:8545");
  const signer = new
  Wallet("*redacted*",
      provider);
  console.log("starting deploy");
  const abi = greetJson.abi;
  const factory = new ethers.ContractFactory(abi, greetJson.bytecode, signer);
  const contract = await factory.deploy(["Ciao Bella"]);
  const greeter = await contract.deployed();
  const greetresult = await greeter.greet();
  response.send("Hello: " + greetresult);
});

export const helloWorld = functions.https.onRequest((request, response) => {
  functions.logger.info("Hello logs!", {structuredData: true});
  response.send("Hello from Firebase!");
});

here's the terminal output:

My-MacBook-Pro:functions jk$ npm run-script build

build tsc

My-MacBook-Pro:functions jk$ firebase serve --only functions
⚠  Your requested "node" version "16" doesn't match your global version "14". Using node@14 from host.
i  functions: Watching "/Users/jk/Documents/VSCodeProjects/BKC/bkc-cloud-blockchain/functions" for Cloud Functions...
✔  functions[us-central1-helloWorld]: http function initialized (http://localhost:5000/bkc-63bcf/us-central1/helloWorld).

That's it. Any idea why the greet function is ignored?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

There's an option called Partial Deploys, to deploy specific Firebase functions.

For example:

$ firebase deploy --only functions:function1

And to deploy more than one function at once, you can use:

$ firebase deploy --only functions:function1,functions:function2

So for your case, you can run the command to deploy your two functions:

$ firebase deploy --only functions:greet,functions:helloWorld

about 4 years ago · Juan Pablo Isaza Relatório

0

This turned out to be a problem related to directory structure, and the include key in tsconfig.json.

If you put an include key like "include": ["src", "contracts"] in order to be able to import json files in the contracts folder, you end up writing to a lib folder that is an unexpected place, and is ignored. Best to make sure that if you need a folder to contain files that need to be included in your build, just put them under src and don't include an include key in your tsconfig when you run firebase serve

about 4 years ago · Juan Pablo Isaza Relatório
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