Module SDK
Modules
MFA Validator

MFA Validator

The MFA Validator module is a module that allows you to add multi-factor validation to an account. The MFA Validator module is used to validate transactions and other executions on the account.

You can find the source code for the module in the Core Modules repo (opens in a new tab) and the deployment address in the address book.

getInstallMultiFactorValidator

The getInstallMultiFactorValidator function is used to create an instance of the MFA Validator module. This function returns a module object.

import { getInstallMultiFactorValidator } from "@rhinestone/module-sdk";
 
const validators = [{
    packedValidatorAndId: '0x...' // packed validator address and validator id
    data: '0x..'; // encoded init data for validator
}];
 
const threshold = 1;
 
const mfaValidator = getInstallMultiFactorValidator({
  validators,
  threshold,
});

getMFAValidatorMockSignature

The getMFAValidatorMockSignature function is used to get a mock signature for the validator. This is used to calculate the gas of an ERC-4337 UserOperation. This function returns a hex-encoded signature.

import { getMFAValidatorMockSignature } from "@rhinestone/module-sdk";
 
const mockSignature = getMFAValidatorMockSignature();

getSetMFAThresholdAction

The getSetMFAThresholdAction function is used to set the threshold for the validator. This function returns an execution object

import { getSetMFAThresholdAction } from "@rhinestone/module-sdk";
 
const threshold = 2;
 
const setMFAThresholdAction = getSetMFAThresholdAction({
  threshold,
});

getSetMFAValidatorAction

The getSetMFAValidatorAction function is used to add a validator to MFA module. This function returns an execution object

import { getSetMFAValidatorAction } from "@rhinestone/module-sdk";
 
const validatorAddress = "0x...";
const validatorId = "0x...";
const newValidatorData = "0x..";
 
const setMFAValidatorAction = getSetMFAValidatorAction({
  validatorAddress,
  validatorId,
  newValidatorData,
});

getRemoveMFAValidatorAction

The getRemoveMFAValidatorAction function is used to remove a validator from the MFA. This function returns an execution object

import { getRemoveMFAValidatorAction } from "@rhinestone/module-sdk";
 
const validatorAddress = "0x...";
const validatorId = "0x...";
 
const removeMFAValidatorAction = getRemoveMFAValidatorAction({
  validatorAddress,
  validatorId,
});

isMFASubValidator

The isMFASubValidator function is used to check if a validator is a sub validator in MFA module. This function returns boolean

import { isMFASubValidator } from "@rhinestone/module-sdk";
 
const validatorAddress = "0x...";
const validatorId = "0x...";
 
const isSubValidator = await isMFASubValidator({
  account,
  client,
  subValidator,
  validatorId,
});

MULTI_FACTOR_VALIDATOR_ADDRESS

The MULTI_FACTOR_VALIDATOR_ADDRESS is a constant that represents the module address.