Write a program in BASIC and get jetForth, the script a jetmora thread runs. Paste jetForth and read it back as BASIC. It all runs in this page: nothing you type leaves it.
Write some BASIC and press Compile.
Paste jetForth and press Read.
| a number | one 64-bit cell |
| bytes | two cells, ( c-addr u ): where they are and how many |
| a variable | at an address fixed when compiling: one cell for a number, two for bytes |
FOR … NEXT | a real loop. jetForth can branch back, so nothing is unrolled |
^ | a multiply loop. Nothing is worked out in advance: the script says what the program says |
VERSION JF 3 | the first line. It becomes the script's first five bytes, VER JF 3:
the lock declares the version its code is written for. A tick spending it must name the same version,
nVersion 0x464a0003 |
With DIM, the program is a covenant: its fields are the thread's state, fixed-width, at the head
of the script. DIM owner$20 is required, and holds HASH160 of the owner's key, as the deployed
Bitcoin covenants store it. The compiler writes the rules every tick must meet:
| 1 · the owner | the key's hash is the owner's, and its signature over the tick holds |
| 2 · the next tick | the value goes up by one, and the tick's sequence number is that same number |
| 3 · the same script | the next tip carries this script |
| 4 · its state | with the fields your program sets, rebuilt into it |
The compiler writes the script once. After that the script rebuilds itself into each new tip, and the rules travel with it.
With INPUT, each tick brings values with it, pushed after the owner's signature and key in
the order INPUT names them. code$ is bytes of any length, code$32
exactly 32; r%2 is a number in at most 2 bytes, r% in at most 8. The owner's
signature covers an input only through what your program puts into the next tip's state.
As a BSV node judges a spend: the unlocking script is byte pushes only; it runs, then the lock runs on what it left; the tick is accepted with exactly one non-zero item. JF revision 3's limits are the same on every host: 500,000 instructions, each 64 bytes moved costing one more; 64 KB of memory; 64 KB of pushed bytes, read-only; 1,000 items; 100 signature checks.