【问题标题】:Contract is not an nft drop thirdweb合约不是nft drop thirdweb
【发布时间】:2022-12-12 13:48:27
【问题描述】:

我正在尝试通过 thirdweb 在我的下一个应用程序中使用我的合同。但是我收到错误 “错误:合约不是 nft-drop”。 当我转到 thirdweb 仪表板并复制并粘贴完全相同的代码时,我仍然收到错误。我怎样才能解决这个问题?

代码

import { useContract } from '@thirdweb-dev/react'

export default function Component() {
  const { contract } = useContract("<My contract address>", "nft-drop")

  // Now you can use the nft drop contract in the rest of the component
}

我正在使用来自 thirdweb react 文档 https://portal.thirdweb.com/sdk/interacting-with-contracts/nft-drop#getting-the-contract-in-your-application 的 useContract 钩子

但是我仍然收到错误,我该如何解决?

【问题讨论】:

    标签: reactjs next.js thirdweb


    【解决方案1】:

    您的错误很容易修复。确认您正在使用 NextJs 和 nft drop 合约。

    你想做的是

    import {
      useContract
    } from "@thirdweb-dev/react";
    
    const Home: NextPage = () => {
      const {
        contract
      } = useContract("Put your nft drop contract here")
    // You do not need to specify if it is an Nft drop contact the way you did. All you need to do is just paste in the Contract address and thirdweb does the rest
    }

    现在你可以使用你的 Nft drop 合约了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-08-12
      • 2022-08-14
      • 2021-10-18
      • 2021-08-28
      • 2022-09-25
      • 2021-11-23
      • 1970-01-01
      • 2021-10-09
      相关资源
      最近更新 更多