Solidity to EVM bytecode compiler via Venom IR. Compiles Solidity source code through an alternative compilation pipeline: Solidity → Yul → Venom IR → EVM bytecode.
- Python 3.11+
- solc (Solidity compiler)
- Vyper repository (for Venom IR infrastructure)
# Clone the repository
git clone https://github.com/yourorg/yul-to-venom.git
cd yul-to-venom
# Clone Vyper (required for Venom IR)
git clone https://github.com/vyperlang/vyper.git ../vyper
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Install Vyper dependencies
pip install -r ../vyper/requirements.txtsource .venv/bin/activate
# Compile a Solidity file to bytecode
PYTHONPATH=../vyper:. python -m yul_to_venom.cli.solvenom MyContract.sol
# Output Venom IR instead of bytecode
PYTHONPATH=../vyper:. python -m yul_to_venom.cli.solvenom MyContract.sol --venom
# Output assembly
PYTHONPATH=../vyper:. python -m yul_to_venom.cli.solvenom MyContract.sol --asmpython -m yul_to_venom.cli.solvenom <solidity_file> [options]
| Flag | Output |
|---|---|
| (default) | Bytecode as hex string |
--venom |
Venom IR |
--asm |
EVM assembly |
--json |
JSON with bytecode, ABI, IR, and assembly |
--abi |
ABI only (JSON array) |
| Flag | Description |
|---|---|
--contract NAME |
Compile specific contract by name |
--all |
Compile all contracts in the file |
| Flag | Description |
|---|---|
--base-path PATH |
Root directory for import resolution |
-I PATH |
Additional include directory (can repeat) |
-r MAPPING |
Import remapping, e.g. @openzeppelin/=lib/openzeppelin/ |
Remappings are auto-loaded from remappings.txt if present in the base path or input file directory.
| Flag | Description |
|---|---|
-o FILE |
Write output to file instead of stdout |
-l NAME=ADDR |
Link library at address (can repeat) |
--no-optimize |
Disable optimization |
--evm-version VER |
Target EVM version (default: cancun) |
--solc PATH |
Path to solc binary |
--vyper-path PATH |
Path to Vyper repository |
-v |
Verbose output |
# Compile and output bytecode
python -m yul_to_venom.cli.solvenom contracts/Token.sol
# Compile specific contract from multi-contract file
python -m yul_to_venom.cli.solvenom contracts/Token.sol --contract ERC20
# Save bytecode to file
python -m yul_to_venom.cli.solvenom contracts/Token.sol -o Token.bin# Using base-path for node_modules resolution
python -m yul_to_venom.cli.solvenom src/MyToken.sol --base-path .
# Using explicit remapping
python -m yul_to_venom.cli.solvenom src/MyToken.sol \
-r "@openzeppelin/=node_modules/@openzeppelin/"Create a remappings.txt file:
@openzeppelin/=node_modules/@openzeppelin/
@chainlink/=node_modules/@chainlink/
Then compile (remappings are auto-detected):
python -m yul_to_venom.cli.solvenom src/MyToken.sol --base-path .python -m yul_to_venom.cli.solvenom contracts/MyContract.sol \
-l SafeMath=0x1234567890abcdef1234567890abcdef12345678# Get full compilation output as JSON
python -m yul_to_venom.cli.solvenom contracts/Token.sol --json
# Compile all contracts to JSON
python -m yul_to_venom.cli.solvenom contracts/Token.sol --all --jsonJSON output includes:
{
"contractName": "Token",
"fullyQualifiedName": "contracts/Token.sol:Token",
"bytecode": "0x608060...",
"abi": [...],
"venomIR": "...",
"assembly": "..."
}SolVenom uses an alternative compilation pipeline:
- Solidity → Yul: Uses
solcto compile Solidity to Yul IR - Yul → Venom IR: Translates Yul AST to Vyper's Venom IR
- Venom IR → Bytecode: Uses Vyper's backend for optimization and code generation
This approach leverages Vyper's Venom IR optimizer, which can produce different (sometimes smaller) bytecode compared to solc's native output.
# Run all tests
python -m pytest
# Run SolVenom CLI tests
python -m pytest test_solvenom.py -vcancun(default)shanghaiparislondon- And other versions supported by both solc and Vyper
See LICENSE file for details.