How to extract the addresses of the swapped tokens from the receipt data?

29 Views Asked by At

I can retrieve the BEP-20 transaction receipt data with the transaction hash using the code below. How can I extract the addresses of the swapped tokens(tokenIn/tokenOut) and amount from the receipt?

const { Web3 } = require('web3');

// Initialize Web3 instance
const web3 = new Web3('_YOUR_PROVIDER_');

// Transaction hash of the transaction you want to analyze
const transactionHash = '0x8668568212282dcd672eb14d1fbfbee6a40cd19972b3136aed793cdf7d0c11d3';

web3.eth.getTransactionReceipt(transactionHash)
  .then((tx) => {
    console.log(tx);
  });
0

There are 0 best solutions below