This page covers the smart contract implementation details. See Glossary.
EXEC role.
How modules work
The Modules Manager acts as both a registry and an execution gateway:- Registry — Stores authorized module addresses mapped to unique
bytes32identifiers - Execution gateway — Authorized callers trigger module execution on target contracts (vehicles)
- Target protection — Each target contract must explicitly allow a module before it can be executed on it
- Security — Adding or updating modules is protected by a mandatory timelock
Module lifecycle
Every module goes through a three-step process:- Registration — An authorized
MODULE_MANAGERcallsaddModule. This creates a pending request and starts the timelock countdown. - Finalization — After the timelock elapses, anyone can call
approvePendingModuleto activate the module. - Authorization — The target contract (e.g. a Vehicle) calls
allowModuleto permit execution of that module on itself.
The timelock is a mandatory delay between requesting a module addition and its activation. This gives stakeholders time to review the proposed module before it becomes executable.
Prerequisites
You need the following roles on your External Access Control, scoped to the Modules Manager contract:| Role | Purpose |
|---|---|
MODULE_MANAGER | Add, update, or remove modules from the registry |
EXEC | Execute authorized modules on target contracts |
CANCEL_MODULE | Cancel a pending module operation during the timelock |
UPDATE_TIMELOCK | Change the timelock duration |
VEHICLE_ALLOW | Allow or disallow modules on a Vehicle (scoped to the Vehicle) |
Add a module
Adding a module is a two-step process separated by the timelock.Request module addition
Call
addModule with the module’s unique ID and its contract address. The ID must match the value returned by IModule(module).MODULE_ID().Requires: MODULE_MANAGER role.Approve the pending module
After the timelock has passed, finalize the module registration. This function can be called by any account.
Execute a module
Once a module is active in the registry and allowed on the target, you can execute it. Requires:EXEC role.
The target contract must implement the
IModuleTarget interface. All Railnet vehicles implement this interface by default.Update a module
To update a module’s implementation address, the process mirrors addition — request, timelock, approve.Updating a module does not require re-allowing it on target contracts. Existing
allowModule authorizations carry over to the new implementation.Remove a module
Removing a module revokes its authorization across all target contracts immediately. Requires:MODULE_MANAGER role.
Cancel a pending module
If you need to abort a module addition or update during the timelock period, cancel it. Requires:CANCEL_MODULE role.
Disallow a module on a target
Revoke a module’s authorization on a specific target without removing it from the registry.Update the timelock duration
Change the global timelock duration for future module operations. Requires:UPDATE_TIMELOCK role.
Next steps
Configure fees
Set up fee structures for your Multi-Vehicle.
Configure rewards
Capture and distribute additional protocol rewards with interceptors.