Hot answers tagged

4 votes
Accepted

How to get provider using rainbowkit wallet if connected via walletconnect or coinbase

Figured it out. I had to use signer object to get provider. import { useSigner } from 'wagmi'; const {data: signer} = useSigner(); const web3 = new Web3((signer?.provider as any).provider);
bbusdriver's user avatar
  • 1,144
3 votes

Using Wagmi Core and Wagmi React together

The Wagmi React documentation has an entry for this. While Akrhip's answer is correct and you can use two clients - you can end up in bad situations (especially if you're specifiying different ...
Nasco Bozhkov's user avatar
3 votes

WAGMI useContractWrite() hook unresponsive/not working

In usePrepareContractWrite() I have written contractInterface: abi it should be abi: abi
ameymeow's user avatar
  • 115
2 votes

How to get provider using rainbowkit wallet if connected via walletconnect or coinbase

Use the useProvider() hook as detailed in the docs 😉
Antonio U's user avatar
  • 649
2 votes

Front End: Transfer (send) your NFTs (ERC-721) using Ethers.js or Wagmi.sh

Here is an implementation, in plain JavaScript that you can steal for this: https://nft.life Just click on Batch Transfer ERC-721.
William Entriken's user avatar
2 votes

what is the right way to read from the contract? using wagmi.sh

You can use refetch from useContractRead const { refetch: refetchProjects } = useContractRead({ address: contractAddress, abi: abi.abi, functionName: "getAllProjects", ...
Paulo Bordignon's user avatar
2 votes
Accepted

what is the right way to read from the contract? using wagmi.sh

You should add the watch param to the useContractRead hook so that it continously fetches the new value of the counter const {data:CounterValue,isError,isLoading} = useContractRead({ address:&...
Mila A's user avatar
  • 693
2 votes
Accepted

Wagmi useWaitForTransaction not waiting long enough?

have you tried with const results = await tokenA.connect(signer).approve(poolData.address, amount); await results.wait() Hope it helps
donoso.eth's user avatar
  • 1,423
2 votes

How to get receipt in wagmi / viem for a transaction issued with Safe on walletconnect?

While this problem must be addressed on the connected library's side (eg inside a viem walletClient and transparently passed through to the public client's interface), we decided to build a package ...
elmariachi's user avatar
2 votes
Accepted

Deployed a contract using Remix need to access the abi and function whie developing frontend

You can verify the contract with the help of remix itself. On the bottom left corner you will see the plugin buttton, clicking on that and search verify, then activate the plugin and after compiling ...
Zartaj Afser's user avatar
  • 3,229
1 vote

wagmi error write() undefined

Found the solution, my problem is that usePrepareContractWrite was returning an error: WARN [ContractFunctionExecutionError: The contract function "makePayment" reverted with the following ...
Agustin Gonzalez Ribas's user avatar
1 vote
Accepted

wagmi - Error handling for writeContract action using Vanilla JS?

you can utilize try-catch blocks and conditionally check for specific error cases. async function mint() { if (window.ethereum) { const finney = 1000000000000000; let qty = ...
Mehran Ra's user avatar
  • 545
1 vote
Accepted

Wagmi useSigner hook doesn't work when url has a query parameter in a Next JS project

The issue has been resolved, the only thing that needs to be done here is that const {chains, provider, webSocketProvider} = configureChains( [polygonMumbai], [ alchemyProvider({...
Suhel Kapadia's user avatar
1 vote

If a call to contract B depends on some state in contract A, can I send both transactions in the same block?

Well, you can't know for a fact that your first transaction (i.e. the approve) will be included in the same block than the second transaction (i.e. the mint), and you won't know which transaction is ...
Olivier Demeaux's user avatar
1 vote
Accepted

Ethers.js solidityPackedKeccak256 to bytes32

Looks like the issue is not with the encodedSalt as solidityPackedKeccak256 returns already the bytes32 hex string. You first parameter 3 is also expected to be bytes32 const foo = 3; const fooBytes32 ...
tenbits's user avatar
  • 2,094
1 vote
Accepted

Smart Contract's ABI has uint256, but I get error `Type 'number' is not assignable to type 'BigNumber'

The Error you pasted seems a bit unrelated to the description. The error shows that you are calling method isClaimed(uint256,uint256) with data=0x. Perhaps you are making a call somewhere to that ...
Jacobo Lansac's user avatar
1 vote

How to pass dynamic arguments to usePrepareContractWrite in Wagmi?

Use actions instead of hooks: import { prepareWriteContract, writeContract } from 'wagmi/actions'
Tusken's user avatar
  • 11
1 vote

Two wagmi's usePrepareContractWrite( ) in a single React functional component

You can have as many usePrepareContractWrite() and useContractWrite() hooks as you need within a NextJS component while destructuring to renamed fields. You can change the names of destructured object ...
PSS's user avatar
  • 537
1 vote
Accepted

Failing to trying to approve contract using ethers.js (CALL_EXCEPTION or cannot estimate gas)

Make your approval approve for max amount. const approve = async (e) => { e.preventDefault() try { const token = new ethers.Contract( TOKEN_ADDRESS, erc20ABI, ...
Iulian's user avatar
  • 640
1 vote

Can I connect an address and sign a transaction from nodejs without a browser in Wagmi core

Install ethers lib: npm install ethers Send transaction: // connect provider const provider = new ethers.ethers.providers.JsonRpcProvider(YOUR_RPC_URL); // connect your signer const signer = new ...
0xcuonghx's user avatar
  • 131
1 vote
Accepted

What is the difference between 'watch' and 'cacheOnBlock' in the WAGMI library

When using the useContractRead() hook, there are a few options that tell it how often to fetch data from the blockchain. The documentation which you linked outlines it pretty well. watch is going to ...
jon.bray.eth's user avatar
1 vote

example of HD Wallet injection into RainbowKit

Working on the same issue. This repo from wagmi lead dev is a starting point. https://github.com/tmm/testing-wagmi Still working on rainbowkit integration into tests. @brightiron seems to have it all ...
Ivelin Ivanov's user avatar
1 vote

Passing dynamic arguments to usePrepareContractWrite in Wagmi

Basically, @deepak-sharma has got some things right but his useEffect will trigger an infinite loop and we can also make it a bit better by using a useDebounce (as recommended in wagmi's docs). import ...
DavNej's user avatar
  • 11
1 vote
Accepted

Populating the write args with wagmi usePrepareContractWrite

You can use useState for something this like this, just throwing code together didnt test.... import React, { useState } from 'react'; function Example() { // Declare a new state variable, which we'...
Stackaccount1's user avatar
1 vote
Accepted

Front End: Transfer (send) your NFTs (ERC-721) using Ethers.js or Wagmi.sh

If a contract implements ERC721, it will have the safeTransferFrom function. There are special cases, like CryptoKitties, that were deployed before the ERC-721 standard existed. But not all NFTs are ...
jpozzi's user avatar
  • 126
1 vote
Accepted

How to pass arguments in useContractWrite wagmi

tyou dont pass the args to the write function, you pass it in the useContractWrite hook like so const { write: mint } = useContractWrite({ ...contractConfig, functionName: 'mint', args: [...
AbuUsama's user avatar
  • 170

Only top scored, non community-wiki answers of a minimum length are eligible