Skip to main content

A simple language for non-custodial value swaps

Project description

Sophi

A simple language for non-custodial value swaps.

Sophi has no runtime, no blockchain execution, and no custody of funds. You describe the swap. Sophi verifies the math and produces a portable proof.

Install

pip install sophi

Write a swap (from-to)

swap {
  transfer 0.5 BTC from alice to bob
  transfer 50000 USDT from bob to alice
}

Save as trade.sph and run:

sophi compile trade.sph

Before/after still works

swap {
  before:
    alice = 0.5 BTC
    bob = 50000 USDT

  after:
    alice = 50000 USDT
    bob = 0.5 BTC
}

Proof of possession (address + signature)

swap {
  transfer 0.5 BTC from alice to bob
  transfer 50000 USDT from bob to alice

  proof alice:
    address bc1qalice...
    signature H7f8c2d1e4b7...

  proof bob:
    address bc1qbob...
    signature K9d3e1f2a5c8...
}

Proof output

{
  "status": "valid",
  "conservation": {
    "BTC":  { "before": "0.5",   "after": "0.5"   },
    "USDT": { "before": "50000", "after": "50000" }
  },
  "delta": {
    "alice": { "BTC": "-0.5",  "USDT": "+50000" },
    "bob":   { "BTC": "+0.5",  "USDT": "-50000" }
  },
  "before": { "alice": "0.5 BTC",    "bob": "50000 USDT" },
  "after":  { "alice": "50000 USDT", "bob": "0.5 BTC"    },
  "htlc": {
    "secret_hash": "a3f8c2...",
    "timeout_blocks": 144,
    "legs": [
      { "from": "alice", "to": "bob",   "asset": "BTC",  "amount": "0.5"   },
      { "from": "bob",   "to": "alice", "asset": "USDT", "amount": "50000" }
    ]
  }
}

Why it is safe

  • Non-custodial by construction
  • No on-chain execution
  • Conservation per asset
  • Delta per participant

License

Business Source License 1.1 - converts to Apache 2.0 after 4 years.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sophi-0.2.4.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sophi-0.2.4-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file sophi-0.2.4.tar.gz.

File metadata

  • Download URL: sophi-0.2.4.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sophi-0.2.4.tar.gz
Algorithm Hash digest
SHA256 3686fa977537685d51e785a54f321b8fa1c947c22758f93c15fe0e55784930fa
MD5 c86f6a40726112573735522d6f86cf87
BLAKE2b-256 7ad4af91bfe35b27633f29cf5e47b4ebeb32a061f6d5b884bb0f61c65bab1544

See more details on using hashes here.

File details

Details for the file sophi-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: sophi-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for sophi-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9597790be154488795c23889e9487b776ead94fb0dda01217084ffc83bcb7aae
MD5 048e45a86c095cdb56e0055df0d9cf21
BLAKE2b-256 17b285cdfdbd6cf372fa19c4791b25c837b6b5d011f4e16d52945f9a6ff318c6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page