HODL - smart contract plugin for Electron Cash to timelock BCH

2 455
Avatar for pat
Written by
3 years ago

Did you ever regret acting under FUD or FOMO influence?
Did you make big financial mistakes because of that?
Do you want to protect yourself from such compulsory actions?
 

Then you'll certainly want to use the HODL plugin for Electron Cash. With it you can lock your funds in a smart contract utilizing CLTV opcode, rendering them unspendable until a certain date or blockchain height.

 

I invite the community to test the plugin and experienced developers to audit it for security and other potential issues.

HODL Contract

HODL contract is a simple upgrade over the most common "pay to public key hash" (P2PKH) address type. It utilizes in addition the OP_CHECKLOCKTIMEVERIFY opcode to check against the current blockchain height or current date before locking the funds to the redeemer's public key hash. The target locktime is provided to the contract upon its construction as an argument.

scriptSig: <sig> <pubkey>
scriptPubkey: <locktime> OP_CHECKLOCKTIMEVERIFY OP_DROP OP_DUP OP_HASH160 <pubkeyhash> OP_EQUALVERIFY OP_CHECKSIG

Transaction fees are very low and target 1sat/byte. However, the total fee depends upon the number of inputs, as usual.

Remarks

0. The plugin is quite young, so be careful and try to lock small BCH amounts first.
1. The plugin is designed only for the standard HD wallets (multiaddress). Watch-only, Multisig wallets or wallets with imported private keys are not supported.
2. If you lock the funds until certain date, allow for extra time (up to 70 minutes) after the contract maturation. This is due to the median time-past for the lock-time calculations (BIP-113).
3. HODL contract can safely lock values greater than 21 BCH.

How to install and use the plugin

First, download the hodl.v1.0.0.zip file from github repository releases and verify the checksum to be eaafab422c8cae0fe5786711e44f9ee867b9b86d5f8e855248176cfe8a617cc7.

 

 

Then go to your Electron Cash and install the plugin: in the menu click "Tools" > "Installed Plugins..."

 

 

 

In the presented window select "Add Plugin". Select the dowloaded archive and confirm.

 

 

 

Next, review the plugin info and verify the checksum. Carefully read the Risks and Dangers section. You'd have to check the boxes before completing the installation.

 

 

After installation, a new "HODL" tab will appear. It will list all smart contracts with CLTV locked funds created earlier.

Click Create new HODL contract, choose the amount of BCH you want to lock until either certain blockchain height or certain calendar date and confirm.

After that the list of contracts will update and your new contract will be displayed there along with the information about its locked value and expected maturation.

When contract is matured, it is unlocked for spending. Simply click Spend contract button and confirm the prompt.

Attributions

This work is based on the codebase of an excellent Mecenas Electron Cash plugin by @Licho.
The diamond logo is taken from https://icons8.com

36
$ 6.10
$ 2.13 from @TheRandomRewarder
$ 1.00 from @emergent_reasons
$ 1.00 from @BitcoinOutLoud
+ 8
Avatar for pat
Written by
3 years ago

Comments

When I started reading your article, I immediately thought of Mecenas. I even wrote about Mecenas here:

https://read.cash/@Telesfor/mecenas-recurring-payment-smart-contract-plugin-1c6de86e

$ 0.10
3 years ago

I cashed out my BCH, no doubt it can help, not only me but my family also. I cashed out mine because my family needs it.

$ 0.00
3 years ago