py0g

Python-first smart contract toolkit: Write, compile & deploy on 0g using pure Python.

py0g banner

About

py0g is a revolutionary Python-first smart contract development toolkit that democratizes Web3 by enabling developers to write, compile, and deploy smart contracts using pure Python, no Solidity required.

The Problem: The Web3 ecosystem faces a massive developer adoption barrier with 15+ million Python developers worldwide, but fewer than 50,000 Solidity developers. This language barrier locks out the vast majority of developers from building on-chain applications, particularly those in AI/ML, data science, and traditional web development who are fluent in Python but intimidated by Solidity's complexity.

Our Solution: py0g bridges this gap by providing a complete Python-to-EVM compilation pipeline that generates genuine EVM bytecode (137-349 bytes) from Python smart contracts. Developers can write contracts using familiar Python classes, methods, and data structures, then deploy them to any EVM-compatible blockchain in future(as of now 0g chain).

Key Features:

> Real EVM Bytecode Compilation: Generates actual EVM opcodes, not simulation or interpretation > Complete CLI Toolkit: 10+ commands covering the entire development lifecycle (compile, hash, prove, deploy, verify, debug) > Step-Through Debugger: Debug smart contracts like Python scripts with gas tracking > Security-First Design: Built-in validation prevents dangerous operations and follows security best practices > Production Templates: Pre-built contracts for tokens, DEX, and DAOs > Live Deployments: Successfully deployed contracts on 0G Galileo testnet with verified transactions

Impact & Innovation: py0g represents a 30x expansion of the potential Web3 developer ecosystem. By eliminating the Solidity learning curve, we enable Python developers to immediately start building on-chain applications, bringing their expertise in AI, data science, and web development directly to blockchain.

Live Proof of Concept

Our toolkit has successfully deployed live contracts on 0G Galileo testnet:

STRK token: txn hash "0xeb861a0f96c7b886d49a4bdbe5f9498d460ea77435a1b19054d89b6f6807135a" (79,992 gas used) StakingContract: txn hash "0x7bb9f3bfd00f57222629096e15e2ec5116f577037c750746fb2e0715cebf94f4" (125,114 gas used) These contracts are fully functional and can be interacted with using our universal contract interactor tool.

How it's made

py0g is a revolutionary Python-first smart contract development toolkit that democratizes Web3 by enabling developers to write, compile, and deploy smart contracts using pure Python, no Solidity required.

The Problem: The Web3 ecosystem faces a massive developer adoption barrier with 15+ million Python developers worldwide, but fewer than 50,000 Solidity developers. This language barrier locks out the vast majority of developers from building on-chain applications, particularly those in AI/ML, data science, and traditional web development who are fluent in Python but intimidated by Solidity's complexity.

Our Solution: py0g bridges this gap by providing a complete Python-to-EVM compilation pipeline that generates genuine EVM bytecode (137-349 bytes) from Python smart contracts. Developers can write contracts using familiar Python classes, methods, and data structures, then deploy them to any EVM-compatible blockchain in future(as of now 0g chain).

Key Features:

> Real EVM Bytecode Compilation: Generates actual EVM opcodes, not simulation or interpretation > Complete CLI Toolkit: 10+ commands covering the entire development lifecycle (compile, hash, prove, deploy, verify, debug) > Step-Through Debugger: Debug smart contracts like Python scripts with gas tracking > Security-First Design: Built-in validation prevents dangerous operations and follows security best practices > Production Templates: Pre-built contracts for tokens, DEX, and DAOs > Live Deployments: Successfully deployed contracts on 0G Galileo testnet with verified transactions

Impact & Innovation: py0g represents a 30x expansion of the potential Web3 developer ecosystem. By eliminating the Solidity learning curve, we enable Python developers to immediately start building on-chain applications, bringing their expertise in AI, data science, and web development directly to blockchain.

Live Proof of Concept

Our toolkit has successfully deployed live contracts on 0G Galileo testnet:

STRK token: txn hash "0xeb861a0f96c7b886d49a4bdbe5f9498d460ea77435a1b19054d89b6f6807135a" (79,992 gas used) StakingContract: txn hash "0x7bb9f3bfd00f57222629096e15e2ec5116f577037c750746fb2e0715cebf94f4" (125,114 gas used) These contracts are fully functional and can be interacted with using our universal contract interactor tool.

How It's Made

Core Architecture py0g is built as a multi-stage compilation pipeline that transforms Python source code into production-ready smart contracts: Python Source → AST Analysis → Security Validation → EVM Bytecode → Hash Generation → ZK Proof → Blockchain Deployment

Technical Implementation Stack

1. Python AST Compiler (compiler.py) > Technology: Python's built-in ast module for Abstract Syntax Tree parsing > Innovation: Custom BytecodeGenerator class that produces real EVM opcodes > Security: ContractValidator prevents dangerous imports (os, sys, subprocess) and function calls (eval, exec) > ABI Generation: Automatic interface generation with proper Solidity type mapping (int → uint256, str → string)

Particularly Hacky/Notable: We generate genuine EVM bytecode with proper function dispatching using 4-byte selectors, complete with deployment code that returns runtime code—essentially building a mini-Solidity compiler in Python.

2. EVM Bytecode Generation

> Target: London fork EVM with full compatibility > Opcodes: Real EVM instructions (PUSH1, MSTORE, CALLDATALOAD, RETURN, JUMPI) > Function Dispatch: Implements EVM function selector pattern with jump tables > Gas Optimization: Efficient bytecode generation produces contracts using 20-30% less gas than equivalent Solidity

3. Cryptographic Hash System (hasher.py) > Algorithm: SHA3-256 for deterministic program identification > Normalization: Source code preprocessing for reproducible builds > Components: Hashes normalized source + bytecode + compiler version for integrity

4. Zero-Knowledge Proof System (prover.py) > Curve: BN254 elliptic curve (Ethereum-compatible) > System: Groth16 implementation for trustless verification > Circuit: ~1000-5000 constraints for typical contracts > Innovation: Enables trustless contract verification without revealing source code

5. Blockchain Integration (deployer.py)

> Library: Web3.py for 0G Galileo blockchain interaction > Network: 0G Galileo testnet (Chain ID: 16602) - AI-optimized blockchain > Gas Estimation: Dynamic calculation based on bytecode analysis > Transaction Management: Full deployment pipeline with receipt tracking

6. Universal Contract Interactor (contract_interactor.py) > Innovation: Works with any deployed py0g contract automatically > ABI Discovery: Automatic ABI loading from compilation artifacts > Interactive Mode: Command-line interface for real-time contract interaction > Multi-Network: Supports any EVM-compatible chain

In our submission, AI tools were extensively leveraged across various aspects of the py0g project; specifically, they assisted in generating and refining key code components such as the Python-to-EVM bytecode compiler (compiler.py), the cryptographic hash system (hasher.py), and the zero-knowledge proof circuits (prover.py)

Partner Technology Integration

1. 0G Galileo Blockchain Benefit: AI-optimized blockchain perfect for our Python-first vision Features: Low gas costs, fast finality, AI compute integration Integration: Native RPC connectivity with optimized gas estimation

2. Web3.py Library

Benefit: Mature Python blockchain library with extensive EVM support Usage: Transaction construction, account management, contract interaction Why Chosen: Seamless Python integration vs building custom blockchain clients

Particularly Hacky/Notable Implementations 1. AST-to-EVM Translation We built a custom transpiler that maps Python's object-oriented concepts directly to EVM: Python classes → Contract interfaces Instance methods → Public functions Class variables → Contract storage Method parameters → Function arguments with type validation

2. Function Selector Generation

Implemented Ethereum's function selector algorithm in Python:

3. EVM Stack Management

Our bytecode generator maintains proper EVM stack state across function calls: PUSH operations for loading data POP operations for cleanup JUMPI for conditional logic Proper memory layout with MSTORE/MLOAD

4. Visual Debugger Integration

Built a step-through debugger that simulates EVM execution: Line-by-line Python execution mapping Gas consumption tracking per operation Stack and memory state visualization Breakpoint support for complex debugging

5. Template System

Created a modular template system with production-ready contracts: Token Contracts: ERC-20 compatible with advanced features DAO Governance: Voting and proposal systems

Development Challenges Solved

Type System Mapping: Bridging Python's dynamic typing with EVM's static types Memory Management: Mapping Python objects to EVM storage slots Security Constraints: Preventing dangerous operations while maintaining Python flexibility Gas Optimization: Generating efficient bytecode comparable to hand-optimized Solidity Deterministic Compilation: Ensuring identical source produces identical bytecode across environments

Architecture Innovation

The modular design allows each component to work independently: Compiler can be used without deployer Verifier works with any py0g-compiled contract Debugger operates on source code without blockchain interaction Hash system enables offline verification

This architecture makes py0g not just a compiler, but a complete smart contract IDE that brings the Python development experience to Web3.

From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

No public repo linked, so we can't tell.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

SoliCode

Interactive Solidity development environment combining smart contract compilation, testing and Jupyter notebook functionality. Build, test and deploy blockchain applications with ease.

NearCraft

Unlock the power of NEAR blockchain with our AI toolkit! Seamlessly deploy smart contracts, optimize performance, and enhance security. Empower your development with cutting-edge AI features tailored for the NEAR ecosystem