Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda