A general-purpose Cadence contract for trading NFTs on Flow

Overview

NFT Storefront

The NFT storefront is a general-purpose Cadence contract for trading NFTs on Flow.

NFTStorefront uses modern Cadence run-time type facilities to implement a marketplace that can take any currency in order to vend any token in a safe and secure way. This means that only one instance of the contract is needed (see below for its address on Testnet and Mainnet), and its resources, transactions, and scripts can be used by any account to create any marketplace.

Contract Addresses

Name Testnet Mainnet
NFTStorefront TBD TBD

Usage

Each account that wants to offer NFTs for sale installs a Storefront, and then lists individual sales within that Storefront as SaleOffer resources.

There is one Storefront per account that handles sales of all NFT types for that account.

Each SaleOffer can list one or more cut percentages. Each cut is delivered to a predefined address. Cuts can be used to pay listing fees or other considerations.

Each NFT may be listed in one or more SaleOffer resources. The validity of each SaleOffer can easily be checked.

Purchasers can watch for SaleOffer events and check the NFT type and ID to see if they wish to buy the offered item.

Marketplaces and other aggregators can watch for SaleOffer events and list items of interest.

Comments
  • NFT Storefront revamping

    NFT Storefront revamping

    Changelog -

    • Programmatically delete all the duplicate listing if the given NFT get purchased.
    • Add a getter function that provides an array of listingResourceIDs of the duplicated listings for a provided listing ID.
    • Add a feature of expiry to the listing, If the current timestamp gets greater than the provided expiry then the listing would not allow purchase.
    • Add a function under the StorefrontManagerPublic resource to delete the expired listing for better storage hygiene.
    • Add a customID, i.e. a string that can be added by the seller in the listing so it will be easy to find out on the off-chain processes which listing belongs to whom in respect of dApps or wallets going to use storefront contract.
    • Add support for royalty in the transaction so the storefront consumes the royalty details.
    • Add a commission amount that can be grabbed by anyone who is going to facilitate the purchase.
    • Add an optional marketplaces capability support so the commission can only be transferred to the designated marketplaces instead of grabbing to anyone.
    • Complete test suite for NFTStorefrontV2.

    Open items -

    • [x] Do we want another set of transactions and scripts to support the older version of the NFTStorefront?

    • [x] Add support for running the JS test suite in the CI.

    It closes #41 #38 #40 #39 #37

    opened by satyamakgec 28
  • Check ownership of the NFT

    Check ownership of the NFT

    Currently, it allows me to list NFTs I don't own.

    https://github.com/onflow/nft-storefront/blob/1bda702c94e81ec404c8945e60a0d63652f5ca51/contracts/NFTStorefront.cdc#L261

    here should add a check if the owner of the NFT is also the owner of the storefront.

    opened by bluesign 13
  • How do I know what listings i am able to fulfill

    How do I know what listings i am able to fulfill

    As a marketplace owner for v2 storefront, how can i fetch information about what listings i can fulfill or not?

    The list of addresses that can fulfill an listing is not exposed and there is not method to check if I am allowed to do so or not.

    enhancement SC-Eng 
    opened by bjartek 10
  • Allow zero commission recipient during purchase

    Allow zero commission recipient during purchase

    Changelog -

    • Add support of providing the optional commissionRecipient during the purchase so if the commissionAmount is zero, dApp doesn't need to provide any arbitrary capability to work.
    opened by satyamakgec 2
  • Update README  to tell more about the StorefrontV2

    Update README to tell more about the StorefrontV2

    Context:

    As the new version of the storefront is added in the main branch of the nft-storefront repo then it is good to have an overview of it in the readme as well as make the viewer aware of the new version so they would not end up using the earlier version.

    Definition of Done:

    Need to update the readme and deploy the nft-storefront-v2 to testnet.

    documentation SC-Eng 
    opened by satyamakgec 2
  • Add `nftID` [and `nftType`] to `ListingCompleted` event

    Add `nftID` [and `nftType`] to `ListingCompleted` event

    Most marketplaces need to handle stale/ghost listings to provide a good UX (see discussion https://github.com/onflow/nft-storefront/issues/21). They need to remove the corresponding listings when an NFT is sold/removed through other apps. One solution for the marketplace app is to listen for ListingCompleted events and remove the listings for the corresponding NFTs in the DB/UI. The current ListingCompleted event has minimal data while ListingAvailable provides the needed nftID [and nftType] fields, so the app has to track/store both events and match the storefront/listing IDs. If we store and emit nftID [and nftType] on the contract, the marketplace's logic would be simplified.

    opened by nvdtf 2
  • read_storefront_ids.cdc: value of type Address has no member getCapability

    read_storefront_ids.cdc: value of type Address has no member getCapability

    ...
              client: rpc error: code = Unknown desc = [Error Code: 1101] cadence runtime error Execution failed:
              error: value of type `Address` has no member `getCapability`
               --> 1f5e13d13867e9926ce5d39a2e8b185bda1e1c398d85603c8880889184e6d0cf:8:9
                |
              8 |         .getCapability<&NFTStorefront.Storefront{NFTStorefront.StorefrontPublic}>(
                |          ^^^^^^^^^^^^^ unknown member
              
          occurred
    
    opened by drauschenbach 2
  • i got those errors and i dont know how to slove those

    i got those errors and i dont know how to slove those

    error: mismatched types --> 4be6dc812c12feea768bfe16c16fc28527a69b25e00b15489b7a16faa82998c9:39:22 | 39 | receiver: self.flowReceiver, | ^^^^^^^^^^^^^^^^^ expected Capability<&AnyResource{FungibleToken.Receiver}>, got Capability<&FlowToken.Vault{FungibleToken.Receiver}>

    error: mismatched types --> 4be6dc812c12feea768bfe16c16fc28527a69b25e00b15489b7a16faa82998c9:44:35 | 44 | nftProviderCapability: self.herosCollection, | ^^^^^^^^^^^^^^^^^^^^ expected Capability<&AnyResource{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>, got Capability<&IdleMysitcHeros.Collection{NonFungibleToken.Provider, IdleMysitcHeros.HerosCollectionPublic}>

    opened by fankcoder 2
  • Accept should be public function of the Contract

    Accept should be public function of the Contract

    I think accept should be a member of the Contract, and should take the saleOfferResourceID and the address as additional parameters.

    that way if everyone will have single storefront:

    • it forces a single instance of StoreFront on Path set by contract (also I think we can check path when listing, and not list if it is not on the correct public path, prevents ghost offers)
    • we can clean up sale offers after they are accepted. (no need for cleanup also accepted field will not be necessary)
    • we can emit events on the hostile sellers. (remove listings on the first failed attempt when NFT is not listed anymore ( OfferGoneAway(saleOfferResourceID) ) or cannot reach StoreFront (such as StoreGoneAway(address) )

    Those events will be useful, if there will be some dapps showing listing etc, so they can remove users or listings from their DBs

    opened by bluesign 2
  • Make Commission details accessible in V2 contract

    Make Commission details accessible in V2 contract

    Changelog -

    • Add a public function that will allow anyone to know the allowed commission receivers for a listing.
    • Emit all the allowed commission receiver's addresses in the ListingAvailable event.
    • Emit the commission beneficiary address in the ListingCompleted event.

    Resolves #50

    enhancement SC-Eng 
    opened by satyamakgec 1
  • Storefront contract is not ready for Secure Cadence release

    Storefront contract is not ready for Secure Cadence release

    Issue

    When I try to deploy NFTStorefront contract with emulator, I get the error.

    Error: thrown: "execution error code 1101: [Error Code: 1101] cadence runtime error Execution failed:
    error: cannot deploy invalid contract
     --> fd133addfe9de7559bfa6ff69d7c73d0a6e270bb9d5d54570f056d677012cdd2:7:8
      |
    7 |         acct.contracts.add(
      |         ^
    
    error: mismatched types
       --> 01cf0e2f2f715450.NFTStorefront:456:24
        |
    456 |                 return &self.listings[listingResourceID] as! &Listing{ListingPublic}
        |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `NFTStorefront.Listing{NFTStorefront.ListingPublic}`, got `NFTStorefront.Listing?`
    "
    

    Steps to reproduce

    • Install flow cli to version 0.36.0.
    • Deploy NFTStorefront contract.

    Possible solution

    Secure Cadence has been released, need to upgrade the Storefront contract to the latest Secure Cadence Version to make it work properly.

    opened by thelebster 1
  • Stable Cadence Feature Branch

    Stable Cadence Feature Branch

    Updates the storefront contracts to be compatible with stable Cadence.

    • Changes some methods to be view, so they can be used in pre-conditions and post-conditions
    • Uses the correct casting keyword as
    • Added a Go deployment test for v2 nft storefront
    • Updates go dependencies
    opened by joshuahannan 5
  • Listing via Catalog Multiple Collections Will Conflict

    Listing via Catalog Multiple Collections Will Conflict

    The sell_item_via_catalog tx here https://github.com/onflow/nft-storefront/blob/main/transactions/sell_item_via_catalog.cdc looks a bit confusing.

    On line 39 it specifies a private path for capability by

    // We need a provider capability, but one is not provided by default so we create one if needed.
    let nftCollectionProviderPrivatePath = /private/nftCollectionProviderForNFTStorefront
    

    and on line 50 it's checking if the capability exists and links the current collection identifier's collection storage to /private/nftCollectionProviderForNFTStorefront if not found.

    if !acct.getCapability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic, MetadataViews.ResolverCollection}>(nftCollectionProviderPrivatePath).check() {
        acct.link<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic, MetadataViews.ResolverCollection}>(nftCollectionProviderPrivatePath, target: value.collectionData.storagePath)
    }
    

    How does this support multiple collections? As if collection A is linked to /private/nftCollectionProviderForNFTStorefront in the first transaction and we try to list collection B, the check on line 50 will always return true as the capability exists already (but for collection A) and hence collection B will not be linked to /private/nftCollectionProviderForNFTStorefront in the second transaction.

    Furthermore, if a user is trying to sell tokenId 0 of both collection A and collection B, a user will end up selling tokenId 0 in collection A twice with the above process.

    opened by alliu930410 0
  • NFTStorefrontV2: Listing completed event does not provide information on royalties paid

    NFTStorefrontV2: Listing completed event does not provide information on royalties paid

    The ListingCompleted event lacks information on royalties paid. The self.details.saleCuts should also include the royalty receiver's cut which should be represented in the event. From simply emitting the salePrice we don't know what proportion of this amount was actually paid to the seller, and how much was paid out as royalty.

    https://github.com/onflow/nft-storefront/blob/main/contracts/NFTStorefrontV2.cdc#L75

    opened by bymi15 0
  • Authentication in testnet fails with Google Single Sign-on

    Authentication in testnet fails with Google Single Sign-on

    Steps to Reproduce

    1. Create a Dapper Wallet account using Single Sign-On with a Google account
    2. Launch testnet store front (https://flow-view-source.com/testnet/account/0x2d55b98eb200daef/contract/NFTStorefrontV2)
    3. Click Authenticate
    4. Choose Dapper Wallet
    5. On Dapper Wallet sign-in screen, select "Continue with Google"

    Expected Result

    1. I am signed in using my Google account

    Actual Result

    1. Error page with "accounts.google.com refused to connect."

    Workarounds

    1. None found
    opened by Jtango18 0
  • "error: ambiguous restricted type" while trying to deploy on emulator

    Hi,

    I'm getting this error when trying to deploy on emulator

    error: ambiguous restricted type
       --> f8d6e0586b0a20c7.NFTStorefront:350:47
        |
    350 |             nftProviderCapability: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>,
        |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    error: ambiguous restricted type
       --> f8d6e0586b0a20c7.NFTStorefront:384:47
        |
    384 |             nftProviderCapability: Capability<&{NonFungibleToken.Provider, NonFungibleToken.CollectionPublic}>,
        |                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    

    I thought it was because of some changes that I did but it also appeared when cloning from scratch.

    Any ideas?

    Thanks! any help is appreciated! 🙏

    opened by javiermanzano 1
Releases(v0.0.1)
Owner
Flow
A fast, secure, and developer-friendly blockchain built to support the next generation of games, apps, and the digital assets that power them.
Flow
A tool for design-by-contract in Go

gocontracts gocontracts is a tool for design-by-contract in Go. It generates pre- and post-condition checks from the function descriptions so that the

null 89 Nov 19, 2022
Flow-based and dataflow programming library for Go (golang)

GoFlow - Dataflow and Flow-based programming library for Go (golang) Status of this branch (WIP) Warning: you are currently on v1 branch of GoFlow. v1

Vladimir Sibirov 1.5k Nov 15, 2022
A simulated-annealing approach to solving a max-flow removal problem

RESISTANCE IS FUTILE How to run: Install the latest version of golang to your computer (1.16?) Run a postgres instance on your computer attatched to p

Anthony Ebiner 10 Aug 26, 2022
Examples on different options for implementing Flow Based Programming

Flow Based Programming This repository contains fragments and ideas related to Flow Based Programming. It shows different ways of implementing differe

Egon Elbre 10 Sep 22, 2022
General Golang Code Generator

gg gg is a General Golang Code Generator: A Good Game to play with Golang. package main import ( "fmt" . "github.com/Xuanwo/gg" ) func main() {

Xuanwo 77 Nov 2, 2022
General releases made easy for golang

release General releases made easy What it is Release is inspired to GoReleaser for automates general releases that, in most cases, does not require a

release-cli 1 Jan 7, 2022
Purpose: dump slack messages, users and files using browser token and cookie.

Slack Dumper Purpose: dump slack messages, users and files using browser token and cookie. Typical usecase scenarios: You want to archive your private

Rustam 250 Nov 21, 2022
A basic golang package for demonstration purpose.

stringutils A basic golang package for demonstration purpose. Package currently contains only one function: func Reverse(s string) string Installation

Mert Kimyonşen 0 Nov 30, 2021
Troon-NFT-Contract is deployed on Flow Blockchain, which is a white-label smart-contract for NFTs with an addition layer of Brand, Schema and Template

Overview Summary of NFTContract NFTContract is a Non Fungible Token (NFT) standard for Flow blockchain. It offers a powerful set while keeping unneces

null 0 Jan 4, 2022
After approve this contract, you can use the contract to adventure with multiple characters at the same time

MultipleRarity 又又又更新了! MultipleRarity最新版:0x8ACcaa4b940eaFC41b33159027cDBDb4A567d442 注:角色冷却时间不统一时,可以不用管能不能冒险或升级,合约内部加了筛选,但消耗的gas增加了一点点,介意的可以使用常规修复版。 Mu

medicine 34 Nov 19, 2021
Go-serverless-eth-event-listener - Go serverless, ethereum contract event listener with a sample contract

go-serverless-eth-event-listener This repository is for showing how to listen sm

Emre Ceylan 4 May 19, 2022
Running chaincode in development mode: Smart contract developers that want to iteratively develop and test their chaincode packages without the overhead of the smart contract lifecycle process for every update.

Fabric DEVMODE - Nano bash 1 ORG + 1 PEER + 1 ORDERER Based on fabric-samples/test-network-nano-bash, but using devmode fabric peer Prereqs Follow the

Kmilo Denis González 3 May 14, 2022
Hybrid Engine for emulate trading flow

Deridex Backend This is a backend implementation for Deridex market. The system

Deridex 0 Dec 15, 2021
A library for performing OAuth Device flow and Web application flow in Go client apps.

oauth A library for Go client applications that need to perform OAuth authorization against a server, typically GitHub.com. Traditionally,

GitHub CLI 350 Nov 21, 2022
A limited Flow Access API which runs outside of the Flow Network using the DPS

Access API Flow DPS implements the Flow Access API Specification, except for the following endpoints: SendTransaction GetLatestProtocolStateSnapshot G

optakt 3 Jul 28, 2022
Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.

Cadence Visit cadenceworkflow.io to learn about Cadence. This repo contains the source code of the Cadence server. To implement workflows, activities

Uber Open Source 6.4k Nov 21, 2022
Example code for my Cadence Intro Workshop

Temporal Intro Workshop This repository contains example code for my Temporal Intro Workshop. Prerequisites Git, Make, etc. Make sure you have the lat

Márk Sági-Kazár 19 Nov 21, 2022
General purpose library for reading, writing and working with OpenStreetMap data

osm This package is a general purpose library for reading, writing and working with OpenStreetMap data in Go (golang). It has the ability to read OSM

Paul Mach 240 Nov 20, 2022
General purpose library for reading, writing and working with OpenStreetMap data

osm This package is a general purpose library for reading, writing and working with OpenStreetMap data in Go (golang). It has the ability to read OSM

Paul Mach 241 Nov 25, 2022
A general purpose application and library for aligning text.

align A general purpose application that aligns text The focus of this application is to provide a fast, efficient, and useful tool for aligning text.

John Moore 78 Sep 27, 2022