<p>Yes, you can use <code>OP_CHECKLOCKTIMEVERIFY</code> opcode in the locking script of the output. This opcode takes either blocks or Unix Epoch Time (seconds since 1-Jan-1970) as the parameter to lock. If the parameter is non-zero and below 500 million, it is interpreted as a block height, if it is greater than or equal to 500 million, it is interpreted as a Unix Epoch timestamp. When you would reference this UTXO at the time of spending, you need to set the transaction <code>nLocktime</code> equal to or great than the <code>OP_CHECKLOCKTIMEVERIFY</code>. The <code>nLocktime</code> parameter while spending should be same as what was specified in the CLTV; i.e. if the CLTV locking parameter was in blocks, it should be specified in blocks, otherwise in Unix Epoch timestamp.</p>

<p>Since you want it to be spendable after 1st Jan 2030, that is equivalent to timestamp of 1,893,456,000 (or 0x70dbd880). So your locking script will be concatenation of:</p>

<pre><code>OP_DATA (size of CLTV_expiry): 0x04
CLTV (little endian): 0x80d8db70
OP_CLTV: 0xb1
OP_DROP: 0x75
OP_DUP: 0x76
OP_HASH160: 0xa9
OP_DATA (size of address): 0x14
Address: &lt;address&gt;
OP_EQUALVERIFY: 0x88
OP_CHECKSIG: 0xac
</code></pre>

<p>Two things to note: (1) When you are spending this transaction, the input referencing this UTXO needs to have <code>nSequence</code> value between 0xF0000000 to 0xFFFFFFFE. (2) Median_time (time of last 11 blocks) is used to check <code>nLocktime</code> when the script is evaluated which is generally about hour behind the actual time on your wall clock.</p>

CC BY-SA 4.0
2021-02-19T19:51:38.350Z
How can one build such a transaction, though, except with a binary/hex editor, "manually"?
Gabriel
CC BY-SA 4.0
2021-05-10T22:46:36.800Z
@Gabriel you can try this link which has multiple examples and code samples https://bcoin.io/guides/cltv.html
pseudozach
CC BY-SA 4.0
2022-12-21T02:06:28.487Z
Can the `nSequence` field be any value as long as it's not `0xffffffff`?
greatwolf
CC BY-SA 4.0
2019-06-07T16:28:50.943Z
2019-06-07T17:19:59.223Z
2019-06-07T17:19:59.223Z
Ugam Kamat
<p>Is it possible to submit some coins to some address and make them spendable after some period of time?</p>

<p>Like I want submit 1btc to address 1Kc24m... and make that output to be spendable after january 1st 2030.</p>

<locktime><checklocktimeverify>
How can I make transaction output time locked?
Michal
# How can I make transaction output time locked?

(Asked by: username_0 on 2019-06-07)

Is it possible to submit some coins to some address and make them spendable after some period of time?

Like I want submit 1btc to address 1Kc24m... and make that output to be spendable after january 1st 2030.

**Tags:** locktime, checklocktimeverify


---

## 1 answers

### Answer by username_1 on 2019-06-07. Score: 5

Yes, you can use `OP_CHECKLOCKTIMEVERIFY` opcode in the locking script of the output. This opcode takes either blocks or Unix Epoch Time (seconds since 1-Jan-1970) as the parameter to lock. If the parameter is non-zero and below 500 million, it is interpreted as a block height, if it is greater than or equal to 500 million, it is interpreted as a Unix Epoch timestamp. When you would reference this UTXO at the time of spending, you need to set the transaction `nLocktime` equal to or great than the `OP_CHECKLOCKTIMEVERIFY`. The `nLocktime` parameter while spending should be same as what was specified in the CLTV; i.e. if the CLTV locking parameter was in blocks, it should be specified in blocks, otherwise in Unix Epoch timestamp.

Since you want it to be spendable after 1st Jan 2030, that is equivalent to timestamp of 1,893,456,000 (or 0x70dbd880). So your locking script will be concatenation of:

```
OP_DATA (size of CLTV_expiry): 0x04
CLTV (little endian): 0x80d8db70
OP_CLTV: 0xb1
OP_DROP: 0x75
OP_DUP: 0x76
OP_HASH160: 0xa9
OP_DATA (size of address): 0x14
Address: <address>
OP_EQUALVERIFY: 0x88
OP_CHECKSIG: 0xac

```

Two things to note: (1) When you are spending this transaction, the input referencing this UTXO needs to have `nSequence` value between 0xF0000000 to 0xFFFFFFFE. (2) Median\_time (time of last 11 blocks) is used to check `nLocktime` when the script is evaluated which is generally about hour behind the actual time on your wall clock.

> **Comments:**
> **username_2**: How can one build such a transaction, though, except with a binary/hex editor, "manually"?  
> **username_3**: @username_2 you can try this link which has multiple examples and code samples https://bcoin.io/guides/cltv.html  
> **username_4**: Can the `nSequence` field be any value as long as it's not `0xffffffff`?  

---

