Register a Module
Modules are smart contracts that are registered in the "Module Registry" and that perform specific validation logic on attestations before they are issued into the registry.
The Module mechanism may change in the future, following Verax Improvement Proposal #5 and what we call "Modules V2".
Module creation
Modules are intended to perform a single specific function. They should be designed to be minimalistic, atomic, and reusable. Modules can be chained together in series so that they are executed in order, with any module in the chain being able to prevent an attestation being issued to the registry by simply reverting if its verification checks fail.
To create a module, you must deploy a smart contract that inherits the AbstractModule
abstract contract, which looks like this:
The run
function accepts four arguments:
attestationPayload
, the raw attestation data that will be stored in the registryvalidationPayload
, validation logic that the module needs to execute its verification logictxSender
, the address of the initial transaction sendervalue
, the amount of ETH paid to get this attestation
The validationPayload
can be any data, which may encompass fields from the attestation metadata or additional data such as ZKP proof, a signature, merkle proof, and so on.
As well as implementing the AbstractModule
interface, the module contract must also implement the IERC165Upgradeable interface, which involves including this function:
Module registration
Module registration takes 3 parameters, defined as follows:
Manually registering a deployed Module in the ModuleRegistry
contract
ModuleRegistry
contractOnce you have deployed your module contract, you can then register it in the ModuleRegistry
contract using the register
function:
A few caveats: a module contract must be first deployed and cannot be registered twice under different names, and it must implement the interfaces described above. Also, the name
parameter must not be empty.
Using a blockchain explorer
Instead of crafting the smart contract call by hand, you can benefit from a chain explorer interface. Let's use the Linea Sepolia explorer, Lineascan.
Retrieve the
ModuleRegistry
contract address from the project READMEAccess the
ModuleRegistry
contract on LineascanGo to the "Contract" tab
Go to the "Write as Proxy" tab
Connect your allow-listed wallet and fill the
register
form with the parameters described aboveSend the transaction
Using the official Verax SDK
We have seen rather manual ways to register a Module, now let's focus on the easiest way: via the Verax SDK.
Check this page to discover how to instantiate the Verax SDK.
Once you have an SDK instance, you can register a Module like this:
To dive deeper on exactly how the ModuleRegistry
contract works, you can check out the source code on GitHub.
Once you have deployed one or more schemas and optionally also deployed one or more modules, you are ready to register a portal and tie them all together so that you can issue your first attestations.
Last updated