Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!