A fast Solidity compiler for EVM simulations, written in TypeScript.
import { sol } from "allegedly";
const depositContract = "0x...";
const { abi, code } = sol(`
contract GetBalance {
function run() external returns (uint256) {
return address(${depositContract}).balance;
}
}
`);
This project is not meant to replace solc
. Instead, it is a smaller, faster, more modular alternative, that produces less efficient and less secure bytecode.
-
uint{size}()
-
int{size}()
-
bytes{size}()
-
keccak256()
-
abi.encode()
-
abi.encodePacked()
-
address
-
uint{size}
-
int{size}
-
bytes{size}
-
string
-
bytes
-
bool
- tuple
- struct
- enum
- mapping
- array
- user-defined:
type UserType is uint256;
-
if (x) { }
-
for (x; x < 10; x++) { }
-
while (x) {}
-
do { } while (x)
-
break
-
continue
-
return
-
unchecked { }
-
x++
or++x
-
x--
or--x
-
-x
-
delete x
-
!x
-
~x
-
x + y
-
x - y
-
x * y
-
x / y
-
x % y
-
x ** y
-
x && y
-
x || y
-
x == y
-
x != y
-
x < y
-
x <= y
-
x > y
-
x >= y
-
x & y
-
x | y
-
x ^ y
-
x >> y
-
x << y
-
x ? y : z
- memory
- calldata
- returndata
- storage
- transient storage
-
import "file.sol";
-
pragma solidity major.minor.patch;
-
// SPDX-License-Identifier: ...
-
using UserType for {type}
-
assembly { }
graph TD
A[source code]
B[tokens]
C[ast]
D[type annotations]
E[bytecode + abi]
A -- lexer --> B
B -- parser --> C
C -- checker --> D
C -- compiler --> E
D -- compiler --> E