bug: usePrepareContractWrite chainId validation not working
See original GitHub issueIs 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?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Issue has been identified. I am working on a fix. 😃
Thank you very much!