Skip to main content
You’re viewing an old version of the Arkade contracts documentation. Go to Your first contract for the current version.
This contract is an experimental compiler example. Do not fund it with real funds.
A non-interactive swap lets a user lock one asset in a contract that pays out to anyone who delivers another asset in return. The user who funds the offer does not need to be online when someone fills it. Transaction introspection makes this safe: the contract checks the outputs of the spending transaction, so a filler cannot take the locked asset without paying. Arkade Intents settles routes whose endpoints both use arkade with a contract of this kind. Asset Swaps documents that contract. It has no expiry: the user cancels it at any time.

The contract

This is non_interactive_swap.ark from the compiler examples. makerPk is the user who funds the offer, and takerPk is whoever fills it. These are contract positions, not roles.
non_interactive_swap.ark
new SingleSig(makerPk) is the output script of a SingleSig contract for the maker’s key. Requiring it in output 0 makes sure the maker can spend what they receive. The contract checks only those two outputs. Fund it with exactly offerAmount of the offered asset: the filler decides where any extra value goes. The emulator runs swap and cancel before it cosigns, together with the operator. Arkade Compiler explains how covenants become paths.