CollectButton

Leverage the CollectButton to easily add minting and sweeping to your app

Prerequisites ⚙️

Install and configure ReservoirKit.

CollectButton

ReservoirKit provides a simple to configure button for facilitating sweeping and minting tokens in your react app. The CollectButton automatically detects if a given collection or token is minting and handles rendering the MintModal or SweepModal for you. Below is an example of a simple CollectButton setup.

import { CollectButton } from '@reservoir0x/reservoir-kit-ui'

<CollectButton
  contract={contract}
	onConnectWallet={onConnectWallet}
/>

Let's dive into the parameters:

PropDescriptionRequired
onConnectWalletA function that opens the connect wallet flow. Use this to prompt your connect modal and continue the ux of connecting the user's wallet.Y
contractThe contract address of the collection you wish to purchase from. Can be undefined until the data is ready.

Note: A contract, collectionId or token is required
N
collectionIdThe collection id of the collection you wish to purchase from. Can be undefined until the data is ready.

Note: A contract, collectionId or token is required
N
tokenThe token you wish to purchase from. Can be undefined until the data is ready.

Format: 0x8d04a8c79ceb0889bdd12acdf3fa9d207ed3ff63:704
Note: A contract, collectionId or token is required
N
chainIdThe chain id to force the modal to render, ensure that this is a chain that is configured in the ReservoirKit provider. If not specified then the active chain configured in the ReservoirKitProvider will be used.N
optionalMintModalPropsThe props that are passed into the MintModal. These parameters can be viewed on the MintModal docs.N
optionalSweepModalPropsThe props that are passed into the SweepModal. These parameters can be viewed on the SweepModal docs.N
triggerCssAn inline style prop override that's applied to the triggerN
swrOptionsSWR infinite configuration optionsN
customTriggerRendererA function to handle rendering your own custom trigger. All of the underlying data that the default CollectButton uses is provided for you.N

Custom CollectButton

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

import { CollectButton } from '@reservoir0x/reservoir-kit-ui'

<CollectButton.Custom
	onConnectWallet={onConnectWallet}
  contract={contract}>
  {({
     loading,
     publicMintData,
     mintStages,
     collection,
     tokenData,
  }) => {
    { Your Custom React Elements }
  })}
</CollectButton.Custom>

The custom CollectButton takes in the same parameters as before. You'll then have access to the data that the CollectButton uses internally and can use all or some of that data in your custom implementation.

👍

Nice job!

Now that we've added a CollectButton to your dApp, let's customize the theme to match your brand.