How to Deploy a Modular Contract

This guide will show you how to publish a Modular Contract that increments a counter. If you're interested in learning how modular contracts work, refer to How it works. If you haven't read through Create a Core Contract and Create a Module Contract, please do so before proceeding as this guide will build on top of those previous guides.

  • Grab an API Key from the thirdweb Dashboard

    Go to the thirdweb Dashboard Settings and click on "Create API Key".

    A dialog should pop up asking for the name of the key. Use modular-contract-test-key.

    Click "Proceed".

    Then, click on the copy icon and store the API key in a secure place.

  • Publish the Module Contract

    In your terminal, run the following command:

    npx thirdweb publish -k "THIRDWEB_API_KEY"

    Replace THIRDWEB_API_KEY with your API key. Then, select CounterModule.

    It should open up your browser. Scroll to the bottom and click "Next".

    Then, choose the Sepolia network and click "Publish Contract".

    Now, we can move on to deploying the core contract.

  • Deploy the Core Contract

    In your terminal, run the following command:

    npx thirdweb deploy -k "THIRDWEB_API_KEY"

    Replace THIRDWEB_API_KEY with your API key. Choose CounterCore.

    It should open up your browser. Input the owner of the contract and click "Deploy Now".

    Then, choose the Sepolia chain and click "Deploy Now".

    It should now be deploying.

    Once the core contract has been deployed, click "View Contract".

  • Install the Module

    On the contract dashboard, click on "Modules" in the left-hand sidebar.

    You will be redirected to the "Edit Modules" page, where you can install the CoreModule. Under the "Publisher" input, paste in the address of the publisher you used.

    Then, the "Module Name" input will unlock. Click on that and select counterModule. Once it finishes checking eligibility, select "Module Version" as 1.0.0 and choose whichever step you wish to use.

    Finally, click "Install".

    Now the module has been successfully installed.


And there you have it! You have now deployed your very own Modular Contract!