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.3.tar.gz (16.8 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.3-py3-none-any.whl (18.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sophi-0.2.3.tar.gz
  • Upload date:
  • Size: 16.8 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.3.tar.gz
Algorithm Hash digest
SHA256 23e8164d23d5b559af78635118dfdfae3e50d3490e331e1ea9a02b745faf1863
MD5 3eeeea44e2f62d9801854758a7029d16
BLAKE2b-256 a7fabac9bed85bf2ee049619544a1b1f55eb7980e0d036ac435cbe44c2406104

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sophi-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 18.8 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f6e3b2a1acd5e05a60ff9df21eefc879e94964545c341191d06bd3a98a585d55
MD5 a21fcf0b4be900f4dba7c6ecb096e516
BLAKE2b-256 6ae77a22fc2e2329b27531ccdb026ee967fb384fda3b2d33ab10089ba4ca7cc0

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