@net-protocol/bazaar 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,198 @@
1
+ # @net-protocol/bazaar
2
+
3
+ **Status: Alpha** - Usable but may have breaking changes over time. Suitable for early adopters and testing.
4
+
5
+ NFT marketplace SDK for Net Protocol - read listings, collection offers, and ERC20 offers via Seaport.
6
+
7
+ ## What is Net Bazaar?
8
+
9
+ Net Bazaar is a decentralized NFT marketplace built on Net Protocol. It uses Seaport for order execution and Net Protocol for order storage and indexing.
10
+
11
+ **Key features:**
12
+ - **NFT Listings**: Buy and sell NFTs with native currency
13
+ - **Collection Offers**: Make offers on any NFT in a collection
14
+ - **ERC20 Offers**: Make offers to buy ERC20 tokens (Base and HyperEVM only)
15
+
16
+ ## What can you do with this package?
17
+
18
+ - **Read listings**: Get valid NFT listings for a collection
19
+ - **Read collection offers**: Get valid offers for any NFT in a collection
20
+ - **Read ERC20 offers**: Get valid offers for ERC20 tokens
21
+ - **Cancel orders**: Prepare transactions to cancel your listings or offers
22
+
23
+ This package provides both React hooks (for UI) and a client class (for non-React code).
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ npm install @net-protocol/bazaar @net-protocol/core viem
29
+ # or
30
+ yarn add @net-protocol/bazaar @net-protocol/core viem
31
+ ```
32
+
33
+ For React hooks, also install:
34
+ ```bash
35
+ npm install react wagmi @tanstack/react-query
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ### React Hooks
41
+
42
+ ```typescript
43
+ import { useBazaarListings, useBazaarCollectionOffers, useBazaarErc20Offers } from "@net-protocol/bazaar/react";
44
+
45
+ // Get NFT listings for a collection
46
+ function ListingsComponent() {
47
+ const { listings, isLoading, error } = useBazaarListings({
48
+ chainId: 8453,
49
+ nftAddress: "0x...",
50
+ });
51
+
52
+ if (isLoading) return <div>Loading...</div>;
53
+
54
+ return (
55
+ <div>
56
+ {listings.map((listing) => (
57
+ <div key={listing.orderHash}>
58
+ Token #{listing.tokenId}: {listing.price} {listing.currency}
59
+ </div>
60
+ ))}
61
+ </div>
62
+ );
63
+ }
64
+
65
+ // Get collection offers
66
+ function CollectionOffersComponent() {
67
+ const { offers, isLoading } = useBazaarCollectionOffers({
68
+ chainId: 8453,
69
+ nftAddress: "0x...",
70
+ });
71
+
72
+ const bestOffer = offers[0]; // Sorted by price, highest first
73
+ return <div>Best offer: {bestOffer?.price} {bestOffer?.currency}</div>;
74
+ }
75
+
76
+ // Get ERC20 offers (Base and HyperEVM only)
77
+ function Erc20OffersComponent() {
78
+ const { offers, isLoading } = useBazaarErc20Offers({
79
+ chainId: 8453,
80
+ tokenAddress: "0x...",
81
+ });
82
+
83
+ const bestOffer = offers[0]; // Sorted by price per token, highest first
84
+ return (
85
+ <div>
86
+ Best offer: {bestOffer?.pricePerToken} {bestOffer?.currency} per token
87
+ </div>
88
+ );
89
+ }
90
+ ```
91
+
92
+ ### BazaarClient (Non-React)
93
+
94
+ ```typescript
95
+ import { BazaarClient } from "@net-protocol/bazaar";
96
+
97
+ const client = new BazaarClient({ chainId: 8453 });
98
+
99
+ // Get listings
100
+ const listings = await client.getListings({
101
+ nftAddress: "0x...",
102
+ });
103
+
104
+ // Get collection offers
105
+ const collectionOffers = await client.getCollectionOffers({
106
+ nftAddress: "0x...",
107
+ });
108
+
109
+ // Get ERC20 offers (Base and HyperEVM only)
110
+ const erc20Offers = await client.getErc20Offers({
111
+ tokenAddress: "0x...",
112
+ });
113
+
114
+ // Cancel a listing
115
+ const cancelTx = client.prepareCancelListing(listing);
116
+ // Use with wagmi's useWriteContract or viem's writeContract
117
+ ```
118
+
119
+ ## API Reference
120
+
121
+ ### Types
122
+
123
+ ```typescript
124
+ interface Listing {
125
+ maker: `0x${string}`;
126
+ nftAddress: `0x${string}`;
127
+ tokenId: string;
128
+ priceWei: bigint;
129
+ price: number;
130
+ currency: string;
131
+ expirationDate: number;
132
+ orderHash: string;
133
+ orderStatus: SeaportOrderStatus;
134
+ messageData: `0x${string}`;
135
+ orderComponents?: SeaportOrderComponents;
136
+ }
137
+
138
+ interface CollectionOffer {
139
+ maker: `0x${string}`;
140
+ nftAddress: `0x${string}`;
141
+ priceWei: bigint;
142
+ price: number;
143
+ currency: string;
144
+ expirationDate: number;
145
+ orderHash: string;
146
+ orderStatus: SeaportOrderStatus;
147
+ messageData: `0x${string}`;
148
+ orderComponents?: SeaportOrderComponents;
149
+ }
150
+
151
+ interface Erc20Offer {
152
+ maker: `0x${string}`;
153
+ tokenAddress: `0x${string}`;
154
+ tokenAmount: bigint;
155
+ priceWei: bigint;
156
+ pricePerTokenWei: bigint;
157
+ price: number;
158
+ pricePerToken: number;
159
+ currency: string;
160
+ expirationDate: number;
161
+ orderHash: `0x${string}`;
162
+ orderStatus: SeaportOrderStatus;
163
+ messageData: `0x${string}`;
164
+ orderComponents?: SeaportOrderComponents;
165
+ }
166
+ ```
167
+
168
+ ### Validation
169
+
170
+ All returned listings and offers are automatically validated:
171
+ - Order status is OPEN (not filled, cancelled, or expired)
172
+ - Not expired
173
+ - For listings: seller still owns the NFT
174
+ - For offers: buyer has sufficient WETH balance
175
+
176
+ ### Sorting
177
+
178
+ - **Listings**: Sorted by price (lowest first), deduplicated per token
179
+ - **Collection offers**: Sorted by price (highest first)
180
+ - **ERC20 offers**: Sorted by price per token (highest first)
181
+
182
+ ## Supported Chains
183
+
184
+ | Chain | Listings | Collection Offers | ERC20 Offers |
185
+ |-------|----------|-------------------|--------------|
186
+ | Base (8453) | Yes | Yes | Yes |
187
+ | Base Sepolia (84532) | Yes | Yes | No |
188
+ | Degen (666666666) | Yes | Yes | No |
189
+ | Ham (5112) | Yes | Yes | No |
190
+ | Ink (57073) | Yes | Yes | No |
191
+ | Unichain (130) | Yes | Yes | No |
192
+ | HyperEVM (999) | Yes | Yes | Yes |
193
+ | Plasma (9745) | Yes | Yes | No |
194
+ | Monad (143) | Yes | Yes | No |
195
+
196
+ ## License
197
+
198
+ MIT