PoC-Doc-Delivery / PoC_Transaction_Data / transactionReceiptLogs.js
transactionReceiptLogs.js
Raw
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);

// Get the transaction receipt logs
const getLogs = async (tx) => {
    const receipt = await provider.getTransactionReceipt(tx);
    const logs = receipt.logs;
    const parsedLogs = logs.map(log => contract.interface.parseLog(log));
    console.log(parsedLogs);
}

// Display the transaction receipt logs of the functions
const showTransactionReceiptLogs = async () => {
	console.log('accept transaction receipt logs:');
	await getLogs(txHash.accept);
	console.log();
	console.log('publish transaction receipt logs:');
	await getLogs(txHash.publish);
}

showTransactionReceiptLogs();