diff --git a/docs/course/contract-compile-deploy.zh-CN.md b/docs/course/contract-compile-deploy.zh-CN.md index 42e50aace..0ea69bce2 100644 --- a/docs/course/contract-compile-deploy.zh-CN.md +++ b/docs/course/contract-compile-deploy.zh-CN.md @@ -39,7 +39,7 @@ order: 3 ## 部署 -点击 `Deploy&Run` 可以将将交易发送到当前的 `ENVIRONMENT` 中。 +点击 `Deploy&Run` 可以将交易发送到当前的 `ENVIRONMENT` 中。 接下来我们尝试通过 MetaMask 部署合约到测试网 Goerli 中,请先将你的 MetaMask 切换到测试网 Goerli(当然你也可以切换到其它你习惯使用的测试网)。 diff --git a/docs/course/contract-dapp.md b/docs/course/contract-dapp.md index 655833f56..e575544bf 100644 --- a/docs/course/contract-dapp.md +++ b/docs/course/contract-dapp.md @@ -19,11 +19,11 @@ In addition to the address, we also need to switch to the testnet. The specific ```diff import { createConfig, http, useReadContract, useWriteContract } from "wagmi"; - import { mainnet } from "wagmi/chains"; -+ import { mainnet, goerli } from "wagmi/chains"; ++ import { mainnet, sepolia } from "wagmi/chains"; import { WagmiWeb3ConfigProvider, MetaMask, -+ Goerli, ++ Sepolia, } from "@ant-design/web3-wagmi"; import { Address, @@ -38,10 +38,10 @@ import { parseEther } from "viem"; const config = createConfig({ - chains: [mainnet], -+ chains: [mainnet, goerli], ++ chains: [mainnet, sepolia], transports: { [mainnet.id]: http(), -+ [goerli.id]: http(), ++ [sepolia.id]: http(), }, connectors: [ injected({ @@ -50,6 +50,9 @@ const config = createConfig({ ], }); +- const CONTRACT_ADDRESS = "0xEcd0D12E21805803f70de03B72B1C162dB0898d9"; ++ const CONTRACT_ADDRESS = "0x81BaD6F768947D7741c83d9EB9007e1569115703"; // use your own contract address + const CallTest = () => { const { account } = useAccount(); const result = useReadContract({ @@ -62,17 +65,28 @@ const CallTest = () => { outputs: [{ type: "uint256" }], }, ], -- address: "0xEcd0D12E21805803f70de03B72B1C162dB0898d9", -+ address: "0x418325c3979b7f8a17678ec2463a74355bdbe72c", // use your own contract address + address: CONTRACT_ADDRESS, functionName: "balanceOf", args: [account?.address as `0x${string}`], }); - const { writeContract } = useWriteContract(); + const { data: hash, writeContract } = useWriteContract(); + 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()} +
+ ) +}; +``` + +发送交易是指创建并向区块链网络发送一笔交易的过程,而交易被确认(交易上链)是指一旦交易被验证并包含在区块中,该交易数据被永久记录在区块链上的过程。一旦交易被打包到区块中,该区块被添加到区块链上,交易数据就被永久保存在区块链的分布式账本中,不可篡改。 最终完整的代码如下: diff --git a/docs/course/dev-connect.md b/docs/course/dev-connect.md index a2703b026..844cb578a 100644 --- a/docs/course/dev-connect.md +++ b/docs/course/dev-connect.md @@ -46,7 +46,7 @@ The introduction of the content is as follows: - [createConfig](https://wagmi.sh/react/config): wagmi is used to create the method of configuration. - http: wagmi is used to create the method of [HTTP JSON RPC](https://wagmi.sh/core/api/transports/http) connection. Through it, you can access the blockchain through HTTP request. -- [mainnet](https://wagmi.sh/react/chains): represents the Ethereum mainnet. In addition to `mainnet`, there will be other testnets similar to `goerli` and other EVM-compatible public chains similar to `bsc` and `base`. Some are L1 public chains like Ethereum, and some are L2 public chains. We will not go into details here. +- [mainnet](https://wagmi.sh/react/chains): represents the Ethereum mainnet. In addition to `mainnet`, there will be other testnets similar to `sepolia` and other EVM-compatible public chains similar to `bsc` and `base`. Some are L1 public chains like Ethereum, and some are L2 public chains. We will not go into details here. - [WagmiWeb3ConfigProvider](https://web3.ant.design/components/wagmi#wagmiweb3configproviderprops): Ant Design Web3 is the Provider used to receive wagmi configuration. Then create the configuration: diff --git a/docs/course/dev-connect.zh-CN.md b/docs/course/dev-connect.zh-CN.md index 152c3632c..ec7960359 100644 --- a/docs/course/dev-connect.zh-CN.md +++ b/docs/course/dev-connect.zh-CN.md @@ -46,7 +46,7 @@ export default function Web3() { - [createConfig](https://wagmi.sh/react/config):wagmi 用来创建配置的方法。 - http:wagmi 用来创建 [HTTP JSON RPC](https://wagmi.sh/core/api/transports/http) 连接的方法,通过它你可以通过 HTTP 请求访问区块链。 -- [mainnet](https://wagmi.sh/react/chains):代表以太坊主网,除了 `mainnet` 以外还会有类似 `goerli` 的测试网和类似 `bsc` 和 `base` 的 EVM 兼容的其它公链,有的是和以太坊一样的 L1 公链,有的是 L2 公链,这里先暂不展开。 +- [mainnet](https://wagmi.sh/react/chains):代表以太坊主网,除了 `mainnet` 以外还会有类似 `sepolia` 的测试网和类似 `bsc` 和 `base` 的 EVM 兼容的其它公链,有的是和以太坊一样的 L1 公链,有的是 L2 公链,这里先暂不展开。 - [WagmiWeb3ConfigProvider](https://web3.ant.design/components/wagmi-cn#wagmiweb3configproviderprops):Ant Design Web3 用来接收 wagmi 配置的 Provider。 接着创建配置: diff --git a/docs/course/img/mint-test-net.png b/docs/course/img/mint-test-net.png index b506cc59d..47760d3d1 100644 Binary files a/docs/course/img/mint-test-net.png and b/docs/course/img/mint-test-net.png differ