rhinestone

Tutorials

Deploying modules

This tutorial will walk you through deploying any of your modules. Simultaneously, this will also register your module on the Module Registry in order to make it available to users.

This tutorial uses Foundry, a toolchain to simplify and speed up smart contract development. If you are not familiar with Foundry, feel free to check out their docs.

If you do not have foundry installed, run the following command and follow the onscreen instructions: bash curl -L https://foundry.paradigm.xyz | bash

Installation

  1. Get started with ModuleKit by using our template or adding it into an existing foundry project:

Installation

git clone https://github.com/rhinestonewtf/module-template.git
cd module-template
forge install

Deploying the module

In this section, we will deploy the module.

  1. Open the file script/DeployModule.s.sol and change the following code:
bytes memory bytecode = type(ValidatorTemplate).creationCode;
bytes memory deployParams = "";
bytes memory data = "";

Change ValidatorTemplate to the name of your module and deployParams to the parameters you want to pass to the constructor (if any). Finally, change data to the data you want to be stored additionally on the Registry (you will likely want to leave this empty for now).

  1. Create a .env file in the root directory and add the following variables:
PK=[YOUR_PRIVATE_KEY]
  1. Replace the following variables in the command below and then run it in your terminal:
  • RPC_URL is the URL of the RPC node you want to use to broadcast the transaction.
  • SENDER_ADDRESS is the address of the account you want to use to deploy the module (the address of the private key you added to your .env file). Hint: use cast wallet address --private-key [YOUR_PRIVATE_KEY] to get the address of your private key in your command line.
forge script script/DeployModule.s.sol:DeployModuleScript --rpc-url [RPC_URL] --sender [SENDER_ADDRESS] --broadcast
  1. If you scroll up to the top of your command, you should see the following message:

response

== Logs ==
Module deployed at: 0x...

Congratulations, you just deployed your first module!