forked from metaplex-foundation/js-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.jsx
47 lines (41 loc) · 1.24 KB
/
App.jsx
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
import React, { useState } from 'react';
import { Metaplex } from '@metaplex-foundation/js';
import { clusterApiUrl, Connection, PublicKey } from '@solana/web3.js';
import './App.css';
const connection = new Connection(clusterApiUrl('devnet'));
const mx = Metaplex.make(connection);
function App() {
const [address, setAddress] = useState(
'3ijFZcJKmp1EnDbbuaumWYvEFbztx9NRupwTXTchK9bP',
);
const [nft, setNft] = useState(null);
const fetchNft = async () => {
const asset = await mx.nfts().findByMint({ mintAddress: new PublicKey(address) });
setNft(asset);
};
return (
<div className="App">
<div className="container">
<h1 className="title">NFT Mint Address</h1>
<div className="nftForm">
<input
type="text"
value={address}
onChange={(event) => setAddress(event.target.value)}
/>
<button onClick={fetchNft}>Fetch</button>
</div>
{nft && (
<div className="nftPreview">
<h1>{nft.name}</h1>
<img
src={nft.json.image}
alt="The downloaded illustration of the provided NFT address."
/>
</div>
)}
</div>
</div>
);
}
export default App;