Use the dedicated web application “LOCK-APP” to interact with the smart contract on the EOS, TELOS or UX mainnets and easily lock/unlock your account for/after the specified time period.

Alternatively, you can use the manual procedure described below in the”GETTING LOCKED” section.

WARNING

The account-lock utility is intended for advanced use by EOSIO dapp developers. It is provided “as is” and its adoption by inexperienced users is strongly discouraged.

Change of the owner permission is a potentially dangerous action which can make your account irrecoverable. Please make sure you are doing it correctly or you can permanently loose access to your account. We suggest to test the process with a secondary account until you are sure that everything is working properly.


GETTING LOCKED

Follow these steps to provide temporary immutability to your account:

1. Add the accountlock2@eosio.code permission to the owner authority of your account:

cleos set account permission YOUR_CONTRACT owner ‘{ “threshold”: 1, ”keys”: [{“key”: “CURRENT_PUBLIC_KEY”,”weight”: 1}], “accounts”: [ { “permission”:{“actor”:”accountlock2″, ”permission”:”eosio.code” }, ”weight”:1 } ] }’ -p YOUR_CONTRACT@owner

In alternative to the above cleos command line or lock-app user interface you can use the eosio account toolkits or wallets available online.

2. Call the lock action of the accountlock2 smart contract. Set the following parameters:

  • target_contract: [YOUR_CONTRACT]
  • unlock_time: [enter the lock expiry in “YYYY-MM-DDThh:mm:ss” format]
  • days_notice: [enter the notice period in number of days, it can be set to 0 for immediate release]
  • public_key_string: [enter the public key that should be used to restore your account after the lock time has expired]
  • unlocker_str: [ enter an empty string “” or the name of the account which will be allowed to restore the account ]
  • locked_auth:[ enter “both” to lock both owner and active authorities or “owner” to lock only the owner authority]

cleos -u https://eos.greymass.com push transaction ‘{“delay_sec”: 0, “max_cpu_usage_ms”: 0, “actions”: [{“account”: “accountlock2″,”name”: “lock”, “data”: {“target_contract”: “YOUR_CONTRACT”, “unlock_time”: “2021-04-30T00:00:00”, “days_notice”: 60, “public_key_str”: “YOUR_PUBLIC_KEY”, “unlocker_str”: “”, “locked_auth”: “both”}, “authorization”: [{ “actor”: “YOUR_CONTRACT”, “permission”: “owner” } ] } ] }’

Warning: make sure to insert correctly your public key string or you might permanently loose control of your account.

3. After the lock time has expired, call the unlock action of the accountlock2 contract to restore the owner authority:

  • target_contract: [YOUR_CONTRACT]

cleos -u https://eos.greymass.com push transaction ‘{“delay_sec”: 0, “max_cpu_usage_ms”: 0, “actions”: [{“account”:”accountlock2″,”name”: “unlock”,”data”: {“target_contract”: “YOUR_CONTRACT”},”authorization”: [{ “actor”: “UNLOCKER_CONTRACT”,”permission”: “active”}]}]}’

To call the unlock action you should use the unlocker_str account provided during lockup. If unlocker_str was set to an empty string (“”), than any account can unlock (please note that you will not be able to call the unlock action using YOUR_CONTRACT’s permissions as these will be locked at this time);

If days_notice > 0, then the days_notice period is added as additional lock time after the first attempt to unlock the contract. If days_notice = 0, this action will unlock your account by restoring the public_key_string as the owner authority.


Note: the accountlock2 permissions are set to “eosio.null” to ensure that no-one can take control of your account while locked


Troubleshooting


PROOF OF LOCK AND EXPIRY TIME

Locked account names and the corresponding lock-up expiry dates are recorded on a table on the accountlock2 contract.

Any user of your dapp can check, using a simple blockchain explorer, that your account is currently locked and the date in which it will be unlocked.

When a locked account gets unlocked, the corresponding record on the accountlock2‘s data table is removed.

The data table stored on the contract address provides at the same time a certification of the lockup and information of the unlock time/date. Lockup data is public and transparent as any dapp user can easily access these details using an online blockchain explorer.