ReservoirKit is a react package that makes it easy to add buying NFTs into your dApp. It's intuitive, responsive and customizable.

Overview

@reservoir0x/reservoir-kit

ReservoirKit is the official Reservoir Protocol UI Kit. You can choose to use the prebuilt UI or create your own UI while utilizing the logic layer.

Installing ReservoirKit

yarn add @reservoir0x/reservoir-kit-ui

Also make sure to install the peer dependencies required by ReservoirKit if your application doesn't already include them:

yarn add wagmi ethers react react-dom

Configuring Reservoir Kit UI

{ Your App } ">
import {
  ReservoirKitProvider,
  darkTheme,
} from '@reservoir0x/reservoir-kit-ui'
import { WagmiConfig } from 'wagmi'

const wagmiClient = ...

const theme = darkTheme({
  headlineFont: "Sans Serif",
  font: "Serif",
  primaryColor: "#323aa8",
  primaryHoverColor: "#252ea5",
})


  

    { Your App }

  

The sample code above is all you need to get started with ReservoirKit. Let's break it down step by step. Start by importing the ReservoirKitProvider which is needed for configuring ReservoirKit. Also import a theme of your choice, we provide a lightTheme and a darkTheme. Next we import the WagmiConfig, Wagmi is a peer dependency of ReservoirKit.

Now that we have all the imports ready we can continue by creating a theme. As mentioned previously we have a few preloaded themes with the ability to override some variables, like colors and fonts. Learn more about theming options here.

Next we wrap our app with the ReservoirKitProvider and pass it some options. The only required option is the apiBase, which we point to the production Reservoir hosted API endpoint. We also pass in the theme we previously set up. Now we need to make sure we wrap our application in the WagmiConfig. Follow the instructions in their docs to set up the WagmiClient and then pass it into the WagmiConfig. Finally nest your application code within the ReservoirKitProvider and the WagmiConfig.

Theming

ReservoirKit provides 2 preconfigured themes, darkMode and lightMode. They can be used as is or configured with some additional overrides:

const theme = darkTheme({
  headlineFont: "Sans Serif",
  font: "Serif",
  primaryColor: "#323aa8",
  primaryHoverColor: "#252ea5",
})

Click here for a full list of overrides.

If that isn't enough customization you can also create a completely custom ReservoirKitTheme.

const theme: ReservoirKitTheme = {
  radii: { ... },
  fonts: { ... },
  colors: { ... }
}

BuyModal

ReservoirKit provides a simple to configure modal for facilitating token purchases in your react app. Below is an example of a simple BuyModal setup.

console.log('Purchase Complete')} />">
import { BuyModal } from '@reservoir0x/reservoir-kit-ui'


      Buy Token
    
  }
  collectionId="0xf5de760f2e916647fd766b4ad9e85ff943ce3a2b"
  tokenId="1236715"
  onComplete={() => console.log('Purchase Complete')}
/>

Let's dive into the parameters. You'll need to provide an element to trigger the modal, this can be any valid html element. Next you'll want to provide a collectionId and a tokenId. These can be set to undefined until the data is ready. Finally you can set an optional callback when the purchase is complete, where you can refresh the data, give your use a success message, etc.

Custom BuyModal

The BuyModal also comes with a custom renderer which can be used to just get the data layer that the BuyModal uses internally to handle the underlying business logic. With the renderer you can rebuild the UI completely to your liking. Below is an example of how it works in practice.

import { BuyModal, BuyStep } from '@reservoir0x/reservoir-kit-ui'


  {({
    token,
    collection,
    totalPrice,
    referrerFee,
    buyStep,
    transactionError,
    hasEnoughEth,
    txHash,
    feeUsd,
    totalUsd,
    ethUsdPrice,
    isBanned,
    balance,
    address,
    etherscanBaseUrl,
    buyToken,
    setBuyStep,
  }) => {
    { Your Custom React Elements }
  })}

The custom BuyModal take a few parameters like before with one additional one being the open parameter. This is because there is no trigger, you have control over what sort of modal you want this to eventually live in and how to trigger that modal. You'll have the ability to add a custom button with a custom handler, etc. The custom BuyModal then passes some key data into the children which we parse above and use in our custom UI. It's also important to note the BuyStep here which is used to manage the internal state of the BuyModal's logic. You can decide to use all or some of the data passed into your custom implementation.

Comments
  • doesn't build

    doesn't build

    reservoir-kit$ yarn build

    @parcel/transformer-typescript-types: Cannot find module '../modal/list/ListModalRenderer' or its corresponding type declarations.

    /home/steve/Documents/GitHub/mavrik/reservoir-kit/packages/ui/src/hooks/useListingPreapprovalCheck.ts:4:26 3 | import { Marketplace } from './useMarketplaces'

    4 | import { Listings } from '../modal/list/ListModalRenderer' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cannot find module '../modal/list/ListModalRenderer' or its corresponding type declarations. 5 | import { useSigner } from 'wagmi' 6 | import { Execute } from '@reservoir0x/reservoir-kit-client'

    @parcel/transformer-typescript-types: Cannot find module './modal/buy/BuyModal' or its corresponding type declarations.

    /home/steve/Documents/GitHub/mavrik/reservoir-kit/packages/ui/src/index.ts:20:26 19 | //Components

    20 | export { BuyModal } from './modal/buy/BuyModal' | ^^^^^^^^^^^^^^^^^^^^^^^ Cannot find module './modal/buy/BuyModal' or its corresponding type declarations. 21 | export { BuyStep } from './modal/buy/BuyModalRenderer' 22 |

    @parcel/transformer-typescript-types: Cannot find module './modal/buy/BuyModalRenderer' or its corresponding type declarations.

    /home/steve/Documents/GitHub/mavrik/reservoir-kit/packages/ui/src/index.ts:21:25 20 | export { BuyModal } from './modal/buy/BuyModal'

    21 | export { BuyStep } from './modal/buy/BuyModalRenderer' | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Cannot find module './modal/buy/BuyModalRenderer' or its corresponding type declarations. 22 | 23 | export { ListModal } from './modal/list/ListModal'

    @parcel/transformer-typescript-types: Cannot find module './modal/list/ListModal' or its corresponding type declarations.

    /home/steve/Documents/GitHub/mavrik/reservoir-kit/packages/ui/src/index.ts:23:27 🚨 Build failed.

    @parcel/core: Failed to resolve './modal/buy/BuyModal' from './packages/ui/src/index.ts'

    /home/steve/Documents/GitHub/mavrik/reservoir-kit/packages/ui/src/index.ts:20:26 19 | //Components

    20 | export { BuyModal } from './modal/buy/BuyModal' | ^^^^^^^^^^^^^^^^^^^^^^^ 21 | export { BuyStep } from './modal/buy/BuyModalRenderer' 22 |

    @parcel/resolver-default: Cannot load file './modal/buy/BuyModal' in './packages/ui/src'. 💡 Did you mean './Modal/buy/BuyModal'? 💡 Did you mean './Modal/Modal'?

    [email protected]:~/Documents/GitHub/mavrik/reservoir-kit$ yarn run build:fix-type-defs Fix bad imports in d.ts files… Fixed: [ {} ] [email protected]:~/Documents/GitHub/mavrik/reservoir-kit$ yarn build mv: cannot stat 'tsconfig.production.json': No such file or directory [email protected]:~/Documents/GitHub/mavrik/reservoir-kit$

    opened by sgehrman 8
  • Confusing UI

    Confusing UI

    Hey,

    Some product feedback, the Same Profit and Custom tabs are quite confusing. I'm not actually what they even do. I'm guessing one is how much I earn before fees and one is after fees, but I'm not really sure (till I look at the code). May want to remove these tabs or rename them to something more clear.

    image
    opened by elie222 4
  • Support for multiple fee recipients

    Support for multiple fee recipients

    The API supports splitting fees when listing: https://github.com/reservoirprotocol/indexer/issues/1540

    And will soon support it for bids: https://github.com/reservoirprotocol/indexer/issues/1596

    This package expects a string for these fields however. Not sure if the types will update once the API is updated. Happy to contribute a PR here too (I can imagine some other parts of this package will break once feeRecipient supports both string and string[]).

    image
    opened by elie222 2
  • Order Asks Query Type should support multiple Ids

    Order Asks Query Type should support multiple Ids

    The API validation schema supports both single id and an array of ids as per:

    https://github.com/reservoirprotocol/indexer/blob/bbfef603a849b16326ea75e955b767872cf7920f/src/api/endpoints/orders/get-orders-asks/v4.ts#L38

    also querying logic supports ids arrays as per:

    https://github.com/reservoirprotocol/indexer/blob/bbfef603a849b16326ea75e955b767872cf7920f/src/api/endpoints/orders/get-orders-asks/v4.ts#L247

    Client side types currently do not support an array of Ids as per:

    https://github.com/reservoirprotocol/reservoir-kit/blob/f65aa84145191a5942a97cefd11c055b9ce2045a/packages/sdk/src/types/api.ts#L5374

    opened by newts6 1
  • Updated deprecated apis used in hooks/modals

    Updated deprecated apis used in hooks/modals

    Updated the following hooks:

    • useBids
    • useListings
    • useOwnerListings
    • useCollectionActivity
    • useUserTopBids
    • useUsersActivity

    Impacted the following modals:

    • CancelBidModal
    • AcceptBidModal
    opened by pedromcunha 1
  • API returns outdated sell order

    API returns outdated sell order

    I'm getting an error when trying to buy this asset

    https://www.reservoir.market/0x8b82367b242eaa8f5c5fe35bd7d29d16a981f2a0/7

    The error also happens when buying directly on the reservoir site

    After investigation noticed that the API route returns the wrong Ask data from foundation

    https://api.reservoir.tools/orders/asks/v3?token=0x8b82367b242eaa8f5c5fe35bd7d29d16a981f2a0%3A7&includePrivate=false&includeMetadata=false&includeRawData=false&normalizeRoyalties=false&sortBy=createdAt&limit=50

    The api returns a 0.5 eth price while in the foundation website, the current price is 2.04

    https://foundation.app/@ashten/ngnm/7

    opened by yelouafi 1
  • Convert bps fee to wei price when buying

    Convert bps fee to wei price when buying

    • Convert bps fee to atomic unit in BuyModalRenderer before calling buyToken
    • BREAKING: Remove global referrerFee and referrerRecipient due to difficulty calculating fee without price and currency in buyToken method.
    opened by pedromcunha 1
  • error calling listing api with client package

    error calling listing api with client package

    Error: cannot estimate gas; transaction may fail or may require manual gas limit [ See: https://links.ethers.org/v5-errors-UNPREDICTABLE_GAS_LIMIT ] (error={"reason":"cannot estimate gas; transaction may fail or may require manual gas limit","code":"UNPREDICTABLE_GAS_LIMIT","error":{"code":-32000,"message":"gas required exceeds allowance (1541)"},

    const { createClient} = require("@reservoir0x/reservoir-kit-client"); const HDWalletProvider = require("@truffle/hdwallet-provider") const { ethers } = require("ethers"); const web3provider = new HDWalletProvider(privateKey, url); var provider = new ethers.providers.Web3Provider(web3provider) var wallet = new ethers.Wallet(privateKey); singer = wallet.connect(provider)

    const client = createClient({
        apiBase: "https://api.reservoir.tools",
        apiKey: apiKey,
        source: source
      });
    
    const result = await client.actions.listToken({
        listings: listing,
        signer: signer,
        // options: options,
      })
    
    opened by infra403 3
Owner
Reservoir Protocol
Reservoir Protocol
Web3-nft-dapp-tutorial - A simple web3 app for minting NFTs

Web3 - Full Tutorial The demo contains a basic web3 app and smart contract for m

Fireship 198 Dec 10, 2022
Dinos-nft-minting-dapp - A nice and easy way for linking an existing NFT smart contract to this minting dapp

Welcome to HashLips ?? All the code in these repos was created and explained by

EtherCluster 1 Jan 6, 2022
Basic Dapp showing how a React Dapp can connect to Cronos using MetaMask and Crypto.com Defi Wallet

cronos-dapp-basic Basic Dapp showing how a React Dapp can connect to Cronos using MetaMask and Crypto.com Defi Wallet You need to have node version 14

Acclrate 1 Dec 27, 2021
Create-dapp-solana-nextjs - Scaffolding for a Solana dapp using TS, Next.JS, Tailwinds CSS, and Daisy UI

Create Solana Dapp with Next.JS Want to start develop with Solana fetching NFTs

Thug DAO 295 Jan 6, 2023
Dapp-core-components - A library that holds the core logic of a dapp on the Elrond Network with an example to get started easily

A library that holds the core logic of a dapp on the Elrond Network with an example to get started easily

Elrond Network 4 Jan 6, 2023
Re-developed the Sky Ice Cream website using ReactJS. Redesigned the UI to a much more appealing and intuitive styling.

This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: npm start Runs the app in the developmen

Aakash Jana 1 Dec 27, 2021
Braian D. Vaylet 17 Oct 22, 2022
A NextJS, Tailwind, TRPC, Prisma, and NextAuth Starter Project that makes getting an app up and running as easy as possible

A NextJS, Tailwind, TRPC, Prisma, and NextAuth Starter Project that makes getting an app up and running as easy as possible

Kelly Copley 41 Dec 15, 2022
React package that is an Ergo dApp Connector. Current supported wallets are Nautilus Wallet and SafeW.

Ergo dApp Connector React Package Table of Contents About The Project Built With Getting Started Prerequisites Installation Usage Contributing License

null 6 Jun 7, 2022
Fluent Blocks makes it easy to use Fluent & UI Kit designs in app development.

Fluent Blocks makes it easy to use Fluent & UI Kit designs in app development. This repository provides a set of packages developers can use to build

Office Developer 19 Nov 22, 2022
A growing collection of responsive Chakra UI Templates ready to drop into your React project.

A growing collection of responsive Chakra UI Templates ready to drop into your React project.

Achim Rolle 1.2k Jan 2, 2023
A fun Buildspace project to mint NFTs on Solana using Metaplex.

minty-metaplex A project I built by following along with the Buildspace Solana/Metaplex project instructions. Thanks Buildspace! Prerequisites Unless

Nick Taylor 21 Aug 16, 2022
Eth-time - ETH Time - A new NFT collection created to explore new ways of generating NFTs on-chain

ETH Time ETH Time is a new NFT collection created to explore new ways of generat

null 3 Jan 25, 2022
An npm package that lets you jump right into coding React and Redux with universal (isomorphic) rendering. Only manage Express setups or Webpack configurations if you want to.

Universal Redux What and Why Universal Redux is an npm package that when used as a dependency in your project provides a universal (isomorphic) render

Buck DeFore 462 May 22, 2022
A boilerplate template for making your awesome dApp on IoTeX and ETH, BSC, and other possible chains

Bounties ?? Please notice: If you have your own custom project and you want to r

IoTeX Network 70 Nov 26, 2022
A boilerplate template for making your awesome dApp on IoTeX and ETH, BSC

IoTeX dApp Sample V2 This is a boilerplate template for making your awesome dApp on IoTeX and ETH, BSC, and other possible chains (request here) Techn

yalamber 0 Nov 9, 2021
Connect2IC - A toolkit which makes it trivial to support any wallet or identity provider, and make authenticated calls to canisters.

Connect2IC - A toolkit which makes it trivial to support any wallet or identity provider, and make authenticated calls to canisters.

null 65 Dec 6, 2022
This starter template comes as a monorepo for your next fullstack dApp Development

This starter template comes as a monorepo for your next fullstack dApp Development. This will be your tools: ?? React + Vite + Typescript ?? Solidity + Hardhat + Typescript

Johannes 23 Nov 13, 2022
Rohan Kokkula 101 Dec 25, 2022