Write Solana programs in Python.

PythSol compiles a typed Python subset to a native SBF program and an Anchor-style IDL. It does not run your Python, and it does not generate Rust.

Get started Open the playground

program.py

def increment(authority: Signer, counter: Mut[Counter], by: u64) -> None:
    require(counter.authority == authority.key, CounterError.Unauthorized)
    counter.count += by

What the compiler writes

Signer. The authority must have signed.
Mut. The account must be writable, owned, and the right size.
u64. Arguments are length-checked and read little-endian.
require. A failure returns 6000 + index and the source line.
+= Integer math is checked. Overflow aborts.
IDL. The same model writes the IDL and a client.

Four commands

pythsol init

Writes pysol.toml, a program, and a LiteSVM test.

pythsol test

Builds the program and runs it in LiteSVM.

pythsol build

Writes the .so, the IDL, the generated C, and a client.

pythsol deploy

Runs solana program deploy. Mainnet needs --yes.

Playground

Check a program and read the C. Compile stays on this machine.

Try it

This is not a published package and not a token. Version 0.1.0. Compute-unit comparisons against Anchor are not claimed here.