React SDK

useContract

Hook for creating an ethers Contract instance for the given Mintdrop drop.

import { useContract } from "@mintdrop/sdk"

Usage

import { useContract } from "@mintdrop/sdk"

const Example = () => {
  const contract = useContract()

  const handleMint = () => {
    contract
      .publicMint(1)
      .then((receipt) => console.log("Tx Receipt", receipt))
      .catch((err) => console.error("Error during mint", err))
  }

  return (
    <div>
      <button onClick={handleMint}>Mint!</button>
    </div>
  )
}

Returns

contract: Contract

Note

This requires the use of a MintdropProvider in order to access the proper context.

import { MintdropProvider } from "@mintdrop/sdk"

const App = () => {
  return (
    <MintdropProvider drop="123">
      <MyComp />
    </MintdropProvider>
  )
}