How to fetch transaction type using getTokenTransfers?

Hi,

I’m using “Moralis.Web3API.account.getTokenTransfers” function to fetch transactions from an address,
The response doesn’t contain transaction receipt to get transaction method as it’s displayed on block explorer, please find the image.


Is there any way to get transaction methods with bulk fetch function as it’s displayed on the image?
otherwise, should I loop through each transaction to fetch that information? please specify the another function where I could get it from.
Thanks

You could use getTransactions to get all native transactions on the address and get the methodId from the input value.

E.g. for this transaction hash result:

{
      "hash": "0x53dbbff495b09fe9f21bf27e9f553852741a5bc321bc67e76659674d1c698e5d",
      "from_address": "0x73c1c73476ecbd4d063735b6607313bd816b48a2",
      "to_address": "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d",
      "input": "0x23b872dd00000000000000000000000073c1c73476ecbd4d063735b6607313bd816b48a2000000000000000000000000b8abe7b3923e6d3ec1f5c4011fc9ce3c816e0cf80000000000000000000000000000000000000000000000000000000000001864",
}, ...

You get the methodId from the first 4 bytes or 23b872dd. Hashing transferFrom(address,address,uint256) with Keccak256 equals 23b872dd.

So you’d probably need a list of common method names or IDs so you can match them. There is also this directory.

Hi,
Thanks for the answer
I’m using “getTokenTransfers” function to retrieve ERC20 token transfers
and it returns only these fields
{
transaction_hash: ‘0x183b7495beff57e34e82468f5b4f1d762cfbe1cc3e41ed7d947bd6a5b7fa8796’,
address: ‘0xa9079d37a06894e8ed2a6e5fb20e500d6a57563d’,
block_timestamp: ‘2022-04-29T00:14:01.000Z’,
block_number: ‘9083981’,
block_hash: ‘0x9106e818443c920b97fc95b22c77737da682adec03b648ac08395e0afa1f3556’,
to_address: ‘0x2798180dbbe348b171ba055c21899110c5e7bd08’,
from_address: ‘0xa9079d37a06894e8ed2a6e5fb20e500d6a57563d’,
value: ‘50000000000000’
},
That’s why I’m looking for the solution
Is there any solution?
Thanks

Yes the methods you’re looking for on the Transactions page won’t be available in getTokenTransfers.

In the screenshot you posted, the Transactions page is what is in getTransactions, not getTokenTransfers (or the “ERC20 Token Txns” page, that’s what you should be looking at).

Otherwise it may be added to that endpoint at some stage.

Hi,

Yes, that’s my bad that provided wrong page, so instead of transactions page, I need to get method from ERC20 token transafers,
So there is no way to get bulk transactions with the input data right ?
Thanks

No at this stage you would have to use getTransaction and loop over each transaction hash from getTokenTransfers.

Got your response. thanks