| Crates.io | pyra-compiler |
| lib.rs | pyra-compiler |
| version | 0.1.0 |
| created_at | 2026-01-07 11:25:12.19919+00 |
| updated_at | 2026-01-07 11:25:12.19919+00 |
| description | A Pythonic Smart Contract Language for the EVM |
| homepage | |
| repository | https://github.com/DavidIfebueme/pyra |
| max_upload_size | |
| id | 2028061 |
| size | 108,244 |
A compiled, statically typed language with Python-like syntax. It compiles directly to EVM bytecode. The focus is clarity, safety, and predictable gas use.
Inspired by Python, but statically typed and compiled:
let total_supply: uint256 = 10000
def transfer(to: address, amount: uint256):
if amount > 0:
call_contract(to, amount)
mut for mutable stateconstuint256, int256, bool, address, bytesstruct (custom types)Vec<T> and Map<K, V> (compile-time optimized)Source Code (.pyra)
↓
Rust Lexer/Parser (logos + chumsky)
↓
AST + Type Checking + Verification (single pass)
↓
Direct EVM Bytecode Generation
↓
Optimized EVM Bytecode (.bin)
| Stage | Tooling/Tech | Notes |
|---|---|---|
| Lexer/Parser | logos + chumsky (Rust) | Zero-copy parsing and fast performance |
| AST + Type Checker | Custom Rust structs | Single-pass and memory efficient |
| Formal Verification | Z3 SMT solver integration | Supports proofs of correctness |
| Gas Estimator | Static analysis engine | Compile-time gas cost prediction |
| Code Generator | Direct EVM bytecode (Rust) | No external compiler dependency |
| CLI | clap (Rust) | pyra build contracts/MyToken.pyra |
Write high-level code that compiles to the same bytecode as hand-written versions:
# This generic function...
def safe_add<T: Numeric>(a: T, b: T) -> T:
return a + b
# ...generates identical bytecode to:
def add_uint256(a: uint256, b: uint256) -> uint256:
return a + b
# Compiler provides gas costs:
def transfer(to: address, amount: uint256): # Gas: 21,000 + 5,000 SSTORE
balances[msg.sender] -= amount # Gas: 5,000 SSTORE
balances[to] += amount # Gas: 20,000 SSTORE
def withdraw(amount: uint256):
require amount <= balances[msg.sender]
# @verify: balance_sum_invariant
# @verify: no_overflow_underflow
# @verify: reentrancy_safe
balances[msg.sender] -= amount
msg.sender.transfer(amount)
Type-safe code reuse without runtime cost:
# Generic data structures
struct Vault<T: Token> {
token: T,
balance: uint256
}
# Generic functions with constraints
def swap<A: ERC20, B: ERC20>(token_a: A, token_b: B, amount: uint256)
Built into the language:
def withdraw(amount: uint256):
# Automatically generates a reentrancy guard
balances[msg.sender] -= amount
msg.sender.transfer(amount) # Guarded by default
uncheckedpyra build ...)pyra/
├── compiler/ # Rust compiler codebase
│ ├── src/
│ │ ├── lexer.rs # logos-based lexer
│ │ ├── parser.rs # chumsky grammar
│ │ ├── ast.rs # AST definitions
│ │ ├── typer.rs # Type checker and inference
│ │ ├── verifier.rs # Formal verification (Z3)
│ │ ├── gas.rs # Gas estimation engine
│ │ ├── codegen.rs # Direct EVM bytecode generation
│ │ ├── security.rs # Reentrancy and security analysis
│ │ └── main.rs # CLI entry point
│ ├── Cargo.toml
│ └── build.rs
├── contracts/ # Example .pyra contracts
├── tests/ # Foundry/Hardhat integration tests
├── stdlib/ # Standard library (Pyra code)
├── README.md
└── docs/
| Week | Milestone |
|---|---|
| 1-2 | Rust lexer and parser plus basic AST |
| 3 | Type checker and generics |
| 4 | Direct EVM code generation and gas estimation |
| 5 | Formal verification and security analysis |
| 6 | CLI tool and working contracts |
# Install (crates.io)
cargo install --locked pyra-compiler
# If crates.io publish isn't done yet
# cargo install --locked --git https://github.com/DavidIfebueme/pyra pyra-compiler
# Compile example contracts
pyra build contracts/ERC20.pyra
pyra build contracts/Vault.pyra
Outputs:
<Contract>.abi<Contract>.binThe compiler includes Criterion benchmarks under compiler/benches/ to track lexer/parse/codegen performance.
Built by DavidIfebueme
This is an experimental project. Use at your own risk. Not production-ready until v1 is officially tagged and audited.