I am trying to make a small public script to fetch the initial minter of a token or a list of tokens.
The easiest way is to fetch the transaction that matches with the correct program id and get the fee payer because, in 99.99% of the cases, the fee payer is the minter itself.
I am trying to get the fee payer from a TransactionResponse object.
I can see that transaction.transaction.message.accountKeys[0]
gives the fee payer but I couldn't find any resource to verify that the first account in accountKeys
array is always the fee payer.
Is this way safe? If not, is there any other convenient way to fetch the fee payer of a transaction?
The payer is always the first account referenced, and the first signature is by the fee payer.
Here's a reference in the message code:
In the `Message` structure, the first account is always the fee-payer,
Excerpted from https://github.com/solana-labs/solana/blob/c419845cfeb1c7ab9ca959de66e90b9dacbc25b7/sdk/program/src/message/legacy.rs#L90
You can follow along the (slightly complicated) logic in JS: https://github.com/solana-labs/solana/blob/c419845cfeb1c7ab9ca959de66e90b9dacbc25b7/web3.js/src/transaction.ts#L415