The Dead Entity Switch aims to enhance the functionality of an account by introducing a recovery mechanism that enables a designated beneficiary to assume complete control over the account under specific conditions. This functionality is designed to address situations where an account becomes inactive or dormant due to prolonged inactivity, thereby ensuring its resources can be efficiently managed and utilized.
/contracts: smart contracts./deploy: deployment and contract interaction scripts.hardhat.config.ts: configuration file.
Commands are configured in the package.json file and use hardat.config.ts.
yarn hardhat compilewill compile the contracts.yarn deploy-factorydeploy factory usingPK_OWNERaccount and prints its resulting address.yarn deploy-accountdeploy account usingFACTORYenv variable and prints its address to be replaced inDESA_ACCOUNTenv variable. The owner will be set to the public key ofPK_OWNER.yarn set-recovery-addressinteract withDESA_ACCOUNTasPK_OWNERto setPK_BENEFICIARYas recovery address.yarn set-recovery-periodinterect withDESA_ACCOUNTasPK_OWNERto change current recovery period (by default 365 days) to 5 minutes.yarn extract-eth-accountinteract withDESA_ACCOUNTasPK_BENEFICIARY(Should be owner first) to extract ETH minus fees from account.yarn heartBeatinteract withDESA_ACCOUNTasPK_OWNERto stop any recovery ongoing.yarn init-recoveryinteract withDESA_ACCOUNTasPK_BENEFICIARYto start the process of recovery.yarn finish-recoveryinteract withDESA_ACCOUNTasPK_BENEFICIARYto change owner toPK_BENEFIARYpublic key if the recovery period is complete.
In order to prevent users to leak private keys, this project includes the dotenv package which is used to load environment variables. It's used to load the wallet private key, required to run the deploy-factory script, and other variables for further interaction with the deployed account.
To use it, rename .env.example to .env and enter values.
ZKSYNC_WEB3_API_URL=https://zksync2-testnet.zksync.dev
PK_OWNER=123cde574ccff...
PK_BENEFICIARY=123cde574ccff...
FACTORY=0x123cd...
DESA_ACCOUNT=0x123cd...