Skip to content
Open
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
0ce5e68
Create readme.md
Mosamorphing Oct 15, 2024
9001155
Update readme.md
Mosamorphing Oct 15, 2024
968cdb0
Create next-init-page.png
Mosamorphing Oct 15, 2024
5a1d099
Add files via upload
Mosamorphing Oct 15, 2024
49b9984
Merge branch 'WTFAcademy:main' into main
Mosamorphing Oct 31, 2024
32a7327
Update readme.md
Mosamorphing Nov 7, 2024
c8c0e2e
Add files via upload
Mosamorphing Nov 7, 2024
6c821e0
Update readme.md
Mosamorphing Nov 7, 2024
b397f2a
Update readme.md
Mosamorphing Nov 7, 2024
28bb3ae
Add files via upload
Mosamorphing Nov 7, 2024
e69c433
Update readme.md
Mosamorphing Nov 7, 2024
695c590
Create Web3.tsx
Mosamorphing Nov 7, 2024
b201f12
Create Web3.tsx
Mosamorphing Nov 7, 2024
72286cd
Create readme.md
Mosamorphing Nov 7, 2024
57793c4
Create faucet.png
Mosamorphing Nov 7, 2024
c47196b
Add files via upload
Mosamorphing Nov 7, 2024
86c3159
Create readme.md
Mosamorphing Nov 7, 2024
42c7ea4
Create connect.png
Mosamorphing Nov 7, 2024
7ad6344
Add files via upload
Mosamorphing Nov 7, 2024
8688fd4
Create Web3.tsx
Mosamorphing Nov 7, 2024
e48759d
Create readme.md
Mosamorphing Nov 7, 2024
1719674
Create metamask.png
Mosamorphing Nov 7, 2024
dc8244c
Add files via upload
Mosamorphing Nov 7, 2024
3576a8c
Create readme.md
Mosamorphing Nov 7, 2024
7df8b7d
Create Web3.tsx
Mosamorphing Nov 7, 2024
4ca95b5
Create Web3.tsx
Mosamorphing Nov 7, 2024
0e1310b
Add files via upload
Mosamorphing Nov 7, 2024
6471fa4
Update readme.md
Mosamorphing Nov 7, 2024
801b2ea
Update readme.md
Mosamorphing Nov 7, 2024
a91bfdd
Update readme.md
Mosamorphing Nov 7, 2024
4fdacac
Update readme.md
Mosamorphing Nov 7, 2024
0e42342
Create readme.md
Mosamorphing Nov 7, 2024
59aa147
Update readme.md
Mosamorphing Nov 7, 2024
bca70dc
Create createnew.png
Mosamorphing Nov 7, 2024
576e25f
Add files via upload
Mosamorphing Nov 7, 2024
fd553fd
Update readme.md
Mosamorphing Nov 7, 2024
e956587
Create readme.md
Mosamorphing Nov 7, 2024
8b9e281
Create remix.png
Mosamorphing Nov 7, 2024
d5d50d7
Add files via upload
Mosamorphing Nov 7, 2024
aca0921
Update readme.md
Mosamorphing Nov 7, 2024
655a975
Update readme.md
Mosamorphing Nov 7, 2024
93709f8
Create MyToken.sol
Mosamorphing Nov 7, 2024
705cd61
Update MyToken.sol
Mosamorphing Nov 7, 2024
4a0db7d
Create readme.md
Mosamorphing Nov 8, 2024
f26ae02
Create connect1.png
Mosamorphing Nov 8, 2024
086b794
Add files via upload
Mosamorphing Nov 8, 2024
a442acc
Create Web3.tsx
Mosamorphing Nov 8, 2024
c213e51
Create readme.md
Mosamorphing Nov 8, 2024
cdf62a5
Create Web3.tsx
Mosamorphing Nov 8, 2024
8d419b2
Create demo.png
Mosamorphing Nov 8, 2024
6e10641
Add files via upload
Mosamorphing Nov 8, 2024
fdb6e7b
Create readme.md
Mosamorphing Nov 8, 2024
773127c
Create walletconnect.png
Mosamorphing Nov 8, 2024
d42c522
Add files via upload
Mosamorphing Nov 8, 2024
a6c3a51
Create Web3.tsx
Mosamorphing Nov 8, 2024
0c8eed4
Update readme.md
Mosamorphing Nov 8, 2024
812cd05
Create readme.md
Mosamorphing Nov 8, 2024
ab6b551
Create Web3.tsx
Mosamorphing Nov 8, 2024
8a17bd4
Create image.png
Mosamorphing Nov 8, 2024
4e7b65e
Add files via upload
Mosamorphing Nov 8, 2024
fd138c0
Create readme.md
Mosamorphing Nov 8, 2024
7e32b05
Create demo.png
Mosamorphing Nov 11, 2024
8dc6b77
Add files via upload
Mosamorphing Nov 11, 2024
85c92af
Create readme.md
Mosamorphing Nov 11, 2024
ec96757
Update readme.md
Mosamorphing Nov 11, 2024
da04bc5
Create send.png
Mosamorphing Nov 11, 2024
b542ecb
Add files via upload
Mosamorphing Nov 11, 2024
81dd076
Create readme.md
Mosamorphing Nov 11, 2024
06247a9
Create localnode.png
Mosamorphing Nov 11, 2024
5ba4c01
Add files via upload
Mosamorphing Nov 11, 2024
0bebb85
Create readme.md
Mosamorphing Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Create Web3.tsx
  • Loading branch information
Mosamorphing authored Nov 8, 2024
commit ab6b551bd660b5242667da542e0d679ccd70d67c
136 changes: 136 additions & 0 deletions languages/en/11_MultipleChain/Web3.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { createConfig, http, useReadContract, useWriteContract } from "wagmi";
import { mainnet, sepolia, polygon } from "wagmi/chains";
import {
WagmiWeb3ConfigProvider,
MetaMask,
Sepolia,
Polygon,
} from "@ant-design/web3-wagmi";
import {
Address,
NFTCard,
Connector,
ConnectButton,
useAccount,
useProvider,
} from "@ant-design/web3";
import { injected } from "wagmi/connectors";
import { Button, message } from "antd";
import { parseEther } from "viem";

const config = createConfig({
chains: [mainnet, sepolia, polygon],
transports: {
[mainnet.id]: http(),
[sepolia.id]: http(),
[polygon.id]: http(),
},
connectors: [
injected({
target: "metaMask",
}),
],
});

const contractInfo = [
{
id: 1,
name: "Ethereum",
contractAddress: "0xEcd0D12E21805803f70de03B72B1C162dB0898d9",
},
{
id: 5,
name: "Sepolia",
contractAddress: "0x418325c3979b7f8a17678ec2463a74355bdbe72c",
},
{
id: 137,
name: "Polygon",
contractAddress: "0x418325c3979b7f8a17678ec2463a74355bdbe72c",
},
];

const CallTest = () => {
const { account } = useAccount();
const { chain } = useProvider();
const result = useReadContract({
abi: [
{
type: "function",
name: "balanceOf",
stateMutability: "view",
inputs: [{ name: "account", type: "address" }],
outputs: [{ type: "uint256" }],
},
],
address: contractInfo.find((item) => item.id === chain?.id)
?.contractAddress as `0x${string}`,
functionName: "balanceOf",
args: [account?.address as `0x${string}`],
});
const { writeContract } = useWriteContract();

return (
<div>
{result.data?.toString()}
<Button
onClick={() => {
writeContract(
{
abi: [
{
type: "function",
name: "mint",
stateMutability: "payable",
inputs: [
{
internalType: "uint256",
name: "quantity",
type: "uint256",
},
],
outputs: [],
},
],
address: contractInfo.find((item) => item.id === chain?.id)
?.contractAddress as `0x${string}`,
functionName: "mint",
args: [1],
value: parseEther("0.01"),
},
{
onSuccess: () => {
message.success("Mint Success");
},
onError: (err) => {
message.error(err.message);
},
}
);
}}
>
mint
</Button>
</div>
);
};

export default function Web3() {
return (
<WagmiWeb3ConfigProvider
config={config}
chains={[Sepolia, Polygon]}
wallets={[MetaMask()]}
>
<Address format address="0xEcd0D12E21805803f70de03B72B1C162dB0898d9" />
<NFTCard
address="0xEcd0D12E21805803f70de03B72B1C162dB0898d9"
tokenId={641}
/>
<Connector>
<ConnectButton />
</Connector>
<CallTest />
</WagmiWeb3ConfigProvider>
);
}