Skip to main content

A simple language for Bitcoin non-custodial smart contracts

Project description

Sophi

A simple language for Bitcoin non-custodial smart contracts.

Sophi is not a smart contract language like Solidity. It has no runtime, no blockchain execution, and no custody of funds. You describe what a fair exchange looks like — and Sophi proves it is mathematically valid.

Install

pip install sophi

Write a swap

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

  after:
    alice = 50000 USDT
    bob = 0.5 BTC
}

Save as trade.sph and run:

sophi compile trade.sph

That's it. Sophi checks that no value was created or destroyed. If the math holds, it produces a validity proof. If not, you get a clear error — before anything touches a network.

Works for any number of participants

swap {
  before:
    alice = 0.5 BTC
    bob = 50000 USDT
    carol = 1 ETH

  after:
    alice = 50000 USDT
    bob = 1 ETH
    carol = 0.5 BTC
}

2 people, 3, 8, or any number. Sophi handles it automatically.

How it works

Every Sophi program is a mathematical statement:

sum(before) == sum(after)

Alice's 0.5 BTC plus Bob's 50000 USDT before must equal Alice's 50000 USDT plus Bob's 0.5 BTC after. No value created. No value destroyed. The math either holds or it doesn't.

Sophi verifies this off-chain and produces a proof. That proof is then used to settle on Bitcoin, Lightning, or any network — where funds stay under the users' control until the moment of execution.

The four primitives

These exist under the hood. You never write them — Sophi infers them from your swap.

Resource — anything with value. BTC, USDT, ETH, or any asset you name.

State — who holds what. before and after are states.

Rule — the conservation law. sum(before) == sum(after). Always verified automatically.

Proof — the output. A portable JSON that any system can consume to coordinate settlement.

Proof output

{
  "status": "valid",
  "rule": "sum(before) == sum(after)",
  "before": {
    "alice": "0.5 BTC",
    "bob": "50000 USDT"
  },
  "after": {
    "alice": "50000 USDT",
    "bob": "0.5 BTC"
  }
}

This proof is portable. Bitcoin, Lightning, your own backend — any system can consume it to coordinate settlement without trusting a third party.

Why not Solidity?

Sophi Solidity
Holds funds Never Yes
Executes on-chain No Yes
Reentrancy attacks possible No — impossible by design Yes
Anyone can read it Yes Partial
Network independent Yes Ethereum only
Formally verifiable Yes No

The DAO hack, Wormhole, Ronin — all were possible because smart contracts hold funds and execute arbitrary code. Sophi eliminates both. You cannot write a custodial program in Sophi because the language has no concept of custody.

Independent from any platform

Sophi is a standalone language. It does not depend on any specific platform, exchange, or settlement system. The proof it produces can be used by anyone.

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.1.tar.gz (16.2 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.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sophi-0.2.1.tar.gz
  • Upload date:
  • Size: 16.2 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.1.tar.gz
Algorithm Hash digest
SHA256 da391ff8e5900751c5d07b3b81f81b9c4ee99b38c5a2badc27e9173e41812a68
MD5 acaeeff8af3f576c9e702ed322999e50
BLAKE2b-256 d5867c0d55d686c9ed0ace07867517d3fecda0a4da33124a6898fdd9f506c74b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sophi-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b82f6aea9308d6e477c607ff41ddbd2f947ddf29901c748989c4b17e89c77dad
MD5 95991cc981113983fc9f591f9972f64a
BLAKE2b-256 ccbf553560017c1d15c662b4302ded28fe1356589bca2b35177dca59151d6149

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