generated from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from SWF2023-HongikIngan:feature/smart-contrac…
…t-func-impl map , detail, true coin done
- Loading branch information
Showing
4 changed files
with
121 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import styled from "@emotion/styled"; | ||
import { Button } from "@mui/material"; | ||
import { useAccount } from "wagmi"; | ||
import { useScaffoldContractWrite } from "~~/hooks/scaffold-eth"; | ||
|
||
const FactButton = styled.div` | ||
width: 126px; | ||
height: 36px; | ||
border-radius: 30px; | ||
background: #000; | ||
color: #fff; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: 12px; | ||
font-weight: 600; | ||
cursor: pointer; | ||
`; | ||
|
||
// export default function Writer({ cid }) { | ||
export default function Writer({ contractName, functionName, args, text }) { | ||
// const { address, isConnecting, isDisconnected } = useAccount(); | ||
const { writeAsync, isLoading, isMining } = useScaffoldContractWrite({ | ||
contractName: contractName, | ||
functionName: functionName, | ||
args: [...args], | ||
// For payable functions, expressed in ETH | ||
value: "0", | ||
// The number of block confirmations to wait for before considering transaction to be confirmed (default : 1). | ||
blockConfirmations: 1, | ||
// The callback function to execute when the transaction is confirmed. | ||
onBlockConfirmation: txnReceipt => { | ||
console.log("Transaction blockHash", txnReceipt.blockHash); | ||
}, | ||
}); | ||
|
||
async function Write() { | ||
await writeAsync(); | ||
} | ||
|
||
return <FactButton onClick={Write}>{text}</FactButton>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters