Skip to content

Commit b7d2c39

Browse files
committed
add token-api-nft-components with initial setup and example components
1 parent 43ebfa7 commit b7d2c39

File tree

14 files changed

+2416
-0
lines changed

14 files changed

+2416
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ For more information, visit [www.thegraph.com/docs](https://www.thegraph.com/doc
3838
- [**token-api-quickstart**](./token-api/token-api-quickstart): Provides examples for integrating The Graph's Token API directly via React and through Cursor MCP. Covers token balances, transfers, and multi-chain support. (last updated May 2025)
3939
- [**token-api-scaffold-eth**](./token-api/token-api-scaffold-eth): Demonstrates integrating The Graph's Token API with Scaffold ETH to accelerate development of full-stack decentralized applications. (last updated May 2025)
4040
- [**token-api-tax-demo**](./token-api/token-api-tax-demo): Shows how to pull wallet balances, historical inventory, transfers, and price data from The Graph Token API for tax and accounting, using a lightweight HTML, CSS, JavaScript, and Express proxy. (last updated May 2025)
41+
- [**token-api-nft-components](./token-api/token-api-nft-components/) Five copy/paste components that feature Token API's NFT features. (Last updated June 2025)
4142

4243
## License
4344

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Token-API NFT React Components
2+
3+
A super-lightweight set of **five** React components that surface common NFT data from the [Token API](https://token-api.thegraph.com/).
4+
Each component lives in a single file, has **zero runtime dependencies** (besides `react`) and can be copy-pasted straight into any React project.
5+
6+
## Components
7+
8+
| Component | Description | API Docs |
9+
|-----------|-------------|----------|
10+
| `ActivityFeed.jsx` | Latest mints / transfers / burns for a collection | [API →](https://token-api.service.pinax.network/#tag/evm/GET/nft/activities/evm) |
11+
| `CollectionStatsBadge.jsx` | High-level stats for a collection (supply, owners, transfers) | [API →](https://token-api.service.pinax.network/#tag/evm/GET/nft/collections/evm/%7Bcontract%7D) |
12+
| `NFTTopHolders.jsx` | Top addresses ranked by number of tokens held | [API →](https://token-api.service.pinax.network/#tag/evm/GET/nft/holders/evm/%7Bcontract%7D) |
13+
| `NFTWalletHoldings.jsx` | All NFTs owned by a wallet | [API →](https://token-api.service.pinax.network/#tag/evm/GET/nft/ownerships/evm/%7Baddress%7D) |
14+
| `RecentMintsTable.jsx` | Recent mint events for a collection | [API →](https://token-api.service.pinax.network/#tag/evm/GET/nft/activities/evm) |
15+
16+
## Quick Start (2 minutes)
17+
18+
1. **Get your JWT Token**
19+
- Visit [The Graph Marketplace](https://marketplace.thegraph.com/)
20+
- Get your JWT token for authenticated API access
21+
- Higher rate limits than public endpoints
22+
23+
2. **Create `.env` file in your project root:**
24+
```bash
25+
# .env
26+
VITE_TOKEN_API_JWT_KEY=your_jwt_token_here # For Vite
27+
# or
28+
REACT_APP_TOKEN_API_JWT_KEY=your_jwt_token_here # For Create React App
29+
```
30+
31+
3. **Copy & Use Components**
32+
```jsx
33+
// Example: App.jsx
34+
import ActivityFeed from "./components/ActivityFeed";
35+
import CollectionStatsBadge from "./components/CollectionStatsBadge";
36+
37+
export default function App() {
38+
return (
39+
<div>
40+
<CollectionStatsBadge />
41+
<ActivityFeed />
42+
</div>
43+
);
44+
}
45+
```
46+
47+
## Example Contract Addresses
48+
49+
Try these example addresses to see the components in action:
50+
51+
- **NFT Collection:** `0xbd3531da5cf5857e7cfaa92426877b022e612cf8` (Pudgy Penguins)
52+
- **Wallet Address:** `0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045` (vitalik.eth)
53+
54+
## Features
55+
56+
- 🔒 Secure authentication with JWT
57+
- 🚀 Zero dependencies (just React)
58+
- 📱 Responsive & mobile-friendly
59+
- 🎨 Clean, minimal styling
60+
- 🔗 Direct links to API docs
61+
- ⚡ Instant copy & paste setup
62+
63+
## Component Features
64+
65+
Each component includes:
66+
- Pre-filled example addresses
67+
- Loading & error states
68+
- Network selection (mainnet active, others coming soon)
69+
- Direct links to API documentation
70+
- Clean, minimal styling that's easy to customize
71+
72+
## Environment Setup
73+
74+
The components support both Vite and Create React App:
75+
76+
```bash
77+
# For Vite projects
78+
VITE_TOKEN_API_JWT_KEY=your_jwt_token_here
79+
80+
# For Create React App projects
81+
REACT_APP_TOKEN_API_JWT_KEY=your_jwt_token_here
82+
```
83+
84+
## API Documentation
85+
86+
Each component links directly to its API documentation. Click the "API Docs ↗" link in any component's header to view the full API details.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Token-API NFT Demo</title>
7+
</head>
8+
<body>
9+
<header style="max-width:960px;margin:0 auto;padding:24px;font-family:sans-serif;">
10+
<h1 style="margin-top:0">NFT Portfolio Dashboard (Demo)</h1>
11+
<p>All data is fetched from The Graph's Token&nbsp;API.
12+
Read the API <a href="https://token-api.thegraph.com/#tag/evm" target="_blank" rel="noopener">here</a> and the Quickstart guide <a href="https://thegraph.com/docs/en/token-api/quick-start/" target="_blank" rel="noopener">here</a>.
13+
</p>
14+
<p style="font-size:0.9rem;color:#555;">Use these example addresses to try the widgets. More chains will be added soon — currently only Ethereum Mainnet is supported.</p>
15+
<ul style="font-size:0.9rem;">
16+
<li><strong>Wallet NFT Explorer example EOA:</strong> 0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045</li>
17+
<li><strong>NFT Collection Explorer example contract:</strong> 0xbd3531da5cf5857e7cfaa92426877b022e612cf8</li>
18+
</ul>
19+
<p style="font-size:0.8rem;color:#666;">Copy any component from <code>/components</code> into your own project and provide your JWT key from <a href="https://marketplace.thegraph.com/" target="_blank" rel="noopener">The&nbsp;Graph Marketplace</a> in <code>.env</code>.</p>
20+
<hr style="margin:32px 0;" />
21+
</header>
22+
<div id="root"></div>
23+
<script type="module" src="/src/main.jsx"></script>
24+
</body>
25+
</html>

0 commit comments

Comments
 (0)