const ethers = require('ethers'); const { contractAddress, JsonRpcProvider, txHash } = require('./parameters'); const { abi } = require('./ABI'); // Load the RPC provider const provider = new ethers.JsonRpcProvider(JsonRpcProvider); // Create a new instance of Contract with the given values const contract = new ethers.Contract(contractAddress, abi, provider); // Retrieve the transaction logs const getTXData = async (tx) => { const transaction = await provider.getTransaction(tx); const decodedInput = contract.interface.parseTransaction({ data: transaction.data, value: transaction.value }); const functionFragment = abi.find(fragment => fragment.name === decodedInput.name); const fInputs = Object.fromEntries(decodedInput.args.map((arg, index) => [ functionFragment.inputs[index].name, arg ])); console.log("Function input params:", fInputs); const receipt = await provider.getTransactionReceipt(tx); const logs = receipt.logs; const parsedLogs = logs.map(log => contract.interface.parseLog(log)); const inputs = parsedLogs[0].fragment.inputs; const logsNames = {}; for (let i = 0; i < inputs.length; i++) { const inputName = inputs[i].name; const argValue = parsedLogs[0].args[i]; logsNames[inputName] = argValue; } console.log("Event logs:", logsNames); } // Display the transaction data of the functions const showTXData = async () => { console.log('accept transaction data:'); await getTXData(txHash.accept); console.log(); console.log('publish transaction data:'); await getTXData(txHash.publish); } showTXData();