@@ -155,9 +157,9 @@ const CallTest = () => {
+ outputs: [],
+ },
+ ],
-+ address: "0xEcd0D12E21805803f70de03B72B1C162dB0898d9",
++ address: CONTRACT_ADDRESS,
+ functionName: "mint",
-+ args: [1],
++ args: [BigInt(1)],
+ value: parseEther("0.01"),
+ },
+ {
@@ -193,7 +195,42 @@ Contract calls will have corresponding prompts for success and failure. If the a
![](./img/call-contract.png)
-Click **Reject**, the contract call will not be executed, and your ETH will not be consumed. In the next chapter, we will guide you to deploy a test contract and experience the complete process in the test environment. Of course, if you are very rich, you can also click OK, so that the contract call will be executed, your ETH will be consumed, and you will get an NFT.
+Click **Reject**, the contract call will not be executed, and your ETH will not be consumed. In the next chapter, we will guide you to deploy a test contract and experience the complete process in the test environment. Of course, if you are very rich, you can also click OK, so that the contract call will be executed.
+
+After the transaction is sent, you need to listen to the transaction `hash`, wait for the transaction to be confirmed, consume your ETH, and get an NFT.
+
+The code that needs to be modified is as follows:
+
+```diff
++ import { useWaitForTransactionReceipt } from 'wagmi';
+// ...
+
+const CallTest = () => {
++ const { isLoading: isConfirming, isSuccess: isConfirmed } =
++ useWaitForTransactionReceipt({
++ hash,
++ });
++
++ useEffect(() => {
++ if (isConfirmed) {
++ message.success("Mint Success");
++ result.refetch();
++ }
++ }, [isConfirmed]);
++
+ return (
+
+ {result.data?.toString()}
+
+ )
+};
+```
+
+Sending a transaction refers to the process of creating and broadcasting a transaction to the blockchain network, while transaction confirmation (transaction on-chain) means that once the transaction is verified and included in the blockchain, the transaction data is permanently recorded in the blockchain process. Once a transaction is backed up into a block and the block is added to the blockchain, the transaction data will be permanently stored in each account on the blockchain and cannot be tampered with.
Full code:
diff --git a/docs/course/dev-call-contract.zh-CN.md b/docs/course/dev-call-contract.zh-CN.md
index dbc5cdfd9..847459a39 100644
--- a/docs/course/dev-call-contract.zh-CN.md
+++ b/docs/course/dev-call-contract.zh-CN.md
@@ -67,6 +67,8 @@ const config = createConfig({
],
});
++ const CONTRACT_ADDRESS = '0xEcd0D12E21805803f70de03B72B1C162dB0898d9'
++
+ const CallTest = () => {
+ const { account } = useAccount();
+ const result = useReadContract({
@@ -79,7 +81,7 @@ const config = createConfig({
+ outputs: [{ type: 'uint256' }],
+ },
+ ],
-+ address: '0xEcd0D12E21805803f70de03B72B1C162dB0898d9',
++ address: CONTRACT_ADDRESS,
+ functionName: 'balanceOf',
+ args: [account?.address as `0x${string}`],
+ });
@@ -131,12 +133,13 @@ export default function Web3() {
const CallTest = () => {
// ...
-+ const { writeContract } = useWriteContract();
++ const { writeContract, data: hash } = useWriteContract();
return (
{result.data?.toString()}
+