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}() -
address() -
payable() -
bool() -
string() -
bytes() -
abi.encode() -
abi.encodePacked() -
abi.encodeWithSelector() -
abi.encodeWithSignature() -
abi.encodeCall() -
abi.decode() -
bytes.concat() -
string.concat() -
keccak256() -
sha256() -
ripemd160() -
ecrecover() -
addmod() -
mulmod() -
this -
super -
selfDestruct() -
type().name -
type().creationCode -
type().runtimeCode -
type().interfaceId -
type().min -
type().max -
blockHash() -
blobHash() -
gasleft() -
block.basefee -
block.blobbasefee -
block.chainid -
block.coinbase -
block.difficulty -
block.gaslimit -
block.number -
block.prevrandao -
block.timestamp -
msg.data -
msg.sender -
msg.sig -
msg.value -
tx.gasprice -
tx.origin
-
interface I { } -
contract C { } -
new c() -
new C{ salt }()
-
uint{size} -
int{size} -
bytes{size} -
address -
address payable -
bool -
string -
bytes -
struct S { } -
enum E { } -
mapping -
{type}[](array type) -
Contract c(contract type) -
type C is V;(user defined value type) - function type
-
ufixedMxN -
fixedMxN
-
if (x) { } -
for (x; x < 10; x++) { } -
while (x) {} -
do { } while (x) -
break -
continue -
return -
unchecked { } -
try/catch
-
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
-
constant -
immutable -
storage -
memory -
calldata -
= -
(x, y) = ... -
+= -
-= -
*= -
/= -
%= -
&= -
|= -
^= -
<<= -
>>=
-
fn() -
fn{ value: }() -
fn({x: x}) -
pure -
view -
payable -
external -
public -
internal -
private -
constructor -
receive -
fallback - overloading
- modifers
- return variables
- memory
- calldata
- returndata
- storage
- transient storage
-
import "file.sol"; -
pragma solidity major.minor.patch; -
// SPDX-License-Identifier: ... -
using UserType for {type};
-
{address}.balance -
{address}.code -
{address}.codehash -
{address}.call() -
{address}.delegateCall() -
{address}.staticCall() -
{address payable}.send() -
{address payable}.transfer()
-
{array}.length -
{array}.push() -
{array}.pop()
-
hex"" -
unicode""
-
wei -
gwei -
ether -
seconds -
minutes -
hours -
days -
weeks
-
none
-
none
-
none
- none
- none
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