0

I’m using wagmi ^1.3.10 and getting this error:

getTransaction.js:58 Uncaught (in promise) TransactionNotFoundError
    at getTransaction (getTransaction.js:58:15)
    at async delay.count.count (waitForTransactionReceipt.js:104:48)
    at async attemptRetry (withRetry.js:17:30)

when calling this function:

export const createProposalInteraction = async (
  ipfsHash: string,
  formAddress: string
) => {
  const { request: prepareConfig } = await prepareWriteContract({
    address: mainContractAddress,
    abi: MainContractAbi,
    args: [formAddress, ipfsHash],
    functionName: "createProposal",
  });
  const { hash } = await writeContract(prepareConfig);

  const data = await waitForTransaction({
    hash,
  });
  return data;

};

However, the transaction itself successfully passes.

Here is my wagmi config:

import {
  RainbowKitProvider,
  getDefaultWallets,
  connectorsForWallets,
} from "@rainbow-me/rainbowkit";
import {
  argentWallet,
  trustWallet,
  ledgerWallet,
} from "@rainbow-me/rainbowkit/wallets";
import { configureChains, createConfig, WagmiConfig } from "wagmi";
import { sepolia } from "wagmi/chains";

import { publicProvider } from "wagmi/providers/public";

const { chains, publicClient, webSocketPublicClient } = configureChains(
  [
    sepolia,
  ],
  [
    publicProvider(),
  ],
  //{ retryDelay: 500 }
);

const projectId = "my project id";

const { wallets } = getDefaultWallets({
  appName: "RainbowKit demo",
  projectId,
  chains,
});

const demoAppInfo = {
  appName: "Rainbowkit Demo",
};

const connectors = connectorsForWallets([
  ...wallets,
  {
    groupName: "Other",
    wallets: [
      trustWallet({ projectId, chains }),
      ledgerWallet({ projectId, chains }),
    ],
  },
]);

export const wagmiConfig = createConfig({
  autoConnect: true,
  connectors,
  publicClient,
  webSocketPublicClient,
});

I’ve even tried to tinker with retryDelay in wagmi config , but that doesn't seem to be the issue.

How to fix this?

1 Answer 1

0

You should use waitForTransactionReceipt.

In your code corresponding to createProposalInteraction, replace:

const data = await waitForTransaction({
  hash,
});
return data;

With:

const transactionReceipt = await waitForTransactionReceipt(wagmiConfig, {
  hash
});
return transactionReceipt;
11
  • waitForTransactionReceipt is a function from wagmi version 2. waitForTransaction was renamed to waitForTransactionReceipt. is there a way to fix my error with wagmi version 1?
    – rashmor
    Commented Jun 17 at 15:56
  • Can you try adding the timeout? Commented Jun 17 at 18:00
  • Thanks! It seems that the timeout fixed the issue.
    – rashmor
    Commented Jun 18 at 11:11
  • UPD. issue was fixed for like 10 tries and then reappeared again
    – rashmor
    Commented Jun 18 at 11:40
  • 1
    ok, issue resolved by replacing publicProvider() in wagmiConfig with another provider; now it works fine.
    – rashmor
    Commented Jul 3 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.