Trying to extract internal transactions from pancakeswaps

Hello all,

Given the following transaction in bsc: 0x575e4a540c9605c5e6cdd318743b78f41b3c94c32cacec5478d7fd055347afed

I am trying to extract the internal transactions done on pancakeswaps

I am running the following Moralis code:

from moralis import evm_api

import json

api_key = API_KEY

params = {

β€œaddress”: β€œ0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c”, #WBNB contract

β€œchain”: β€œbsc”,

β€œtopic”: β€œ0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef”, #topic ID

β€œabi”:

{

"anonymous": False,

"inputs": [

  {

    "indexed": True,

    "internalType": "address",

    "name": "from",

    "type": "address"

  },

  {

    "indexed": True,

    "internalType": "address",

    "name": "to",

    "type": "address"

  },

  {

    "indexed": False,

    "internalType": "uint256",

    "name": "amount",

    "type": "uint256"

  }

],

"name": "Transfer",

"type": "event"

}

}

result = evm_api.events.get_contract_logs(

api_key=api_key,

params=params,

)

pretty = json.dumps(result, indent=2, sort_keys=True)

print(pretty)

In the output i get a data which is an hexa:

β€œdata”: β€œ0x000000000000000000000000000000000000000000000000016345785d8a0000”

Any way to decode this?

Many thanks

Hi @kevsav

Since you are trying to decode the logs of the event. You can use evm_api.events.get_contract_events to get the decoded data from the event logs.

Check the below doc for testing and for code samples.

Usually the data inside a transaction is in hexadecimal, and you need to know the data structure and types to interpret it. In your case, since you are looking for internal transactions on PancakeSwap, the data is most likely related to token transfers. The hexadecimal string β€œ0x000000000000000000000000000000000000000000000000000016345785d8a0000” may represent the transferred address, amount, and type of token. However, without more information about the contract and its abi (ABI), the blockchain application interface that defines the data structure and functions of the contract, it can be difficult to decipher the data. You may need to get the appropriate ABI for the contract associated with that transaction to interpret the data correctly. If you have access to the source code of the contract or other information about its structure, this can help you decode the data.

Cheers guys for your help - will give it a go

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.