0.0.19 ā€¢ Published 3 months ago

shakedex v0.0.19

Weekly downloads
64
License
MIT
Repository
github
Last release
3 months ago

CircleCI Discord

šŸ¤šŸ’° shakedex šŸ’°šŸ¤

A decentralized exchange for Handshake names.

How It Works

The underlying protocol is based on the non-interactive name swap construction created by @tynes. It works like this:

  1. Alice transfers one of her names to a locking script that prevents it from being spent anywhere except another transfer.
  2. Alice crafts a presigned transaction that signs over the following inputs and outputs:
    • Input: Her FINALIZE output from the transfer in step 1.
    • Output: An output back to herself valued at whatever she wants to sell the name for.
  3. Alice distributes the presigned transaction wherever she sees fit.
  4. Bob takes the presigned transaction, adds an input to fund Alice's sale price, an output transferring the name to him, and a change output if necessary.
  5. Bob signs the transaction and broadcasts it. He can now FINALIZE the transfer whenever he sees fit.

shakedex automates the above flow, and adds an auction layer on top. By creating a set of presigned transactions with decreasing sale prices but increasing lock times, shakedex creates a fully decentralized reverse-Dutch auction system that allows names to be bought and sold without intermediaries.

Installation

To install shakedex:

npm i -g hsd	# required, min hsd v6.0.0
npm i -g shakedex

For shakedex to work, you'll need a Handshake node running somewhere. You can use Bob Wallet (just remember to set your API key), or run hsd in a background process. Make sure to start your HSD node with --index-tx.

Usage

āš ļø Warning: Shakedex generates its own public/private keys to sign/redeem auction presigns. These keys are stored in ~/.shakedex. Remember to back up this folder - without it, you risk losing funds.

shakedex has a command line interface. CLI usage is documented by running shakedex --help.

The workflow to create a swap is as follows:

Selling a Name

1. Transfer the name to the locking script.

Run shakedex transfer-lock <name>. This will initiate the transfer to the locking script. You may be asked for your wallet passphrase.

Wait 48 hours for the transfer lockup to expire.

2. Finalize the transfer to the locking script.

Run shakedex finalize-lock <name>. Wait 15 minutes for the transaction to confirm.

3. Generate Presigns

Run shakedex create-auction <name>. This will walk you through the process of creating an auction. You will choose:

  1. The starting price, which should be very high.
  2. The ending price, which should be the lowest price you are willing to accept for the name.
  3. The duration of the auction.
  4. A location on disk to put the presigns.

This will output a file containing a set of newline-delimited JSONs. These JSONS are the "swap proofs" Bob will use to validate the auction. They are time-locked, so you can release them all at once.

4. Distribute Presigns

The CLI will offer to upload your presigns to ShakeDex Web, a website that displays Shakedex swap proofs.

You can also opload the presigns file wherever presign files are found.

Buying a Name

1. Download Presigns

Download a presigns file from wherever presign files are found.

2. Fulfill the Auction

Run shakedex fulfill-auction <path to presigns file>. This will find the lowest non-timelocked price and fulfill it using funds from your wallet. You may be asked for your passphrase.

Wait 48 hours for the transfer lockup to expire.

3. Finalize the Auction

Run shakedex finalize-auction <name>. Wait 15 minutes for the transaction to confirm.

The auction is now complete!

Viewing Auction/Fulfillment Info

You can see your list of active auctions by running shakedex list-auctions. The output looks something like this:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ Name   ā”‚ Status           ā”‚ Transfer Broadcast  ā”‚ Transfer Confirmed  ā”‚ Finalize Broadcast  ā”‚ Finalize Confirmed  ā”‚ Start Price ā”‚ End Price ā”‚ Current Price ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ monk   ā”‚ AUCTION_LIVE     ā”‚ 2021-02-06 02:34:16 ā”‚ 2021-02-06 02:35:12 ā”‚ 2021-02-06 02:40:39 ā”‚ 2021-02-06 02:41:05 ā”‚ 100.000000  ā”‚ 1.000000  ā”‚ 95.875000     ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ stonks ā”‚ FINALIZE_MEMPOOL ā”‚ 2021-02-06 03:40:40 ā”‚ 2021-02-06 03:42:30 ā”‚ 2021-02-06 03:42:41 ā”‚ -                   ā”‚ -           ā”‚ -         ā”‚ -             ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Similarly, you can see the list of names you have bought by running shakedex list-fills. The output looks something like this:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¬ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”
ā”‚ Name ā”‚ Status                     ā”‚ Price      ā”‚ Fulfill Broadcast   ā”‚ Fulfill Confirmed   ā”‚ Finalize Broadcast  ā”‚ Finalize Confirmed  ā”‚
ā”œā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¼ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”¤
ā”‚ honk ā”‚ FULFILL_FINALIZE_CONFIRMED ā”‚ 100.000000 ā”‚ 2021-02-06 02:42:26 ā”‚ 2021-02-06 02:50:51 ā”‚ 2021-02-06 02:51:50 ā”‚ 2021-02-06 02:51:54 ā”‚
ā””ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”“ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”˜

Errata

FAQ

How does the locking script work?

Essentially, it uses Handshake's OP_TYPE opcode to return OP_RETURN whenever someon tries to spend a lockd name to a RENEW, REVOKE, or UPDATE output.

You can see the script working for yourself by checking out the swap script tests.

Can I cancel a name transferred to the locking script?

Yes, but you will either need to wait for me to implement a feature for that in shakedex or figure out the right code to unlock the locking script on your own.

Can I use hsd/Bob to manage the names I buy using shakedex?

Yes, you can. Once the transfer has been FINALIZEd, the name can be managed using Bob, HSD, or any other wallet of your choice.

Design Goals

  1. The project should function both as a CLI tool and as a library.
  2. The library should use Handshake's RPC/REST API rather than direct wallet/node DB access.
  3. Minimize the amount of state stored on disk.

Development Status

Alpha Software That Works On My Machine šŸ’«

0.0.19

3 months ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

3 years ago

0.0.14

3 years ago

0.0.15

3 years ago

0.0.13

3 years ago

0.0.12

3 years ago

0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago