question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: usePrepareContractWrite chainId validation not working

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Package Version

0.6.4

Current Behavior

I’m using the usePrepareContractWrite function in order to mint a NFT on Ethereum Mainnet.

In my MVP I’m calling the function as described here:

const {
    config,
    error: prepareError,
    isError: isPrepareError,
  } = usePrepareContractWrite({
    addressOrName: "0xaf0326d92b97df1221759476b072abfd8084f9be",
    contractInterface: ["function mint()"],
    functionName: "mint",
    chainId: 1,
  });

  const { data, error, isError, write } = useContractWrite(config);

When the user switches chains via Metamask extension, the write function invokes a transaction of 0 ETH to the specified contract address. The same behaviour occurs in the Docs page, while sometimes the ‘Mint’ button is disabled, occasionally when hopping chains it still tries to send a transaction when it’s on the wrong chain.

Expected Behavior

An actual error whenever the current user is not on the specified chain chainId . The write function should not execute an empty transaction.

Steps To Reproduce

No response

Link to Minimal Reproducible Example (CodeSandbox, StackBlitz, etc.)

No response

Anything else?

Screenshot_20220909_223718

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
jxomcommented, Sep 13, 2022

Issue has been identified. I am working on a fix. 😃

0reactions
Fugashucommented, Sep 13, 2022

Issue has been identified. I am working on a fix. 😃

Thank you very much!

Read more comments on GitHub >

github_iconTop Results From Across the Web

usePrepareContractWrite - wagmi
usePrepareContractWrite gives back a "prepared config" to be sent through to ... Chain ID used to validate if the user is connected to...
Read more >
tmm/wagmi - gitwork
TrustWallet not connected with WalletConnect ... bug: lots of requests on arbitrum ... bug: usePrepareContractWrite chainId validation not working.
Read more >
The transaction declared chain ID 5777, but the connected ...
Ganache chain id is not 5777. This is network id. Network id is used by nodes to transfer data between nodes that are...
Read more >
Error: chainId address mismatch - Ethereum Stack Exchange
i'm trying to deploy a simple smart contract with node-js on a ganache-GUI but i keep getting this Error: chainId address mismatch; ...
Read more >
safe_chainid - npm
Problem Statement. At the time of writing, the chain ID is effectively the GUID of Ethereum chains, and a critical component of transaction ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found