forked from thirdweb-example/contracts-sdk-with-extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
54 lines (49 loc) · 1.45 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {
useContract,
ThirdwebNftMedia,
useNFTs,
Web3Button,
} from "@thirdweb-dev/react";
import styles from "../styles/Theme.module.css";
const contractAddress = "0xe0F5f8Bb09627B0A886D4CBd300Ba36cd9E522c6";
export default function Home() {
// Read the contract from the blockchain
const { contract } = useContract(contractAddress);
// Read the NFTs from the contract
const { data: nfts, isLoading: loading } = useNFTs(contract);
return (
<div className={styles.container}>
{!loading ? (
<div className={styles.nftBoxGrid}>
{nfts?.map((nft) => (
<div className={styles.nftBox} key={nft.metadata.id.toString()}>
<ThirdwebNftMedia
metadata={nft.metadata}
className={styles.nftMedia}
/>
<h3>{nft.metadata.name}</h3>
<p>Owner: {nft.owner.slice(0, 6)}</p>
</div>
))}
</div>
) : (
<p>Loading NFTs...</p>
)}
<Web3Button
colorMode="dark"
accentColor="#F213A4"
contractAddress={contractAddress}
action={(contract) =>
contract.erc721.mint({
name: "Yellow Star",
image:
"https://gateway.ipfscdn.io/ipfs/QmZbovNXznTHpYn2oqgCFQYP4ZCpKDquenv5rFCX8irseo/0.png",
})
}
onSuccess={() => alert(`🚀 Successfully Minted NFT!`)}
>
Mint NFT
</Web3Button>
</div>
);
}