Skip to main content

Function: getMessagesByTxHash()

getMessagesByTxHash(args): Promise<EquitoMessageWithData[]>

Fetches and decodes all the MessageSendRequested events of a transaction, given its hash.

Parameters

args: GetMessagesByTxHashArgs

GetMessagesByTxHashArgs

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 publicClient = ...;  // Your viem provider
const routerContract = '0x...'; // The router contract address
const txHash = '0x...'; // The transaction hash

getMessagesByTxHash({publicClient, routerContract, 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);
});

Defined in

packages/viem/src/router/get-message-and-data-by-tx-hash.ts:51