Skip to content

Commit 8f1de43

Browse files
Felipe CevallosFelipe Cevallos
authored andcommitted
Optimize README for LLM ingestion and developer experience
This update enhances the README to be more discoverable and useful for both LLMs and developers by adding: - Clear project description with value proposition - Structured "What It Does" and "Who It's For" sections with skill levels - Comprehensive installation and setup instructions - 5 copy-pasteable usage examples with CLI commands and Cadence code - Complete technology stack and dependencies list - Visual project structure with inline annotations - Common integration patterns for different user types - Key concepts glossary - Security considerations - Testing instructions with commands - Enhanced contribution guidelines with development setup - SEO-optimized keywords for better discoverability - Support and community resource links These improvements make the repository more accessible to AI assistants helping developers, while also providing a better onboarding experience for human developers new to the Flow NFT Storefront standard.
1 parent d70cf3f commit 8f1de43

File tree

1 file changed

+266
-38
lines changed

1 file changed

+266
-38
lines changed

README.md

Lines changed: 266 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,289 @@
1-
# NFT Storefront Contract Standard
1+
# Flow NFT Storefront Contract Standard
22

3-
The NFT Storefront contract standard is a cornerstone of the Open Marketplace ecosystem on Flow. An open market ecosystem promotes the
4-
free flow of NFT listings across the network, emitted as events and consumed by other marketplaces (or any other consumer). Marketplaces may filter
5-
listings consumed based on commission rates they may receive. Listings may be created with variable commission, royalties or other fractional revenue, paying to multiple accounts. NFT listings are not NFTs, they are Resources which can be transacted with using the `purchase` [function](https://github.com/onflow/nft-storefront/blob/jp-update-structure/contracts/NFTStorefrontV2.cdc#L300) to obtain the token indicated by the listing.
3+
**A production-ready, non-custodial NFT marketplace smart contract standard for the Flow blockchain**
64

7-
The `NFTStorefrontV2` contract lets you create a non-custodial NFT marketplace to simplify integration with off-chain applications/UIs. The contract supports sellers who want to list and manage NFTs for sale simultaneously across any number of marketplaces. Listing expiry, orphaned and ghost listing cleanup are also of value for integrators to minimize overheads and ensure the best UX.
5+
The NFT Storefront contract is the cornerstone of Flow's Open Marketplace ecosystem, enabling peer-to-peer NFT trading with robust security guarantees, automated royalty distribution, and multi-marketplace listing support.
86

9-
Marketplaces and sellers also benefit from the robust security guarantees of Flow's account model when trading NFTs. Through this standard a NFT trade takes place from peer-to-peer, directly from the Storefront Resource in the sellers account to the purchasers account. At the same time, the standard ensures that marketplaces or other recipients may receive royalties, fees or commissions with no risk to the seller.
7+
## What It Does
108

11-
Sellers or marketplaces can optionally configure their NFTStorefront to be limited or closed. However, those wishing to participate in the Open Marketplace ecosystem on Flow are required to use the NFTStorefront standard.
9+
NFT Storefront provides a standardized way to:
10+
- **List NFTs for sale** across multiple marketplaces simultaneously from a single listing
11+
- **Execute secure peer-to-peer trades** directly from seller to buyer accounts
12+
- **Automate revenue splits** including royalties, marketplace commissions, and custom sale cuts
13+
- **Manage listing lifecycle** with expiry, ghost listing cleanup, and duplicate listing handling
14+
- **Enable marketplace interoperability** through standardized events and APIs
1215

13-
Detailed docs: [docs/documentation.md](docs/documentation.md)
14-
Flow.com docs: [NFT Storefront Standard](https://developers.flow.com/build/core-contracts/nft-storefront)
16+
## Who It's For
1517

16-
# Contract Addresses
18+
**For Marketplace Developers (Intermediate to Advanced)**
19+
- Building NFT marketplaces on Flow
20+
- Integrating existing marketplaces with the Flow ecosystem
21+
- Implementing custom marketplace logic with commission structures
1722

18-
|Name|Emulator|Testing Framework|Testnet|Previewnet|Mainnet|
19-
|----|----|------|-------|------|-------|
20-
|[NFTStorefront](contracts/NFTStorefront.cdc)| N/A | N/A |[0x94b06cfca1d8a476](https://flow-view-source.com/testnet/account/0x94b06cfca1d8a476/contract/NFTStorefront)|[0x6df5e52755433994](contracts/NFTStorefront.cdc)|[0x4eb8a10cb9f87357](https://flowscan.org/contract/A.4eb8a10cb9f87357.NFTStorefront)|
21-
|[NFTStorefrontV2 (recommended)](contracts/NFTStorefrontV2.cdc)|`0xf8d6e0586b0a20c7`| `0x0000000000000001` |[0x2d55b98eb200daef](https://flow-view-source.com/testnet/account/0x2d55b98eb200daef/contract/NFTStorefrontV2)|[0x6df5e52755433994](contracts/NFTStorefrontV2.cdc)|[0x4eb8a10cb9f87357](https://flowscan.org/contract/A.4eb8a10cb9f87357.NFTStorefrontV2)|
23+
**For NFT Project Developers (Beginner to Intermediate)**
24+
- Enabling secondary sales for your NFT collections
25+
- Implementing creator royalties
26+
- Setting up peer-to-peer trading for your community
2227

23-
# Usage
28+
**For dApp Developers (Intermediate)**
29+
- Adding NFT trading functionality to games or applications
30+
- Building hybrid custody solutions with NFT trading
2431

25-
If you'd like to test with the `NFTStorefrontV2` Smart contract on the emulator,
26-
it is automatically deployed to `0xf8d6e0586b0a20c7` or `0x0000000000000001` in the Cadence Testing Framework.
32+
## Key Features
2733

28-
If you'd like to test with the `NFTStorefrontV2` Smart contract in your project,
29-
add it to your project by using the flow dependency manager:
34+
- **Non-custodial**: NFTs remain in seller's account until purchased
35+
- **Multi-marketplace support**: List once, sell anywhere
36+
- **Automated royalties**: Built-in support for creator earnings via MetadataViews
37+
- **Flexible commissions**: Variable marketplace fees with multiple recipients
38+
- **Listing management**: Expiry dates, ghost listing cleanup, duplicate handling
39+
- **Event-driven**: Real-time listing discovery through on-chain events
40+
- **Security-focused**: Leverages Flow's account model for safe trades
3041

31-
```
42+
## Quick Start
43+
44+
### Installation
45+
46+
Install the contract dependency using Flow CLI:
47+
48+
```bash
3249
flow dependencies install mainnet://0x4eb8a10cb9f87357.NFTStorefrontV2
3350
```
3451

35-
Use the addresses mentioned above for the `emulator` and `testing` import addresses in your project's flow.json.
52+
### Contract Addresses
53+
54+
| Network | Address | Explorer |
55+
|---------|---------|----------|
56+
| **Mainnet** | `0x4eb8a10cb9f87357` | [View](https://flowscan.org/contract/A.4eb8a10cb9f87357.NFTStorefrontV2) |
57+
| **Testnet** | `0x2d55b98eb200daef` | [View](https://flow-view-source.com/testnet/account/0x2d55b98eb200daef/contract/NFTStorefrontV2) |
58+
| **Emulator** | `0xf8d6e0586b0a20c7` | - |
59+
| **Testing Framework** | `0x0000000000000001` | - |
60+
61+
### Basic Usage Examples
62+
63+
#### 1. Setup Storefront (One-time setup)
64+
65+
```bash
66+
flow transactions send ./transactions/setup_account.cdc
67+
```
68+
69+
Or using Cadence:
70+
```cadence
71+
import NFTStorefrontV2 from 0x4eb8a10cb9f87357
72+
73+
transaction {
74+
prepare(acct: auth(Storage, Capabilities) &Account) {
75+
if acct.storage.borrow<&NFTStorefrontV2.Storefront>(from: NFTStorefrontV2.StorefrontStoragePath) == nil {
76+
let storefront <- NFTStorefrontV2.createStorefront()
77+
acct.storage.save(<-storefront, to: NFTStorefrontV2.StorefrontStoragePath)
78+
79+
let cap = acct.capabilities.storage.issue<&NFTStorefrontV2.Storefront>(NFTStorefrontV2.StorefrontStoragePath)
80+
acct.capabilities.publish(cap, at: NFTStorefrontV2.StorefrontPublicPath)
81+
}
82+
}
83+
}
84+
```
85+
86+
#### 2. List an NFT for Sale
87+
88+
```bash
89+
# Basic listing
90+
flow transactions send ./transactions/sell_item.cdc \
91+
--arg Address:0xNFTReceiverAddress \
92+
--arg UInt64:1234 \
93+
--arg UFix64:10.0
94+
95+
# With marketplace commission
96+
flow transactions send ./transactions/sell_item_with_marketplace_cut.cdc \
97+
--arg Address:0xMarketplaceAddress \
98+
--arg UFix64:0.05
99+
```
100+
101+
#### 3. Purchase a Listed NFT
102+
103+
```bash
104+
flow transactions send ./transactions/buy_item.cdc \
105+
--arg UInt64:listingResourceID \
106+
--arg Address:0xStorefrontAddress
107+
```
108+
109+
#### 4. Remove a Listing
110+
111+
```bash
112+
flow transactions send ./transactions/remove_item.cdc \
113+
--arg UInt64:listingResourceID
114+
```
115+
116+
#### 5. Cleanup Ghost Listings
117+
118+
```bash
119+
flow transactions send ./transactions/cleanup_ghost_listing.cdc \
120+
--arg UInt64:listingResourceID
121+
```
122+
123+
## Technology Stack
124+
125+
- **Language**: Cadence (Flow's smart contract language)
126+
- **Blockchain**: Flow
127+
- **Standards**:
128+
- NonFungibleToken (NFT standard)
129+
- FungibleToken (payment standard)
130+
- MetadataViews (royalty standard)
131+
- **Testing**: Cadence Testing Framework
132+
- **Dependencies**:
133+
- NonFungibleToken
134+
- FungibleToken
135+
- MetadataViews
136+
- ViewResolver
137+
138+
## Project Structure
139+
140+
```
141+
nft-storefront/
142+
├── contracts/
143+
│ ├── NFTStorefrontV2.cdc # Main contract (recommended)
144+
│ ├── NFTStorefront.cdc # Legacy V1 contract
145+
│ └── utility/ # Test utilities
146+
├── transactions/
147+
│ ├── setup_account.cdc # Initialize storefront
148+
│ ├── sell_item.cdc # Create basic listing
149+
│ ├── sell_item_with_marketplace_cut.cdc # Listing with commission
150+
│ ├── buy_item.cdc # Purchase NFT
151+
│ ├── remove_item.cdc # Remove listing
152+
│ ├── cleanup_ghost_listing.cdc # Clean ghost listings
153+
│ └── cleanup_expired_listings.cdc # Clean expired listings
154+
├── scripts/
155+
│ ├── read_storefront_ids.cdc # Query all listings
156+
│ ├── read_listing_details.cdc # Get listing info
157+
│ └── has_listing_become_ghosted.cdc # Check ghost status
158+
└── tests/
159+
├── NFTStorefrontV2_test.cdc # V2 test suite
160+
└── NFTStorefrontV1_test.cdc # V1 test suite
161+
```
162+
163+
## Documentation & Resources
164+
165+
- **Detailed Documentation**: [docs/documentation.md](docs/documentation.md)
166+
- **Flow Developer Docs**: [NFT Storefront Standard](https://developers.flow.com/build/core-contracts/nft-storefront)
167+
- **Contract Source**: [NFTStorefrontV2.cdc](contracts/NFTStorefrontV2.cdc)
168+
- **GitHub Repository**: [onflow/nft-storefront](https://github.com/onflow/nft-storefront)
169+
170+
## Common Integration Patterns
171+
172+
### For Marketplace Developers
173+
174+
1. **Listen for ListingAvailable events** to discover new listings
175+
2. **Filter listings by commission requirements** that match your marketplace
176+
3. **Call purchase()** with your marketplace's commission receiver capability
177+
4. **Execute cleanupPurchasedListings()** after successful sales
178+
179+
### For NFT Projects
180+
181+
1. **Implement MetadataViews.Royalties** in your NFT contract
182+
2. **Guide users** to list using provided transactions
183+
3. **Monitor ListingAvailable events** for your NFT type
184+
4. **Promote across marketplaces** that support the standard
185+
186+
### For dApp Developers
187+
188+
1. **Create Storefront resource** for users on first sale
189+
2. **Use sell_item transaction** with your custom parameters
190+
3. **Handle multiple token types** by creating multiple listings per NFT
191+
4. **Implement cleanup logic** for better UX
192+
193+
## Running Tests
194+
195+
```bash
196+
# Run all tests
197+
flow test tests/NFTStorefrontV2_test.cdc
198+
199+
# Start emulator for manual testing
200+
flow emulator start
201+
202+
# Deploy contracts to emulator
203+
flow project deploy --network emulator
204+
```
205+
206+
## Key Concepts
207+
208+
- **Storefront**: Account-level resource that manages all listings for a seller
209+
- **Listing**: Individual NFT sale offer with price, cuts, and conditions
210+
- **SaleCut**: Payment split sent to specific address (royalties, commissions, seller)
211+
- **Ghost Listing**: Listing without underlying NFT (should be cleaned up)
212+
- **Commission Receiver**: Marketplace capability that receives commission on sale
213+
214+
## Security Considerations
215+
216+
- NFTs never leave seller account until purchase completes
217+
- All payment splits execute atomically in single transaction
218+
- Expired listings automatically prevent purchases
219+
- Ghost listing detection prevents failed transactions
220+
- Capability-based access control ensures proper authorization
221+
222+
## Migration from V1 to V2
223+
224+
NFTStorefrontV2 adds:
225+
- Listing expiry functionality
226+
- Ghost listing detection and cleanup
227+
- Improved marketplace commission handling
228+
- Better duplicate listing management
229+
- Enhanced event emissions
230+
231+
See migration guide: [V1 to V2 Migration](docs/documentation.md#migration)
232+
233+
## SEO Keywords & Topics
234+
235+
Flow blockchain, NFT marketplace, Cadence smart contracts, non-custodial NFT trading, NFT storefront, Flow NFT standard, marketplace integration, creator royalties, peer-to-peer NFT sales, Flow dApp development, NFT listing management, multi-marketplace NFT, Flow NFT API, blockchain marketplace development, NFT trading platform, Flow ecosystem, secondary NFT sales
236+
237+
## Contributing
238+
239+
We welcome contributions! Please follow these guidelines:
240+
241+
1. **Fork the repository** and create a feature branch
242+
2. **Write tests** for new functionality
243+
3. **Follow Cadence best practices** and style guidelines
244+
4. **Update documentation** for any API changes
245+
5. **Submit a pull request** with clear description
246+
247+
### Development Setup
248+
249+
```bash
250+
# Clone repository
251+
git clone https://github.com/onflow/nft-storefront.git
252+
cd nft-storefront
253+
254+
# Install Flow CLI (if not installed)
255+
sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
256+
257+
# Install dependencies
258+
flow dependencies install
259+
260+
# Run tests
261+
flow test tests/
262+
```
263+
264+
## Support & Community
265+
266+
- **Issues**: [GitHub Issues](https://github.com/onflow/nft-storefront/issues)
267+
- **Discord**: [Flow Discord](https://discord.gg/flow)
268+
- **Developer Portal**: [Flow Developers](https://developers.flow.com)
36269

37-
Detailed docs for how to manage listings are available on
38-
[the flow developer docs website](https://developers.flow.com/build/core-contracts/nft-storefront)
270+
## License
39271

40-
# Brief Overview
272+
The works in these files are licensed under the [Apache License 2.0](LICENSE).
41273

42-
Each account that wants to offer NFTs for sale installs a `Storefront`,
43-
and then lists individual sales within that `Storefront` as `Listing` resources.
274+
## Authors & Maintainers
44275

45-
There is one `Storefront` per account that handles sales of all NFT types
46-
for that account.
276+
Maintained by the Flow Foundation and community contributors.
47277

48-
Each `Listing` can list one or more cut percentages.
49-
Each cut is delivered to a predefined address.
50-
Cuts can be used to pay listing fees or other considerations.
278+
**Core Contributors**:
279+
- Flow Foundation Team
280+
- Community developers
51281

52-
Each NFT may be listed in one or more `Listing` resources.
53-
The validity of each `Listing` can easily be checked.
282+
## Version History
54283

55-
Purchasers can watch for `Listing` events and check the NFT type and
56-
ID to see if they wish to buy the offered item.
284+
- **V2 (Current)**: Enhanced features with expiry, ghost listing management, improved events
285+
- **V1 (Legacy)**: Original storefront implementation (still supported on mainnet)
57286

58-
Marketplaces and other aggregators can watch for `Listing` events
59-
and list items of interest.
287+
---
60288

61-
See further docs and examples on [the developer docs site](https://developers.flow.com/build/core-contracts/nft-storefront).
289+
*Built on Flow - The blockchain for open worlds*

0 commit comments

Comments
 (0)