Skip to content

A fast Solidity compiler for EVM simulations, written in TypeScript

License

Notifications You must be signed in to change notification settings

kyscott18/allegedly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Allegedly

A fast Solidity compiler for EVM simulations, written in TypeScript.

Overview

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.

Supported Language Features

Built-in

  • 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

Contracts

  • interface I { }
  • contract C { }
  • new c()
  • new C{ salt }()

Types

  • 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

Statements

  • if (x) { }
  • for (x; x < 10; x++) { }
  • while (x) {}
  • do { } while (x)
  • break
  • continue
  • return
  • unchecked { }
  • try / catch

Expressions

  • 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

Variables

  • constant
  • immutable
  • storage
  • memory
  • calldata
  • =
  • (x, y) = ...
  • +=
  • -=
  • *=
  • /=
  • %=
  • &=
  • |=
  • ^=
  • <<=
  • >>=

Functions

  • fn()
  • fn{ value: }()
  • fn({x: x})
  • pure
  • view
  • payable
  • external
  • public
  • internal
  • private
  • constructor
  • receive
  • fallback
  • overloading
  • modifers
  • return variables

Data locations

  • memory
  • calldata
  • returndata
  • storage
  • transient storage

Directives

  • import "file.sol";
  • pragma solidity major.minor.patch;
  • // SPDX-License-Identifier: ...
  • using UserType for {type};

Address

  • {address}.balance
  • {address}.code
  • {address}.codehash
  • {address}.call()
  • {address}.delegateCall()
  • {address}.staticCall()
  • {address payable}.send()
  • {address payable}.transfer()

Arrays

  • {array}.length
  • {array}.push()
  • {array}.pop()

Literals

  • hex""
  • unicode""

Units

  • wei
  • gwei
  • ether
  • seconds
  • minutes
  • hours
  • days
  • weeks

Errors

  • none

Events

  • none

Modifiers

  • none

Yul

  • none

Inheritance

  • none

Miscellaneous

Architecture

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
Loading

About

A fast Solidity compiler for EVM simulations, written in TypeScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published