0

I need some help with this topic, I'm using the Blockfrost API: https://docs.blockfrost.io/, but when I get the hash here using this function that I created :

const BASE_URL = "https://cardano-mainnet.blockfrost.io/api/v0";

export const getTransactions = async (address: string) => {
  const { data } = await axios.get(
    `${BASE_URL}/addresses/${address}/transactions`,
    {
      headers: {
        project_id: process.env.BLOCKFROST_API_KEY,
      },
    }
  );
  return data;
};

and doing this process to have the metadata with the utxos:

const getAllTransactions = async (hash) => {
    await axios
      .all([
        axios.get(`${process.env.BASE_API}/txs/${hash}/metadata`, {
          headers: {
            project_id: process.env.BLOCKFROST_API_KEY,
          },
        }),
        axios.get(`${process.env.BASE_API}/txs/${hash}/utxos`, {
          headers: {
            project_id: process.env.BLOCKFROST_API_KEY,
          },
        }),
      ])
      .then(
        axios.spread((...responses) => {
          const responseOne = responses[0];
          const responseTwo = responses[1];
          if (responseOne.status === 200 && responseTwo.status === 200) {
            let data = {
              metadata: responseOne?.data[0],
              utxos: responseTwo.data,
            };
            setMetaData((prevMetaData) => [...prevMetaData, data]);
            console.log("data :>> ", metaData);
          }
        })
      )
      .catch((errors) => {
        console.log("errors :>> ", errors);
      });
  };

I have a problem that seems that some of the txs have undefined metadata, but checking like https://cexplorer.io/tx they have the info of the transactions even if has undefined metadata but it seems that is a coded part for no-humans, but the question is, it possible do decoded using blockfrost and have the metadata info from the hash?

lumberjack
  • 31
  • 2

0 Answers0