Contracts
Stylus Minting Modules
You can now install rust based modules into a solidity based modular contract.
This plug-n-play model also allows users to write their own custom minting logic in rust, taking advantage of Stylus' interoperability and gas savings. These modules work with existing router contracts and modules written in solidity.
Deploying a Modular Contract and installing modules is easy through the thirdweb dashboard and ideal when you don't want to modify any code on the contract.
Navigate to the Modular Contracts section on Explore and select any token contract for your project.
Select Arbitrum Sepolia or any other Stylus-supported network, then select Deploy. Once you have deployed one of these contracts, the modules come pre-installed, both solidity and rust ones.
If you wish to install a custom module, navigate to modules tab on your contract page. Enter the publisher address and select module from the dropdown, and click install.
You can uninstall a module from the same page.
Here's a list of prebuilt Rust / Stylus specific modules provided by thirdweb:
- Mintable ERC20
- Transferable ERC20
- Mintable ERC721
- Transferable ERC721
- Mintable ERC1155
- Transferable ERC1155
You can customize these modules via thirdweb CLI as described below.
If you want to modify the contract code or publish a custom module, you can use the thirdweb CLI.
In your CLI, run the following command to create a new directory with an template module. Select the module template from the list shown.
In the
src/lib.rsfile you can modify the contract logic such as adding fees, gating logic, analytics events, and more.To build your project, run the following command:
You can publish your module and install it to your modular contract. Publishing stores your module metadata in thirdweb’s on-chain registry so anyone (including you) can use that exact version later with a few clicks.
To publish your module, ensure you have your thirdweb secret key from your created project, then run the following command:
Once published, the module is now available to install via thirdweb dashboard from the modules tab of your contract.
Using the thirdweb SDKs, you can interact with your Stylus Modular contracts / modules to mint tokens, transfer ownership, and more.
The following describes how to interact with a ERC721 modular contract using thirdweb SDK. (Swap for ERC20 or ERC1155 variants as needed.)