Getting started

Our tutorials show how to build with the marketplace-api using the Typescript SDK. However, all the routes can be accessed directly as described in the API reference documentation. You can experience the provided experience on our demo.

Both ERC721 and ERC1155 NFT collections can be quickly registered and a ready-to-use marketplace can be bootstrapped in minutes.

The easiest way to set up your marketplace is to use our boilerplate. It can be easily configured for your collection once you have registered it on your new project.

Intallation

To add the marketplace SDK to your project, you can use npm or yarn:

npm install @cometh/marketplace-sdk
yarn add @cometh/marketplace-sdk

The SDK works both in the browser and in Node. The available functions are described in detail in the SDK reference documentation. In any case, we advise using the SDK documentation to explore route typings as it is more explicit.

Creating a project

To use Cometh Connect, the first step is to get your api keys at https://app.cometh.io. If this is your first time using Cometh Connect, please reach out so we can set you up with a Connect account and apiKey.

When creating a new project, choose the NFT marketplace feature.

You can also add an NFT marketplace scope to an existing project by switching product scope in your existing project.

When setuping the project you will need to choose a network. If you don't see your network in the list, don't hesitate to contact us so we can add it.

Get your API Keys

On your dashboard, you can click the apiKey button to access all your project's credentials.

You now have your project API key, congrats ! It will be used in your front-end to authenticate public API calls

Initializing the SDK

When initializing your SDK, you need to pass the API url as well as the key for your project. The url corresponding to your project's network can be found on the API cheatsheet.

const networkApiUrl = 'https://api.marketplace.prod.core.cometh.tech/v1/doc'

const marketplaceSdk = new MarketplaceSdk({
  BASE: networkApiUrl,
  HEADERS: {
    apikey: 'YOUR_API_KEY'
  }
})

Getting a user's assets

Once our system has finished indexing your registered collection, we can easily search assets based on various criteria. For example, you can search all the assets owned by your logged in user.

const assetsSearch = await marketplaceSdk.asset.searchAssets({
  owner: userAddress,
  contractAddress: MY_COLLECTION_ADDRESS
})

const nbAssets = assetsSearch.total
const userAssets = assetsSearch.assets

Next steps

Building a marketplace will require to implement the different order operations supported by the API, mainly creating and filling orders.

If you want to expand your core knowledge of our marketplace system, we advise having a look at Core concepts.

To continue building, you will need to look at:

Last updated