Skip to content

Commit

Permalink
add multiwrite
Browse files Browse the repository at this point in the history
'
  • Loading branch information
0xquantum3labs committed Apr 26, 2024
1 parent 7380c6c commit 048f6e7
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 1,248 deletions.
18 changes: 17 additions & 1 deletion packages/nextjs/components/stake/StakeContractInteraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ethers } from "ethers";
import humanizeDuration from "humanize-duration";
import { uint256 } from "starknet-dev";
import { BigNumberish } from "starknet";
import { useScaffoldMultiContractWrite } from "~~/hooks/scaffold-stark/useScaffoldMultiContractWrite";

export const StakeContractInteraction = () => {
const { address: connectedAddress } = useAccount();
Expand Down Expand Up @@ -66,6 +67,21 @@ export const StakeContractInteraction = () => {
functionName: "withdraw",
});

const {writeAsync: stakeEth} = useScaffoldMultiContractWrite({
calls: [
{
contractName: "Eth",
functionName: "approve",
args: [StakerContract?.address ?? "",10 ** 14],
},
{
contractName: "Challenge1",
functionName: "stake",
args: [10 ** 14],
}
]
})

const wrapInTryCatch =
(fn: () => Promise<any>, errorMessageFnDescription: string) => async () => {
try {
Expand Down Expand Up @@ -158,7 +174,7 @@ export const StakeContractInteraction = () => {
</div>
<button
className="btn btn-primary uppercase text-base-100"
onClick={wrapInTryCatch(stakeStark, "stakeETH")}
onClick={wrapInTryCatch(stakeEth, "stakeETH")}
>
🥩 Stake 0.5 ether!
</button>
Expand Down
Loading

0 comments on commit 048f6e7

Please sign in to comment.