Write Solana programs in Python.

PythSol checks a typed Python subset, lowers it to C, and compiles native SBF bytecode — with an Anchor-style IDL, a solders client, and LiteSVM tests. Nothing here runs your code.

shell
pip install git+https://github.com/PythSol/pythsol.gitpythsol init my-program

Straight from the repository — PythSol is not on PyPI yet.

counter.py
@instructiondef initialize(authority: Signer, counter: Init[Counter], bump: u8) -> None:    counter.authority = authority.key    counter.count = 0    counter.bump = bump
0 diagnostics CIDLclient
Real lines from examples/counter: a typed instruction with account roles the compiler can enforce.
Scroll to the pipeline

From .py to .so, checked at every step

Each stage draws on the same checked definition of your program — no phase re-parses it with different rules.

Write

Instructions, accounts, errors in one .py. → program.py

Check

PSxxxx diagnostics with file, line, column. → a clean list, or a fix

Emit C

Readable C with runtime checks, per source line. → program.c

Build .so

Native SBF via Solana clang — cached, byte-identical. → program.so

Ship

Anchor-style IDL + solders client + manifest. → your client

You write — from examples/counter/programs/counter.py

counter.py
@instruction
def increment(authority: Signer, counter: Mut[Counter], by: u64) -> None:
    """Add `by` to the count; only the stored authority may call this."""
    require(counter.authority == authority.key, CounterError.Unauthorized)
    counter.count += by

The compiler writes

counter.c — excerpt
static uint64_t pyf_increment(RtCtx *rt) {
    /* (data-length checks: omitted in this excerpt) */
    /* 2. accounts: 2 role-checked in declared order */
    RtAccount *acc_authority = &rt->accounts[0u];
    if (!acc_authority->is_signer) {
        rt_fail_log(1001u, "counter.py", 49u, "signer required: authority");
        return 1001u;
    }
    /* … writable, owner, size, and discriminator checks follow … */
    uint64_t rt_t2 = 0u;
    rt_ld_u64(acc_counter->data, 40u, &rt_t2);
    uint64_t rt_t3;
    uint64_t rt_t4 = rt_checked_add_u64(rt_t2, dp_by, &rt_t3);
    if (rt_t4 != RT_OK) {
        rt_fail_log(rt_t4, "counter.py", 52u, "checked add (u64)");
        return rt_t4;
    }
    rt_st_u64(acc_counter->data, 40u, rt_t3);
    return 0u; /* RT_OK */
}
        
The counter account, as increment reads it
discriminator · 8 B authority · 32 B count · 8 B bump · 1 B RT_SIZE_COUNTER = 49

Straight from the emitted C: rt_ld_u64(acc_counter->data, 40u, …) loads count, and RT_OFF_COUNTER_BUMP is 48.

Both chunks are real: the Python lines are the increment instruction from examples/counter, and the C is what the compiler emits for them — accounts role-checked, discriminator verified, arithmetic overflow guarded, every failure attributed to a source line. Read the full C in the playground (Check, then the C tab).

What PythSol gives you

on this site runs from the page here; in your terminal needs the pythsol CLI and its toolchain.

on this site

Checked, not executed

The site parses your AST and type-checks accounts, seeds, and lamports — your Python is never executed in the browser.

in your terminal

Native, not WASM

clang targets the Solana SBF backend directly, so pythsol build produces a real, deployable program with verifiable bytecode.

on this site in your terminal

IDL + client included

Every build emits an Anchor-style IDL and a solders client. Show them in the playground's result tabs, or let pythsol build write them to disk.

in your terminal

LiteSVM tests

pythsol test runs the real bytecode in-process with LiteSVM — no validator, no network, no RPC cost.

in your terminal

Workflow tools

Faucet, deploy, wallet, verify, port, and profiling ship in the CLI — no extra glue is needed.

language

Solana-native types

PDAs with seeds, token and ATA CPI guards, lamport moves, and data enums are part of the language, not an afterthought.

Try it in the browser

No install. Pick an example, run Check for PSxxxx diagnostics with file, line, and column, then open the tabs to read the generated C, the IDL, and the solders client. Nothing on the page runs your Python.

Learn from working programs

Six examples ship with tests written against the real bytecode — read them locally or follow the walkthroughs.

Counter

start here

One PDA. initialize stores the authority. increment adds a u64 when the signer matches.

accountpdarequireerror

Ledger

FixedArray

FixedArray of four u64 slots, a deposit, an if/else apply, and a for-range fill.

FixedArrayiffor

Vault

lamports

Lamport PDA. deposit uses system_transfer. close returns the lamports to the authority.

SeedsHasOneCloseTosystem_transfer

Escrow

two parties

One lamport deal. make funds the PDA, take pays the maker and closes to the taker, cancel closes to the maker.

SeedsCloseTosystem_transfer

Multisig treasury

2 of 3

Owners approve a payout; the PDA signs the lamport transfer and approvals reset after release.

FixedArrayPubkeySeedsbitmask

Poll

one vote each

Four allowlisted voters. A u8 bitmask records who voted; yes and no counts live on the account.

FixedArrayboolbitmaskrequire

Local development

Eight commands from a fresh checkout

terminal
git clone https://github.com/PythSol/pythsol
cd pythsol
pip install -e ".[test]"
pythsol init app --template counter
cd app
pythsol check programs/app.py
pythsol test
pythsol build

Python 3.11+. Nothing else for check and test.

pythsol test runs the built bytecode in LiteSVM, in-process.

pythsol build needs the SBF platform tools — pythsol doctor names exactly what is missing on your machine.

Full quickstart → CLI reference

What pythsol build leaves on disk

counter.c line-attributed C
native .so SBF bytecode
IDL Anchor-style
client solders only
manifest.json ties them together

What PythSol is

  • A typed Python subset that a compiler can lower to C and native SBF bytecode.
  • A checker with stable PSxxxx diagnostics that carry file, line, and column.
  • A generator for an Anchor-style IDL, a solders client, and a build manifest.
  • A test runner — real bytecode in LiteSVM, offline and fast.

What it isn't

  • Not all of Python - no async, no f-strings, no stdlib imports on-chain. Comprehensions must be a fixed-range array initializer.
  • Not an interpreter: the site parses and type-checks, it never executes your Python.
  • No in-browser SBF compile — .so builds run where Solana's clang lives (your machine or Docker).
  • Not on PyPI yet — install from the repository.

Milestones, not dates

What ships next.

No launch dates. A milestone is done when its checks pass and the docs match the code.

  1. Shipped · 0.1.0

    Compiler and CLI

    Typed Python checked and lowered to C, native SBF builds, Anchor-style IDL, solders client, and LiteSVM tests.

  2. Shipped · live

    Playground and docs

    The in-browser checker, quickstart, language and accounts pages, and this site.

  3. In progress

    $PS token

    Launch on Pump.fun, with trading fees funding compiler and docs work. The contract address goes up on the token card.

  4. Later

    Mainnet path

    Deployment and verification hardening. Mainnet stays opt-in behind --yes, never the default.

$PS · community token

This is our token.

$PS is the PythSol token. Trading fees go back into development — the compiler, the docs, the examples, and this playground.

  • Fees fund development, not a team payout.
  • Launches on Pump.fun; buy from the button on this card.
  • Check the contract address here before every buy.

Contract address

Coming soon
Buy on Pump.fun

The address and the coin page go live at launch. $PS is not an investment or a claim on PythSol.

Questions worth asking

Does this site run my Python?

No. The playground sends your source to a checker that parses it and reports PSxxxx diagnostics. Emitting C is a pure transformation of the checked AST. Compiling to .so happens only on a machine with the SBF tools — loopback pythsol serve, Docker, or your workstation.

What's in the typed subset?

Annotated integers u8–u128 and i8–i128, bool, Pubkey, Signer, Mut/Init/Account, FixedArray, Option, FixedString, capacity-carrying Vec[T, N], unit @enum with match, @struct, @event + emit, plain helpers, and if/while/for over range. Compiler-known calls are require, len, range, emit, system_transfer, token_transfer, token2022_transfer, ata_create, and the width casts. Stdlib and third-party imports are refused. Full details on the Language page.

What does pythsol build write?

The generated C, the native SBF .so, an Anchor-style IDL, a solders client, and a manifest.json that ties them together. Rebuilds are cached and byte-identical for the same source.

How do tests run without a validator?

pythsol test executes the real program bytecode in-process through LiteSVM — no validator, no RPC, no airdrop. The four shipped examples all pass.

Can I deploy to mainnet?

pythsol deploy defaults to devnet. The CLI refuses mainnet unless you pass --yes, and the faucet never touches it. pythsol verify compares the on-chain bytecode against your local .so by hash.