Reading Metadata from Transactions
import {ethers} from 'ethers' //version 6.12.1
// window.etheruem will connect to a wallet like metamask, while https://polygon-rpc.com is public connection to polygon network
const provider = new ethers.BrowserProvider(window.ethereum || 'https://polygon-rpc.com')
const transactionReceipt = await provider.getTransactionReceipt('0xbeab5823b60da4d003293a2594fc9503ee7c002af969ede94bf1ee57a0168ac2')
const data = transactionReceipt['logs'][2].dataimport {Web3} from 'web3' //version 4.8.0
// window.etheruem will connect to a wallet like metamask, while https://polygon-rpc.com is public connection to polygon network
const provider = new Web3(window.ethereum || 'https://polygon-rpc.com')
const transactionReceipt = await provider.eth.getTransactionReceipt('0xbeab5823b60da4d003293a2594fc9503ee7c002af969ede94bf1ee57a0168ac2')
const data = transactionReceipt['logs'][2].datanpm i hex2jsonimport {ethers} from 'ethers' //version 6.12.1
import { decodeHexToJson } from 'hex2json';
// window.etheruem will connect to a wallet like metamask, while https://polygon-rpc.com is public connection to polygon network
const provider = new ethers.BrowserProvider(window.ethereum || 'https://polygon-rpc.com')
const transactionReceipt = await provider.getTransactionReceipt('0xbeab5823b60da4d003293a2594fc9503ee7c002af969ede94bf1ee57a0168ac2')
const data = transactionReceipt['logs'][2].data
const json = decodeHexToJson(data)
console.log(json)
//We extracted the meta data succesfully from the chain.Last updated