With thirdweb

How to deploy a smart contract on the KYOTO network using thirdweb

Getting Started

To get started with the Solidity SDK, run the following command to create a new project:

npx thirdweb create contract

Or, install the contracts package into your existing Solidity project:

  • Hardhat

  • Forge

npm install @thirdweb-dev/contracts

Using the Solidity SDK

The Solidity SDK can be used to build new smart contracts end-to-end, or to add functionality to your own, existing smart contract using extensions.

All functions in the base contracts and extensions can be modified by overriding them.

Using Base Contracts

The Solidity SDK includes base contracts that are fully complete smart contracts that can be customized by overriding functions OR by adding extensions.

1. To start, import and inherit the base contract. You can find the list of all available base contracts here.

2. Base contracts expect certain constructor arguments to function as intended. Implement a constructor for your smart contract and pass the appropriate values to a constructor for the base contract.

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

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

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

This contract inherits the features of ERC721Base by following these steps:

  1. Importing the ERC721Base contract.

  2. Inheriting the contract by declaring that our contract is an ERC721Base contract.

  3. Implementing any necessary methods, such as the constructor.

Once you have customized your contract with the desired logic, you can deploy it to KYOTO using the Deploy function.

Using Extensions

Extensions are to be used via inheritance - your project's smart contract will inherit from them.

Additional extensions can be added to existing smart contracts or to the base contracts to add extra functionality and unlocking features in the SDKs and Dashboard.

1. To start, import and inherit the extension. You can find the list of all available extensions here.

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

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

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

Note:

  • Some Extensions are Abstract and so require certain functions to be implemented*.

  • Some Extensions are Interfaces and so require all the functions to be implemented*.

*implement = write the logic for the function with a matching function signature (matching name, parameters, visibility and return type)

2. Use the functions provided by the Extension to change the behavior of your smart contract.

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

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

contract MyNFT is ERC721Base, Permissions {
    bytes32 private constant MINTER_ROLE = keccak256("MINTER_ROLE");

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

    /**
     *  `_canMint` is a function available in `ERC721Base`.
     *
     *  It is called every time a wallet tries to mint NFTs on this
     *  contract, and lets you define the condition in which an
     *  attempt to mint NFTs should be permitted, or rejected.
     *
     *  By default, `ERC721Base` only lets the contract's owner mint
     *  NFTs. Here, we override that functionality.
     *
     *  We use the `Permissions` extension to specify that anyone holding
     *  "MINTER_ROLE" should be able to mint NFTs.
     */
    function _canMint() internal view override returns (bool) {
        return hasRole(MINTER_ROLE, msg.sender);
    }
}

Deploy Contract

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.

To deploy your smart contract using deploy, navigate to the root directory of your project and execute the following command:

npx thirdweb deploy

Upon completion, the process will present a dashboard interface to finalize the parameter entries.

  • _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%

Select Kyoto as the network

Customize your contract's dashboard by managing additional settings as required. This includes tasks such as uploading NFTs, configuring permissions, and more.

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

Explorer page:

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

  1. Go to the thirdweb Explore page: https://thirdweb.com/explore

  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.

For more information on different contracts available on Explore, check out thirdweb’s documentation.

Last updated