Function: getMessagesByTxHash()
getMessagesByTxHash(
provider
,routerContractAddress
,txHash
):Promise
<EquitoMessageWithData
[]>
Fetches and decodes all the MessageSendRequested
events of a transaction, given its hash.
Parameters
• provider: AbstractProvider
AbstractProvider The Ethers.js provider to interact with the blockchain.
• routerContractAddress: string
The address of the router contract emitting the event.
• txHash: string
The transaction hash for which the logs are to be retrieved and parsed.
Returns
Promise
<EquitoMessageWithData
[]>
A promise that resolves to the decoded messages and message data.
Throws
Throws an error if the transaction receipt is not found.
Example
const provider = ...; // Your Ethers.js provider
const routerContractAddress = '0x...'; // The router contract address
const txHash = '0x...'; // The transaction hash
getMessagesByTxHash(provider, routerContractAddress, txHash)
.then(results => {
results.forEach(result => {
console.log('Decoded Message:', result.message);
console.log('Decoded Message Data:', result.messageData);
});
})
.catch(error => {
console.error('Error:', error);
});