You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I start learn new viem+wagmi.
I have project with below dependencies:
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.5",
"@mui/icons-material": "^5.14.1",
"@mui/material": "^5.14.1",
"@web3modal/ethereum": "^2.4.1",
"@web3modal/react": "^2.4.1",
"buffer": "^6.0.3",
"env-cmd": "^10.1.0",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.7.0",
"tss-react": "^4.3.4",
"util": "^0.12.4",
"viem": "^0.3.50",
"wagmi": "^1.3.9"
},
When it was old version of wagmi I use ethers and useContract hook for wait for confirming transaction and it's work perfectly.
Something like this. I was able invoke approve and stake through 1 button.
let allowance = Number(ethers.utils.formatEther(await TokenProvider?.allowance(address, STAKE_ADDRESS)))
while (allowance < TokenToStake!) {
const approve = await TokenSigner?.approve(STAKE_ADDRESS, ethers.utils.parseEther(TokenToStake!.toString()));
setSpinner(true);
await approve.wait(); // HERE WE WAITING
allowance = Number(ethers.utils.formatEther(await TokenProvider?.allowance(address, STAKE_ADDRESS)))
}
const tx = await StakeSigner?.stake(ethers.utils.parseEther(TokenToStake!.toString()), activeButton)
setSpinner(true);
await tx.wait();
But now we don't have useContract, we don't have ethers. So, what should I do? I need somehow wait until user give to my SC approve and only then invoke function in SC. How I can do this now?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I start learn new viem+wagmi.
I have project with below dependencies:
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@fontsource/roboto": "^5.0.5",
"@mui/icons-material": "^5.14.1",
"@mui/material": "^5.14.1",
"@web3modal/ethereum": "^2.4.1",
"@web3modal/react": "^2.4.1",
"buffer": "^6.0.3",
"env-cmd": "^10.1.0",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.7.0",
"tss-react": "^4.3.4",
"util": "^0.12.4",
"viem": "^0.3.50",
"wagmi": "^1.3.9"
},
When it was old version of wagmi I use ethers and useContract hook for wait for confirming transaction and it's work perfectly.
Something like this. I was able invoke approve and stake through 1 button.
let allowance = Number(ethers.utils.formatEther(await TokenProvider?.allowance(address, STAKE_ADDRESS)))
while (allowance < TokenToStake!) {
const approve = await TokenSigner?.approve(STAKE_ADDRESS, ethers.utils.parseEther(TokenToStake!.toString()));
setSpinner(true);
await approve.wait(); // HERE WE WAITING
allowance = Number(ethers.utils.formatEther(await TokenProvider?.allowance(address, STAKE_ADDRESS)))
}
const tx = await StakeSigner?.stake(ethers.utils.parseEther(TokenToStake!.toString()), activeButton)
setSpinner(true);
await tx.wait();
But now we don't have useContract, we don't have ethers. So, what should I do? I need somehow wait until user give to my SC approve and only then invoke function in SC. How I can do this now?
Beta Was this translation helpful? Give feedback.
All reactions