Web interface for running Python on Solana mainnet.
Open index.html in a browser or deploy to any static hosting service.
Live Demo: The frontend is pre-configured for mainnet with program ID pythonKBk7JcXsbwYzMRy2tL8L9tZqUbgekxRfT1bTE
# Build and prepare for deployment
./deploy.sh
# Deploy to specific platforms
./deploy.sh --vercel # Deploy to Vercel
./deploy.sh --netlify # Deploy to Netlify
./deploy.sh --ipfs # Deploy to IPFS
# Or manually upload dist/ to any static hostnpx wrangler pages deploy dist --project-name=pikapython- Push the
frontenddirectory to a GitHub repository - Go to Settings → Pages
- Select branch and
/frontendfolder - Save
- Script Mode: Send Python code for on-chain parsing (~600K-1.4M CU)
- Bytecode Mode: Send pre-compiled bytecode (~20K-100K CU)
- Scratchpad Accounts: Create persistent storage accounts
- VFS API: Read/write account data with Python file operations
- Multi-wallet Support: Phantom, Solflare, Coinbase, Ledger, MetaMask, etc.
- CPI Support: Cross-program invocation to other Solana programs
Create accounts owned by PikaPython to store persistent data:
- Connect your wallet
- Click Create Scratchpad (costs ~0.001 SOL rent)
- The account is automatically added to your accounts list
- Use Python's VFS API to read/write:
# Write data
f = open("/sol/0", "w")
f.write("Hello Solana!")
f.close()
# Read data
f = open("/sol/0", "r")
data = f.read(64)
f.close()
print(data)Account indices map to the order in the accounts list:
/sol/0= first account/sol/1= second account- etc.
| Function | Description |
|---|---|
open("/sol/N", "r") |
Open account N by index (fast) |
open("/sol/N", "w") |
Open account N for writing |
open("/sol/<pubkey>", "r") |
Open account by base58 pubkey |
f.read(n) |
Read n bytes |
f.write(data) |
Write data, returns bytes written |
f.seek(pos) |
Seek to position |
f.tell() |
Get current position |
f.close() |
Close file |
Path Formats:
/sol/0,/sol/1- Index-based (fast, ~60K CU)/sol/<base58_pubkey>- Pubkey-based (~90K CU, includes base58 decode)
| Package | Functions |
|---|---|
solana |
slot(), epoch(), sha256(), keccak256(), cpi(), find_program_address() |
math |
sin(), cos(), sqrt(), pow(), log(), exp(), pi, e |
time |
time(), ctime(), gmtime(), localtime() |
json |
dumps(), loads() |
struct |
pack(), unpack(), calcsize() |
base58 |
b58encode(), b58decode() |
base64 |
b64decode() |
The frontend includes a WebAssembly compiler that compiles Python to bytecode in the browser:
- Switch to Bytecode mode
- Write Python code
- Click Compile
- Bytecode appears in the hex field
- Click Execute to run on-chain
Bytecode mode uses ~10-100x less compute units than script mode.
To rebuild the WASM compiler:
cd ../tools
./build_wasm.sh
cp pika_compile.js pika_compile.wasm ../frontend/Requires Emscripten SDK.