SkyhookStart here

What You Can Build

Atomic swaps are only the beginning of what the Skyhook Bridge’s lock-scripts can express. In The future of atomic swaps, Zcash Community Grants committee member GGuy described a family of richer arrangements: swaps that work like financial options, which anyone holding them can choose to execute before they expire, and conditional options that only become executable once earlier ones have been. The official grant application builds Milestone 2 around this vision, promising swaps “similar to @GGuy’s vision”.1 This page shows how each idea maps onto the Skyhook Bridge, and lets you run simplified versions of them.

All of them use the same machinery. A lock-script request commits a program; once the Zcash payment has been proven, anyone can execute the program on ESMASTe, which decides where the escrowed funds go. The execution layer is built and tested; the tools for authoring programs without writing opcodes are what Milestone 2 delivers.

Open-recipient options

An open-recipient atomic swap names no counterparty in advance. Whoever holds it may execute the swap before its expiry time, or let it lapse, which is exactly how an option works in traditional finance. The option can be handed out for free or sold.

GGuy’s example is an exchange. A user picks a pair and an amount on the exchange’s website, and the exchange issues an option at the current rate, for instance as a QR code, valid only for a short time. The user then executes the swap if they still want it. The shorter the validity window, the less the rate can move against the issuer; and the same mechanism lets an exchange sell options with long expiry times, for hedging and trading.

In the Skyhook Bridge this is a lock-script that pays whoever executes it, as long as the deadline hasn’t passed, and refunds the issuer afterwards. Unlike the standing-mode tickets, which name the taker they are issued to, such an option can be issued with no named recipient at all.

Build an ESMASL scriptInteractive demo
.header spk set · 5 constants · ext: 32-byte words · limit 64 steps
Program drag blocks to move them · ▸ shows the raw opcodes
Control
Payments
Finish
Caller's inputs
Value
Runner
Counterparty
Owner
Caller

Show the machine
      A simplified demonstration, not the Milestone 2 authoring layer, which produces real ESMASL programs. Blocks stand for library aggregates (the stdlib/stdfin names here are illustrative) and compile to the raw opcodes shown when you expand them. Preimages are hashed with real keccak-256; CHECKSENDER is simulated by the checkbox, and STATICCALL, which is still in development, is emulated by the payments slider. Value leaves the runner only through TRANSFERNATIVE; a TRAP, running past the step limit or ending without RETURN reverts everything; the same inputs always give the same outcome.

      Conditional options

      A conditional option can only be executed once one or more other options have been. GGuy’s example is a one-year car loan with monthly repayments, in which ownership of the car passes to the borrower only after all twelve payments are made. It can be arranged two ways:

      • In sequence. The borrower receives twelve options that must be executed in order. The first eleven are plain ZEC payments to the lender; the twelfth swaps the last payment for the car’s NFT, and each option depends on the one before it.
      • As a set. The first eleven payments can be made in any order, and only the final option, which transfers the car, depends on all of them having been executed.

      The Skyhook Bridge expresses the dependency with a separate contract that keeps track of the loan. Its address goes in the script’s constant stack, and because ESMASL runs inside a runner contract with sandboxed privileges, the script can call, and statically call, that contract to ask how many payments have been made. A dedicated STATICCALL opcode is in development; the demo below emulates it. The final option releases only when the loan manager reports that all eleven earlier payments have been made, and refunds the lender if the deadline passes first.

      Build an ESMASL scriptInteractive demo
      .header spk set · 5 constants · ext: 32-byte words · limit 64 steps
      Program drag blocks to move them · ▸ shows the raw opcodes
      Control
      Payments
      Finish
      Caller's inputs
      Value
      Runner
      Counterparty
      Owner
      Caller

      Show the machine
          A simplified demonstration, not the Milestone 2 authoring layer, which produces real ESMASL programs. Blocks stand for library aggregates (the stdlib/stdfin names here are illustrative) and compile to the raw opcodes shown when you expand them. Preimages are hashed with real keccak-256; CHECKSENDER is simulated by the checkbox, and STATICCALL, which is still in development, is emulated by the payments slider. Value leaves the runner only through TRANSFERNATIVE; a TRAP, running past the step limit or ending without RETURN reverts everything; the same inputs always give the same outcome.

          In the car-loan example the escrow would be the car’s NFT, transferred with a contract call. The demo shows it as ETH so that the value is visible.

          See also

          References

          1. GGuy, The future of atomic swaps, Zcash Community Forum. Quoted from the Milestone 2 user story in the official application. ↩