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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sophi-0.2.0.tar.gz.
File metadata
- Download URL: sophi-0.2.0.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
222e0170e850bee47d75620eb18db0548919933ab8b9f3fd91956b4b7f11cd89
|
|
| MD5 |
66269e877f2a110d2ffbd9ecbcda6569
|
|
| BLAKE2b-256 |
56bb0cd1d03b0296f5fec89fc1b6c682ba031bc5d53ad61e129dcaa83be87ad2
|
File details
Details for the file sophi-0.2.0-py3-none-any.whl.
File metadata
- Download URL: sophi-0.2.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a512f9f1fd7f0539825d509c41a8288aaffea54612772ade7bd5df2345de2244
|
|
| MD5 |
e30d42155342dbd26211296cd696a205
|
|
| BLAKE2b-256 |
61c605ffa38dce161c76ba99afeb3aa4ca527f833207867f31bd3a0c0ecd5955
|