ModuleSDK
Modules
Social Recovery

Social Recovery

The Social Recovery allows users to recover their account using a social recovery mechanism

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.

getSocialRecoveryValidator

The getSocialRecoveryValidator function is used to install the social recovery validator in the account. This function returns a module object.

import { getSocialRecoveryValidator } from "@rhinestone/module-sdk";
 
const guardians = ["0x...", "0x..."]; // guardians address list
const threshold = 2;
 
const socialRecoveryValidator = getSocialRecoveryValidator({
  guardians,
  threshold,
});

getSocialRecoveryMockSignature

The getSocialRecoveryMockSignature 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 { getSocialRecoveryMockSignature } from "@rhinestone/module-sdk";
 
const mockSignature = getSocialRecoveryMockSignature();

getSetSocialRecoveryThresholdAction

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

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

getAddSocialRecoveryGuardianAction

The getAddSocialRecoveryGuardianAction function is used to add a guardian to the validator. This function returns an execution object

import { getAddSocialRecoveryGuardianAction } from "@rhinestone/module-sdk";
 
const guardian = "0x...";
 
const addSocialRecoveryGuardianAction = getAddSocialRecoveryGuardianAction({
  guardian,
});

getRemoveSocialRecoveryGuardianAction

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

import { getRemoveSocialRecoveryGuardianAction } from "@rhinestone/module-sdk";
 
const guardian = "0x...";
 
const removeSocialRecoveryGuardianAction = getAddSocialRecoveryGuardianAction({
  guardian,
});

getSocialRecoveryGuardians

The getSocialRecoveryGuardians function is used to return social recovery guardians. This function returns an array of guardians.

import { getSocialRecoveryGuardians } from "@rhinestone/module-sdk";
 
const params = {
  account,
  client,
};
 
const socialRecoveryGuardians = await getSocialRecoveryGuardians(params);

SOCIAL_RECOVERY_ADDRESS

The SOCIAL_RECOVERY_ADDRESS is a constant that represents the module address.