-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmint.tsx
More file actions
69 lines (60 loc) · 1.69 KB
/
mint.tsx
File metadata and controls
69 lines (60 loc) · 1.69 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import { useAddress, useMetamask, useNFTDrop } from "@thirdweb-dev/react";
import type { NextPage } from "next";
import { useRouter } from "next/router";
import styles from "../styles/Home.module.css";
const Mint: NextPage = () => {
const router = useRouter();
// Get the currently connected wallet's address
const address = useAddress();
// Function to connect to the user's Metamask wallet
const connectWithMetamask = useMetamask();
// Get the NFT Collection contract
const nftDropContract = useNFTDrop(
"0x322067594DBCE69A9a9711BC393440aA5e3Aaca1"
);
async function claimNft() {
try {
const tx = await nftDropContract?.claim(1);
console.log(tx);
alert("NFT Claimed!");
router.push(`/stake`);
} catch (error) {
console.error(error);
alert(error);
}
}
async function buyToken(){
try{
window.open("https://www.coin-up.pro/en_US/trade/DHO_USDT");
}catch(error){
console.error(error);
alert(error);
}
}
return (
<div className={styles.container}>
<h1 className={styles.h1}>Buy token!</h1>
<p className={styles.explain}>
test <b>test</b> test.
</p>
<hr className={`${styles.smallDivider} ${styles.detailPageHr}`} />
{!address ? (
<button
className={`${styles.mainButton} ${styles.spacerBottom}`}
onClick={connectWithMetamask}
>
Connect Wallet
</button>
) : (
<button
className={`${styles.mainButton} ${styles.spacerBottom}`}
//onClick={() => claimNft()}
onClick={()=>buyToken()}
>
Buy token
</button>
)}
</div>
);
};
export default Mint;