Skip to content

Commit

Permalink
Update docs with cli args invalid-before/hereafter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimbo4350 committed Dec 8, 2020
1 parent c6b5742 commit 8368b7a
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions doc/reference/simple-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,25 +281,26 @@ NB: If you specify `"type": "any"` this will allow you to spend from your script

## Bounds

It is important to understand the bounds on a transaction and how they relate to the time locking scripts. Previously we had a `ttl` argument in the cli which was an upper bound on a transaction i.e the transaction was valid up until that slot number. This has been replaced with `--lower-bound` and `--upper-bound` arguments as described below:
It is important to understand the bounds on a transaction and how they relate to the time locking scripts. Previously we had a `ttl` argument in the cli which was an upper bound on a transaction i.e the transaction was valid up until that slot number. This has been replaced with `--invalid-before` and `--invalid-hereafter` arguments as described below:

```
If you specify a lower bound on a transaction it is valid from the lower-bound:
lower bound +infinity
|------------------->
If you specify an upper bound on a transaction it is valid to upperbound - 1:
-infinity upper bound - 1
<-------------------|
If you specify both bounds the tx is valid from the lower bound to the upperbound - 1
lower bound upper bound - 1
<------------------->
If you specify a lower bound on a transaction it is valid from the invalid-before slot (IBS):
[IBS, +infinity)
If you specify an upper bound on a transaction it is valid to invalid-hereafter slot - 1 (IHS - 1):
(-infinity, IHS)
If you specify both bounds the tx is valid from the IBS to the IHS - 1
[IBS, IHS)
```
Whichever bound you specify, the slot number in which you submit your transaction has to be within that bound. For example
if you submit your transaction in slot 500 and you specify a lower bound of 600 then your transaction will be rejected.
if you submit your transaction in slot 500 and you specify a `--invalid-before` slot of 600 then your transaction will be rejected.

This also applies to time locking scripts. If you specify a time lock script with `after: 1000` you must specify a lower bound of at least 1000 and therefore also submit that transaction in or after slot 1000.
This also applies to time locking scripts. If you specify a time lock script with `after: 1000` you must specify a `--invalid-before` of at least 1000 and therefore also submit that transaction in or after slot 1000.

Conversely, if you specify a time lock script with `before: 500` you must specify an upper bound of at most 500 and submit the transaction before slot 500. NB: `before: 500` means the transaction is expired in slot 500.
Conversely, if you specify a time lock script with `before: 500` you must specify an `--invalid-hereafter` slot of at most 500 and submit the transaction before slot 500. NB: `before: 500` means the transaction is expired in slot 500.

Once you have generated your time locked script you need to follow all the same steps above for a multisignature script with a slight modification of [step 1](#Step-1---construct-the-tx-body) which needs to be amended as follows:

Expand All @@ -322,12 +323,12 @@ Examples of the time locking scripts are:
"type": "all"
}
```
For `after` scripts we must provide a lower bound that is greater than or equal to the specified slot number in our simple script. In the example above this means >= 1000.
For `after` scripts we must provide a `--invalid-before` slot that is greater than or equal to the specified slot number in our simple script. In the example above this means >= 1000.

```bash
cardano-cli shelley transaction build-raw \
--ttl 1000 \
--lower-bound 1000\
--invalid-before 1000\
--fee 0 \
--tx-in (txin of script address)
--tx-out yourspecifiedtxout \
Expand All @@ -352,12 +353,12 @@ cardano-cli shelley transaction build-raw \
}
```

For before scripts we must provide an upper bound that is less than or equal to the specified slot number in our simple script. In the example above this means <= 3000:
For before scripts we must provide a `--invalid-hereafter` slot that is less than or equal to the specified slot number in our simple script. In the example above this means <= 3000:

```bash
cardano-cli shelley transaction build-raw \
--ttl 1000 \
--upper-bound 3000\
--invalid-hereafter 3000\
--fee 0 \
--tx-in (txin of script address)
--tx-out yourspecifiedtxout \
Expand Down

0 comments on commit 8368b7a

Please sign in to comment.