跳到主要内容

thirdweb

Create Contract

想使用 thirdweb 命令行创建新的智能合约,请按照以下步骤操作:

  1. In your CLI run the following command:

    npx thirdweb create contract
  2. Input your preferences for the command line prompts:

    1. Give your project a name
    2. Choose your preferred framework: Hardhat or Foundry
    3. Name your smart contract
    4. Choose the type of base contract: Empty, ERC20, ERC721, or ERC1155
    5. Add any desired extensions
  3. Once created, navigate to your project’s directory and open in your preferred code editor.

  4. If you open the contracts folder, you will find your smart contract; this is your smart contract written in Solidity.

    The following is code for an ERC721Base contract without specified extensions. It implements all of the logic inside the ERC721Base.sol contract; which implements the ERC721A standard.

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;

    import "@thirdweb-dev/contracts/base/ERC721Base.sol";

    contract Contract is ERC721Base {
    constructor(
    string memory _name,
    string memory _symbol,
    address _royaltyRecipient,
    uint128 _royaltyBps
    ) ERC721Base(_name, _symbol, _royaltyRecipient, _royaltyBps) {}
    }

    This contract inherits the functionality of ERC721Base through the following steps:

    • Importing the ERC721Base contract
    • Inheriting the contract by declaring that our contract is an ERC721Base contract
    • Implementing any required methods, such as the constructor.
  5. After modifying your contract with your desired custom logic, you may deploy it to Conflux using Deploy.


Alternatively, you can deploy a prebuilt contract for NFTs, tokens, or marketplace directly from the thirdweb Explore page:

  1. 访问 thirdweb Explore 页面:https://thirdweb.com/explore

    thirdweb Explore page

  2. Choose the type of contract you want to deploy from the available options: NFTs, tokens, marketplace, and more.

  3. Follow the on-screen prompts to configure and deploy your contract.

想要了解 Explore 上不同合约的更多信息,请查看 thirdweb 文档

部署合约

Deploy allows you to deploy a smart contract to any EVM compatible network without configuring RPC URLs, exposing your private keys, writing scripts, and other additional setup such as verifying your contract.

  1. 想要使用 deploy 部署您的智能合约,请导航至您项目的根目录并执行以下命令:

    npx thirdweb deploy

    Executing this command will trigger the following actions:

    • 编译当前目录中的所有合约。
    • Providing the option to select which contract(s) you wish to deploy.
    • Uploading your contract source code (ABI) to IPFS.
  2. When it is completed, it will open a dashboard interface to finish filling out the parameters.

    • _name: contract name
    • _symbol: symbol or "ticker"
    • _royaltyRecipient: wallet address to receive royalties from secondary sales
    • _royaltyBps: basis points (bps) that will be given to the royalty recipient for each secondary sale, e.g. 500 = 5%
  3. Select TelosEvm as the network

  4. Manage additional settings on your contract’s dashboard as needed such as uploading NFTs, configuring permissions, and more.

For additional information on Deploy, please reference thirdweb’s documentation.

如果您在过程中有任何问题或遇到任何问题,请联系 thirdweb 寻求支持 support.thirdweb.com

视频教程

In the following video, you can find a hands-on demonstration on how to use thirdweb to deploy smart contracts on Conflux eSpace: