I am working on a Noble to Ethereum USDC bridge using Ethers.js v6. The process involves two main steps: burning USDC on the Noble test chain and minting the USDC on Ethereum Sepolia.
The burn step works correctly, and I can see the transaction on the Noble test chain. However, I am encountering an issue while trying to retrieve the transaction receipt for the Sepolia network.
Problem:
When I attempt to retrieve the transaction receipt using the getTransactionReceipt
method in Ethers.js v6, I receive the error Transaction receipt not found
.
Here is the relevant part of my code:
import { ethers } from 'ethers';
import { getAttestation, AttestationStatus } from './utils/fetchAttestation';
const mintUSDC = async (txHash: string) => {
try {
const provider = new ethers.BrowserProvider(window.ethereum);
const formattedTxHash = `0x${txHash}`;
console.log(`Fetching receipt for transaction hash: ${formattedTxHash}`);
const receipt = await provider.getTransactionReceipt(formattedTxHash);
if (!receipt) {
throw new Error('Transaction receipt not found');
}
const eventSignature = ethers.keccak256(ethers.toUtf8Bytes('MessageSent(bytes)'));
console.log(`Event signature: ${eventSignature}`);
const log = receipt.logs.find(log => log.topics[0] === eventSignature);
if (!log) {
throw new Error('MessageSent event not found');
}
const messageBytes = ethers.AbiCoder.defaultAbiCoder().decode(['bytes'], log.data)[0];
const messageHash = ethers.keccak256(messageBytes);
console.log(`Message hash: ${messageHash}`);
let attestationResponse = await getAttestation(messageHash);
while (attestationResponse.status !== AttestationStatus.complete) {
await new Promise(resolve => setTimeout(resolve, 2000));
attestationResponse = await getAttestation(messageHash);
}
const attestation = attestationResponse.message;
const messageTransmitterContract = new ethers.Contract(
"0x7865fAfC2db2093669d92c0F33AeEF291086BEFD",
["function receiveMessage(bytes message, bytes attestation) public"],
provider.getSigner()
);
console.log(`Sending receiveMessage transaction...`);
const tx = await messageTransmitterContract.receiveMessage(messageBytes, attestation);
await tx.wait();
console.log(`USDC minted: https://sepolia.etherscan.io/tx/${tx.hash}`);
} catch (error) {
console.error('Failed to mint USDC:', error);
}
};
Steps Taken:
- Ensured that the transaction hash is correctly formatted.
- Verified that the transaction hash exists on the Sepolia Etherscan.
- Checked that the provider is correctly set up to connect to the Sepolia network.
Error Message:
Failed to mint USDC: Error: Transaction receipt not found
Additional Information:
- Ethers.js version: 6.x
- Wallet: MetaMask
- Network: Sepolia Testnet
- Example transaction hash:
0x2C6B93DBD374C613A6B69A2975B020667CA7438D5E22BC929C8F86F272B70839
Question:
What could be causing the Transaction receipt not found
error when trying to retrieve the transaction receipt on the Sepolia network? Are there any additional steps or configurations required for Sepolia in Ethers.js v6?
Any help or pointers would be greatly appreciated. Thank you!