Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

I built a tool called Modulity that lets you create smart contracts by assembling components. This article walks through how to use it.

https://modulity.vercel.app/

Overview

Smart contract development normally requires a development environment, and setting one up can be a hurdle. With Modulity, you can develop and deploy contracts without going through that setup process.

Modulity is still under development. The original article dates from July 2025; the screenshots are unchanged and some UI labels remain in Japanese.

Motivation

Engineers can generally set up a development environment without much difficulty. For non-engineers, or engineers who just want to deploy a simple contract, the setup can be an inconvenience. Solidity, a programming language for writing smart contracts, is relatively straightforward and accessible even to non-engineers. Ideally, users should also be able to determine for themselves how a smart contract is implemented. Depositing funds into a fraudulent smart contract can mean losing them permanently. From a security perspective, it is preferable to inspect the implementation of a contract before interacting with it rather than simply trusting it. Wallets may display warnings before execution, but do not rely on those warnings alone. Make your own informed judgment.

For engineers who want to deploy a simple contract, it is also convenient to be able to create and deploy one directly from the browser without setting up a development environment.

How to use Modulity

Let's walk through Modulity by deploying an NFT contract.

Interface layout

First, here's how the interface is organized.

Overview of the Modulity interface

① Navigation menu

  • Contract execution (コントラクト実行) Run functions on a previously deployed contract.
  • Connect Wallet Connect the address used to deploy and interact with contracts.
  • Compile (コンパイル) Compile and deploy the contract you have created.

Compilation

Compilation is the process of converting Solidity code into bytecode that the EVM (Ethereum Virtual Machine) can understand. Once the contract has been compiled into a format the EVM understands, it can be deployed and executed. The Solidity compiler (solc) produces two outputs:

  • Bytecode Low-level instructions executable by the EVM. It is stored on the blockchain when the contract is deployed.
  • ABI (Application Binary Interface) Interface information for interacting with the contract from outside. It includes function names, arguments, and type information.

② Component list

This panel lists the components used to create a Solidity contract.

  • Variables (変数) Store and manage different values.
  • Functions (関数) Implement operations such as minting or transferring NFTs.
  • Modifier Apply execution restrictions to functions, such as allowing only addresses that hold an NFT or allowing only addresses with a specific role.
  • Events (イベント) Notify frontend applications about function execution results. By emitting events, the contract makes execution information available to off-chain applications.
  • Structs (構造体) Group multiple variables into a single data structure.
  • Import Import other contracts, including contracts provided by OpenZeppelin.

③ Component editor

Drag and drop components into this area to configure them. For example, after dropping a function, you can edit its name, behavior, and access controls. To add another function, drag another function component into the editor.

④ Contract code panel

This panel shows the actual code generated from the components you add and edit. When developing a smart contract directly in Solidity, you would normally work with this code yourself.

At the time of writing, the code panel cannot be edited directly. Direct editing is planned for the future.

Connecting a wallet

There are two ways to connect a wallet: through a browser extension or through a mobile wallet app such as MetaMask. For the second approach, see the mobile wallet connection section below.

Connecting a wallet on desktop

This section covers browser extension wallets, using MetaMask as an example.

Click "Connect Wallet" in the upper-right corner. A modal like the following appears.

Desktop wallet connection modal

Select MetaMask in the modal. If you have installed another wallet extension and want to use it instead, select that wallet where it appears alongside MetaMask. You can also select All Wallets and choose the wallet from the list.

Selecting a browser extension wallet

The selected wallet opens and displays a connection screen. Click Connect (接続).

Connecting a mobile wallet

Click "Connect Wallet" in the upper-right corner to open the modal.

Select WalletConnect.

Selecting WalletConnect

A QR code appears. Scan it with your phone's camera app.

WalletConnect QR code

You will be prompted to open a wallet app such as MetaMask. Open the app.

Mobile wallet connection prompt

Click "Connect (接続)".

Wallet connected

Connected wallet address and balance

After connecting, the interface displays the connected wallet address and its native token balance.

A native token is the token used on a blockchain primarily to pay gas fees and reward miners or validators. Examples include ETH on Ethereum and AVAX on Avalanche.

Checking the connected network

Now that the wallet is connected, check which blockchain network it is using and switch networks if needed. Click the native token balance displayed in the upper-right corner.

Opening the network and balance panel

A wallet-style panel appears.

Wallet-style panel

Click the blockchain logo in the upper-left corner. A list of blockchains appears. For this example, select Sepolia, an Ethereum testnet.

Selecting the Sepolia testnet

Check that the native token balance shown in the wallet matches the balance in the upper-right corner.

Creating an NFT contract

Now create the NFT contract.

Importing contracts

First, import external contracts into the contract you are building. This allows you to reuse existing contract implementations.

Select Import in the component list.

Selecting the Import component

Select ERC721.

Selecting ERC721

Scroll down, select Strings and Base64, then click Import (インポート). After importing the other contracts, the interface looks like this.

Imported contracts in the editor

On the left, you can set the name and symbol of the ERC721 NFT. Choose any name and symbol you like.

An NFT symbol is an abbreviated name for the NFT. Some projects use the same name and symbol; the choice varies from project to project.

The actual Solidity code appears on the right. You can see the newly imported ERC721, Strings, and Base64 contracts. Writing "contract MyContract is ERC721" and specifying ERC721 after the is keyword makes all the functionality of the ERC721 contract available through inheritance.

Adding a variable

Variables store data. Drag the Variable (変数) component from the component list into the editor.

Dragging a variable into the editor

Configure the fields of the new variable as follows.

Configuring the URI variable

  • Variable name: uri
  • Type: string
  • Initial value: Paste the URL of the image below. This will be the NFT image.
text
https://ut7vdq4ioh4krpe3kr2qhejiww5fsw3daatfpj4zo3alknv53rtq.arweave.net/pP9Rw4hx-Ki8m1R1A5EotbpZW2MAJlenmXbAtTa93Gc/

Adding functions

Next, add functions that perform operations such as minting or transferring tokens. As before, drag the Function (関数) component from the component list into the editor.

Adding a function component

Configure the new function as follows.

  • Template: ERC721: mint (automatic ID assignment / 自動採番)

Selecting the mint function template

Click Save (保存) to apply the changes to the code on the right.

Add another function by dragging the Function (関数) component from the list again.

Adding a second function

You can collapse the previously added function using the toggle icon on the left. Configure the new function as follows.

  • Template: ERC721: tokenURI

Scroll down slightly to the code field, select all of the existing code (Ctrl + A), and replace it with the following.

text
string memory json = string(
    abi.encodePacked(
        '{"name":"JBANFT #',
        Strings.toString(tokenId),
        '","description":"JBA NFT","image":"',
        uri,
        '"}'
    )
);

string memory encoded = Base64.encode(bytes(json));

return string(abi.encodePacked("data:application/json;base64,", encoded));

This is NFT metadata, which describes an NFT. The code above may be difficult to read at first, but its output takes the following form: name contains the NFT's name, description contains its details, and image contains the image configured earlier.

text
{
	"name": "JBANFT #0",
	"description": "JBANFT NFT",
	"image": "https://arweave.net/pP9Rw4hx-Ki8m1R1A5EotbpZW2MAJlenmXbAtTa93Gc"
}

See the following article for more information about the metadata returned when calling tokenUri.

After pasting the code, click Save (保存).

Saving the tokenURI function

Compilation

The contract is now ready to compile. Compilation converts it into a format that its execution environment, the EVM, can understand, making deployment possible.

Click Compile (コンパイル) in the upper-right corner. If there is a problem with the code, an error is returned at this stage. The contract currently looks like this.

text
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import { ERC721 } from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import { Base64 } from "@openzeppelin/contracts/utils/Base64.sol";
import { Strings } from "@openzeppelin/contracts/utils/Strings.sol";

contract MyContract is ERC721 {

    // Constructor
    constructor() ERC721("TestNFT", "TNFT") {}
    // State variables
    uint256 private _nextTokenId;
    string public uri = "https://ut7vdq4ioh4krpe3kr2qhejiww5fsw3daatfpj4zo3alknv53rtq.arweave.net/pP9Rw4hx-Ki8m1R1A5EotbpZW2MAJlenmXbAtTa93Gc/";

    // Functions
    function safeMint(address to) public {
        uint256 tokenId = _nextTokenId++;
        _safeMint(to, tokenId);
    }

    function tokenURI(uint256 tokenId) public view override returns (string memory) {
        string memory json = string(
            abi.encodePacked(
                '{"name":"JBANFT #',
                Strings.toString(tokenId),
                '","description":"JBA NFT","image":"',
                uri,
                '"}'
            )
        );
        string memory encoded = Base64.encode(bytes(json));
        return string(abi.encodePacked("data:application/json;base64,", encoded));
    }

}

After successful compilation, the following screen appears.

Successful compilation screen

Deployment

Now deploy the compiled contract. Click Deploy (デプロイ) in the lower-right corner of the modal.

Your wallet prompts you to sign the deployment transaction. Click Confirm (確認).

Wallet deployment confirmation

After a short time, the following screen appears, indicating that deployment succeeded.

Successful deployment screen

Click View in Explorer (Explorerで確認) to open the blockchain explorer and inspect the contract.

Nothing is displayed yet. Leave this page as it is; we will check it again after calling a contract function in the next section. Click Close (閉じる) in the lower-right corner.

Interacting with the contract

Now interact with the deployed contract.

Click Contract execution (コントラクトの実行) in the upper-right corner.

Opening the contract execution interface

The following screen opens. Select the only available entry under Contract to execute (実行するコントラクト).

Selecting the deployed contract

You can now call the contract's functions. Select the Write functions (書き込み関数) tab, then choose safeMint under Function to execute (実行する関数). Finally, enter an address of your choice, such as your own address, into to.

Configuring the safeMint call

Click Execute (実行). The wallet opens its transaction confirmation screen again. Click Confirm (確認).

Confirming the mint transaction

After a short time, Transaction successful (トランザクション成功) indicates that execution succeeded. Click View (確認→).

Successful mint transaction

Open the following blockchain explorer.

Enter the address of the contract you deployed into the search field. If the image appears as shown in the following example, the process succeeded.

If the image does not appear, select one of the tokens and click Refresh metadata.

Refreshing NFT metadata in Blockscout

Further exploration

Modulity has other features as well. Try experimenting with them.

Conclusion

This article introduced Modulity, a tool for building smart contracts by assembling components.

I also write articles elsewhere. You can find more of my work at the following links.

https://chaldene.net/