title: Getting some metadata from cloud storage to cloud function
body: <p>I want to grab a json file from my cloud storage to use in cloud function (this is in the '/post-account' route). Although, I'm not sure if I'm doing it correctly, as the error logs are printing that web3 cant instantiate a contract without its abi (json interface).</p>
  <p>I just need some hardcoded metadata for the cloud function. I have tried deploying with the json file local to the function dir, and requiring in the index.js, this did not work.</p>
  <p>I could try copying the entire json interface into index.js as var, but this is thousands of lines of metadata.</p>
  <p><strong>index.js</strong></p>
  <pre><code>'use strict';
  const Web3 = require('web3');
  const Contract = require('web3-eth-contract');
  const axios = require('axios')
  const fs = require('fs');
  const functions = require('firebase-functions');
  const admin = require('firebase-admin');
  admin.initializeApp();
  const express = require('express');
  const cookieParser = require('cookie-parser')();
  const cors = require('cors');
  const app = express();
  
  
  //options for cors midddleware
  const options = {
    allowedHeaders: [
      'Authorization',
      'Origin',
      'X-Requested-With',
      'Content-Type',
      'Accept',
      'X-Access-Token',
    ],
    credentials: true,
    methods: 'GET,HEAD,OPTIONS,PUT,PATCH,POST,DELETE',
    origin: 'https://test-cf-97bfc.web.app',
    preflightContinue: false,
  };
  
  // set headers for app.
  app.use(function (req, res, next) {
  
    // Website you wish to allow to connect
    res.setHeader('Access-Control-Allow-Origin', 'https://test-cf-97bfc.web.app');
  
    // Request methods you wish to allow
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
  
    // Request headers you wish to allow
    res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
  
    // Set to true if you need the website to include cookies in the requests sent
    // to the API (e.g. in case you use sessions)
    res.setHeader('Access-Control-Allow-Credentials', true);
  
    // Pass to next layer of middleware
    next();
  });
  
  
  // Express middleware that validates Firebase ID Tokens passed in the Authorization HTTP header.
  // The Firebase ID token needs to be passed as a Bearer token in the Authorization HTTP header like this:
  // `Authorization: Bearer &lt;Firebase ID Token&gt;`.
  // when decoded successfully, the ID Token content will be added as `req.user`.
  const validateFirebaseIdToken = async (req, res, next) =&gt; {
    console.log('Check if request is authorized with Firebase ID token');
  
    if ((!req.headers.authorization || !req.headers.authorization.startsWith('Bearer ')) &amp;&amp;
      !(req.cookies &amp;&amp; req.cookies.__session)) {
      console.error('No Firebase ID token was passed as a Bearer token in the Authorization header.',
        'Make sure you authorize your request by providing the following HTTP header:',
        'Authorization: Bearer &lt;Firebase ID Token&gt;',
        'or by passing a &quot;__session&quot; cookie.');
      res.status(403).send('Unauthorized');
      return;
    }
  
    let idToken;
    if (req.headers.authorization &amp;&amp; req.headers.authorization.startsWith('Bearer ')) {
      console.log('Found &quot;Authorization&quot; header');
      // Read the ID Token from the Authorization header.
      idToken = req.headers.authorization.split('Bearer ')[1];
    } else if (req.cookies) {
      console.log('Found &quot;__session&quot; cookie');
      // Read the ID Token from cookie.
      idToken = req.cookies.__session;
    } else {
      // No cookie
      res.status(403).send('Unauthorized');
      return;
    }
  
    try {
      const decodedIdToken = await admin.auth().verifyIdToken(idToken);
      console.log('ID Token correctly decoded', decodedIdToken);
      req.user = decodedIdToken;
      next();
      return;
    } catch (error) {
      console.error('Error while verifying Firebase ID token:', error);
      res.status(403).send('Unauthorized');
      return;
    }
  };
  
  
  
  
  app.use(cors(options))
  app.use(cookieParser);
  app.use(validateFirebaseIdToken);
  
  app.get('/hello', (req, res) =&gt; {
    // @ts-ignore
    res.send(`Hello ${req.user.email}`);
  });
  
  
  
  app.post('/post-account', async (req, res) =&gt; {
    const { account, price } = req.body;
    console.log('account' + account);
    console.log('price' + price);
    //changing to matic node
    const web3 = new Web3.providers.HttpProvider('https://ropsten.infura.io/v3/09cbbdd922284d95a70c627ddf29012d');
    const address = &quot;0xE981aFEeA8E3dB77003C1D56e7c1D42e470Ea775&quot;;
  
  //fetch json from cloud storage. Incorrect?
    const abi = axios.get('https://firebasestorage.googleapis.com/v0/b/test-cf-97bfc.appspot.com/o/abis%2Fabi.json?alt=media&amp;token=26bb0e2f-872c-4ee9-ac0f-525b9d84af39')
  
    console.log('after artifact call');
    Contract.setProvider(web3);
    //error here.
    const contract = new Contract(abi, address);
  
    await contract.methods.totalSupply().call( function(error, result){
      if  (error) {
        console.log(error);
        res.status(400).end;
      }
      else if (result) {
        res.status(200).json({ txResolved: &quot;NFT awarded post&quot;, account: account, currentSupply: result  })
      }
  });
  
  
  
  
  
  
  });
  
  
  
  
  exports.testAPI = functions.https.onRequest(app);
  
  
  
  
  </code></pre>