CORE CONCEPTS

SMART CONTRACTS

Understanding smart contract development in MantleDevKit.

OVERVIEW

Smart contracts in MantleDevKit are written in Solidity and compiled directly in your browser. The compiler automatically resolves dependencies from OpenZeppelin Contracts v5.0.0.

MantleDevKit uses Solidity 0.8.20 with the latest OpenZeppelin security standards built in.

CONTRACT STRUCTURE

A typical contract follows this structure:

Contract.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor() ERC20("MyToken", "MTK") Ownable(msg.sender) {
        _mint(msg.sender, 1000000 * 10 ** decimals());
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

OPENZEPPELIN IMPORTS

The compiler automatically resolves OpenZeppelin imports. Common patterns:

@openzeppelin/contracts/token/ERC20/ERC20.sol

Standard ERC-20 token implementation

@openzeppelin/contracts/token/ERC721/ERC721.sol

Standard ERC-721 NFT implementation

@openzeppelin/contracts/access/Ownable.sol

Owner-based access control

@openzeppelin/contracts/utils/ReentrancyGuard.sol

Protection against reentrancy attacks

CONSTRUCTOR ARGUMENTS

When deploying a contract with constructor arguments, the Studio will automatically detect them from the ABI and present a form for input.

EXAMPLE
constructor(
    string memory name,    // Text input
    string memory symbol,  // Text input
    uint256 initialSupply  // Number input
) ERC20(name, symbol) {
    _mint(msg.sender, initialSupply);
}

Supported types: address, uint256, int256, bool, string, bytes, and arrays of these types.

BEST PRACTICES

Use OpenZeppelin Standards

OpenZeppelin contracts are battle-tested and audited. Always extend from them instead of writing your own implementations.

Add Access Control

Use Ownable or AccessControl to protect sensitive functions like mint, burn, and pause.

Guard Against Reentrancy

Use ReentrancyGuard for any function that makes external calls or transfers funds.

Test on Testnet First

Always deploy to Mantle Sepolia and test thoroughly before deploying to mainnet.

NEXT STEPS