How to get a tx caller by tx id?

How to get a tx caller by tx id?

Hi guys, for example I have a transaction 0x35ab0a9fba866c806356552512b82dc0fae47a0ae031f12163725891e09982f9 that has been called from address 0x194c4d5d321ea3bc2e87109f4a86520ad60f924998f67007d487d3cc0acc45d2, I have this info in block explorer, how do I can get this info using javascript?

Hey @fuel! Thanks for the question.

You can refer to our graphql docs for all the information you can query or play around with it on the beta-4 graphql playground.

To answer your question this is the query you are looking for

const QUERY = `
  query {
    transaction(id: "0x35ab0a9fba866c806356552512b82dc0fae47a0ae031f12163725891e09982f9") {
      inputs {
        __typename
        ... on InputCoin {
          owner
          utxoId
          amount
          assetId
        }
        ... on InputContract {
          utxoId
          contract {
            id
          }
        }
        ... on InputMessage {
          sender
          recipient
          amount
          data
        }
      }
    }
  }
`;

fetch("https://beta-4.fuel.network/graphql", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Accept: "application/json",
  },
  body: JSON.stringify({
    query: QUERY,
  }),
})
  .then((response) => {
    if (response.status !== 200) {
      throw new Error("Network response was not ok");
    }
    return response.json();
  })
  .then((result) => {
    console.log(result.data.transaction); 
  })
  .catch((error) => {
    console.error("There was an error fetching data:", error);
  });

yielding this result

{
  inputs: [
    {
      __typename: 'InputContract',
      utxoId: '0xfe97238f1baaffe725644de3385e8b6ce61816aa71c9142ac79a41d578a0c78c00',
      contract: [Object]
    },
    {
      __typename: 'InputCoin',
      owner: '0x194c4d5d321ea3bc2e87109f4a86520ad60f924998f67007d487d3cc0acc45d2',
      utxoId: '0xa36bd404b970b2b98a6f2f1dfd8559754c700f1694721e87c3cf31a36931a1c901',
      amount: '1071093634',
      assetId: '0x8bf7951ea3222fe0bae9b811c2b142a1ff417361dcf7457855ed477d2d9a8550'
    },
    {
      __typename: 'InputCoin',
      owner: '0x194c4d5d321ea3bc2e87109f4a86520ad60f924998f67007d487d3cc0acc45d2',
      utxoId: '0x89463cd24cccc73d17bc64bfd0300e55e760bbf076bbfbb4ddbd6bc016e1081901',
      amount: '799845828',
      assetId: '0x0000000000000000000000000000000000000000000000000000000000000000'
    }
  ]
}

where you can see the owner of each input