Module Registry
Usage
Mock Attestations on Testnet

How to make a mock attestation to use a module on testnet

When building a module, you may want to test it on a testnet before deploying it into production. However, accounts will likely require the module to be attested in order to use it. This is where mock attestations come in. Mock attestations are a way to simulate the attestation process on testnets, allowing you to test your module before deploying it into production.

In this guide, you will have two options for interacting with the chain: using a forge script or using cast. Forge script is a more advanced way which is especially useful when you need to do multiple actions, such as deploying, registering and attesting to a module. When you only need to do one action, cast is a simpler way to interact with the chain.

Deploy your module

First, you will need to deploy your module. The easiest way to do this is using the ModuleKit with the provided RegistryDeployer script.

You can follow along our guide for using this script.

Register your module

If you have deployed your module via the Module Registry, then there is nothing else you need to do since it is already registered. However, if you have deployed your module in a different way, you will need to register it manually.

To register your module in a forge script, you can use the registerModule function from the ModuleKit.

If you are using cast, you can use the following command:

cast send 0x000000000069E2a187AEFFb852bF3cCdC95151B2 "registerModule(bytes32,address,bytes,bytes)" 0xdbca873b13c783c0c9c6ddfc4280e505580bf6cc3dac83f8a0f7b44acaafca4f MODULE_ADDRESS METADATA RESOLVER_CONTEXT --rpc-url RPC_URL --private-key PRIVATE_KEY

You will need to replace MODULE_ADDRESS, METADATA, RESOLVER_CONTEXT, RPC_URL, and PRIVATE_KEY with the appropriate values. Note that METADATA and RESOLVER_CONTEXT can be empty (0x).

Attest to your module

To attest to your module in a forge script, you can use the mockAttestToModule function from the ModuleKit. To see how you can set up the script and run it, check out our guide for using forge script script.

If you are using cast, you can use the following command:

cast send 0xA4C777199658a41688E9488c4EcbD7a2925Cc23A "attest(address,bytes32,(address,uint48,bytes,uint256[]))" 0x000000000069E2a187AEFFb852bF3cCdC95151B2 0x93d46fcca4ef7d66a413c7bde08bb1ff14bacbd04c4069bb24cd7c21729d7bf1 "(MODULE_ADDRESS, 0, ATTESTATION_DATA, MODDULE_TYPES)" --rpc-url RPC_URL --private-key PRIVATE_KEY

You will need to replace MODULE_ADDRESS, ATTESTATION_DATA, MODDULE_TYPES, RPC_URL, and PRIVATE_KEY with the appropriate values. Note that ATTESTATION_DATA can be empty (0x) or a random data string since this is for mock purposes only. MODULE_TYPES is an array of the types of the module, such as [1,2] for a module that is a validator and an executor.

Check the attestation

Your module should now be attested to. In order to check this using the forge script, you can use the isModuleAttestedMock function from the ModuleKit. If the module is attested, the function will return true.

If you are using cast, you can use the following command:

cast call 0x000000000069E2a187AEFFb852bF3cCdC95151B2 "findAttestation(address,address)" MODULE_ADDRESS 0xA4C777199658a41688E9488c4EcbD7a2925Cc23A --rpc-url RPC_URL

You will need to replace MODULE_ADDRESS and RPC_URL with the appropriate values. If the module is attested, the output will non-zero data. Otherwise, it will be all zeros.

Setting up the account

Now that you have deployed, registered, and attested to your module, you can use it on testnet as if it were attested. The final step you will need to do is to set up your account to trust the mock attester: 0xA4C777199658a41688E9488c4EcbD7a2925Cc23A.

How exactly you set this up will depend on the account used, but most accounts have a way to supply trusted attesters on account initialization. You can also set this up manually by calling the trustAttesters function on the Module Registry. To do this, you can create a new UserOperation with the target as the Module Registry (0x000000000069E2a187AEFFb852bF3cCdC95151B2) and the call data as the trustAttesters function (trustAttesters(uint8 threshold, address[] calldata attesters)). In this case, you would use a threshold of 1 and the attester address being 0xA4C777199658a41688E9488c4EcbD7a2925Cc23A.