How to get caller of transaction using indexer?

Hey guys
I’m trying to get all the call transactions of my contract (preferably by function method)
You can see all context on those topics:
How to get all the call transactions of my contract?
Error during pull fuel-indexer: no matching manifest for linux/arm64/v8 in the manifest list entries
Problem with building indexer from source

So, I have already given up hope of receiving contract transactions and decided to fetch all transactions and sort them by input contract on my server :moyai:

In playground we have some schemas and the schema of the transaction looks like that:

type Transaction {
  id: TransactionId!
  inputAssetIds: [AssetId!]
  inputContracts: [Contract!]
  gasPrice: U64
  gasLimit: U64
  maturity: U64
  txPointer: TxPointer
  isScript: Boolean!
  isCreate: Boolean!
  isMint: Boolean!
  inputs: [Input!]
  outputs: [Output!]!
  witnesses: [HexString!]
  receiptsRoot: Bytes32
  status: TransactionStatus
  receipts: [Receipt!]
  script: HexString
  scriptData: HexString
  bytecodeWitnessIndex: Int
  bytecodeLength: U64
  salt: Salt
  storageSlots: [HexString!]

  # Return the transaction bytes using canonical encoding
  rawPayload: HexString!
}

Can you help me to figure out how to find the caller of the transaction here?

2 Likes

You should be able to determine the sender from the transaction inputs array. You can take a look at how the sway standard library does it here: sway/auth.sw at master · FuelLabs/sway · GitHub .

1 Like

I mean How to get the sender from graphQL response, not in sway c:

I understand, however the logic should be the same. If the sender is a contract, you can use the contract input as the sender. Otherwise, you can use the message input sender or coin input owner.