Bringing Ethereum Virtual Machine to StarkNet at warp speed!

Overview

Warp

Warp brings EVM compatible languages to StarkNet, making it possible to transpile Ethereum smart contracts to Cairo, and use them on StarkNet.

Table of Contents 📋

Installation ⚙️

Linux:

sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install -y python3.7
sudo apt install -y python3.7-dev
sudo apt install -y libgmp3-dev
python3.7 -m venv ~/warp_demo
source ~/warp_demo/bin/activate
pip install wheel
pip install ecdsa fastecdsa sympy
pip install cairo-lang==0.3.1
make warp

MacOs:

brew install [email protected]
brew install gmp
python3.7 -m venv ~/warp_demo
source ~/warp_demo/bin/activate
pip install wheel
pip install ecdsa fastecdsa sympy
pip install cairo-lang==0.3.1
make warp

Usage 💻

You can transpile your Solidity/Vyper contracts with:

warp transpile CONTRACT

To deploy the transpiled Cairo contract to Starknet use:

warp deploy CONTRACT.cairo

To invoke a public/external method use:

warp invoke --contract CONTRACT.cairo --address ADDRESS --function FUNCTION_NAME --inputs "INPUTS"

The --inputs flag requires its argument to be a string and have each value separated by a space.

You can check the status of your transaction with:

warp status TX_ID

Want to contribute? 👍

Your contributions are always welcome, see contribution guidelines.

License

Apache License Version 2.0, January 2004.

Comments
  • Add benchmarking for tests

    Add benchmarking for tests

    Adds an automation to make test_yul that benchmarks the number of steps per function invocation for each contract in a markdown called stats.md

    I've switched the number of workers in the MakeFile to 1 for the yul tests. This is to prevent concurrent writes to stats.json through stepsInFunction(). Will find a fix for this.

    Will be adding support for benchmarking contract sizes.

    opened by Glitch18 16
  • Error running warp transpile

    Error running warp transpile

    I am running macOS Monterey 12.0.1. I have followed the installation guide in the repository's README. For context, I also have a python venv in which I am using cairo which I can use to compile, deploy and interact with cairo contracts. I have also built docker containers for cairo and OpenZeppelin Nile which both appear to work without error at this time. I have built a docker container for warp (following the installation instructions in the README). I have also tried the warp installation on my Linux machine (Ubuntu 20.04) neither of which work and display the same error set out below.

    On my MacBook I have installed the following with brew:

    1. python3.7.12
    2. gmp
    3. boost

    I then created a new python venv activated it and installed sol-warp==0.2.15 with pip.

    Everything appears to install properly and without error. However, when I run warp transpile I get the following error:

    (sol-warp) # warp transpile ERC20.sol WARP Traceback (most recent call last): File "/Users/david/sol-warp/bin/warp", line 5, in from cli.warp_cli import main File "/Users/david/sol-warp/lib/python3.7/site-packages/cli/warp_cli.py", line 13, in from cli.commands import _deploy, _invoke, _status File "/Users/david/sol-warp/lib/python3.7/site-packages/cli/commands.py", line 13, in from starkware.starknet.services.api.contract_definition import ContractDefinition File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/starknet/services/api/contract_definition.py", line 9, in from starkware.cairo.lang.compiler.program import Program File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/program.py", line 10, in from starkware.cairo.lang.compiler.debug_info import DebugInfo File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/debug_info.py", line 10, in from starkware.cairo.lang.compiler.preprocessor.flow import FlowTrackingDataActual File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/preprocessor/flow.py", line 16, in from starkware.cairo.lang.compiler.references import FlowTrackingError, Reference File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/references.py", line 18, in from starkware.cairo.lang.compiler.fields import ExpressionAsStr File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/fields.py", line 4, in from starkware.cairo.lang.compiler.parser import parse_expr, parse_type File "/Users/david/sol-warp/lib/python3.7/site-packages/starkware/cairo/lang/compiler/parser.py", line 34, in propagate_positions=True, File "/Users/david/sol-warp/lib/python3.7/site-packages/lark/lark.py", line 355, in init assert_config(lexer, ('basic', 'contextual', 'dynamic', 'dynamic_complete')) File "/Users/david/sol-warp/lib/python3.7/site-packages/lark/exceptions.py", line 21, in assert_config raise ConfigurationError(msg % (value, options)) lark.exceptions.ConfigurationError: Got 'standard', expected one of ('basic', 'contextual', 'dynamic', 'dynamic_complete')

    Your help with this would be appreciated.

    opened by dkillen 13
  • No such file or directory: '_marked.sol'

    No such file or directory: '_marked.sol'

    System Version: Ubuntu 20.04 Python Version: 3.7.12 sol-warp Version: 0.5.1

    I am attempting to transpile a contract with the command "warp transpile ./loan.sol loan" from within the directory containing loan.sol, where loan is the name of the primary contract. I get the following error (with full traceback):

    ERROR: Compilation failed

    Traceback (most recent call last): File "/mnt/c/Blockchain/envs/warp/bin/warp", line 8, in sys.exit(main()) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/cli/warp_cli.py", line 162, in main warp() File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/click/core.py", line 1128, in call return self.main(*args, **kwargs) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/cli/warp_cli.py", line 45, in transpile output = transpile_from_solidity(file_path, contract_name) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/yul/main.py", line 77, in transpile_from_solidity output = get_for_contract(sol_src_path_modified, main_contract, ["abi"]) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/yul/utils.py", line 136, in get_for_contract get_source_version(sol_source) File "/mnt/c/Blockchain/envs/warp/lib/python3.7/site-packages/yul/utils.py", line 146, in get_source_version with open(sol_source) as f: FileNotFoundError: [Errno 2] No such file or directory: './loan_marked.sol'

    opened by hayden4r4 10
  • Use cleaner warp_output directory structure

    Use cleaner warp_output directory structure

    This changes the output from <solfile-root>__WC__<contract-name>.cairo to solfile.sol/contract.cairo which is similar to how artifacts are generated in hardhat and is much cleaner

    opened by JorikSchellekens 7
  • Cannot install warp: Docker image?

    Cannot install warp: Docker image?

    Hi There,

    Really cool project.

    I tried 3 separate ways of installing warp:

    • Big Sur (invalid OS issue)
    • In Docker (Ubuntu 18) => missing libc6 dependency, apparently only 21 has the right version
    • In Docker (Ubuntu 21) => fails at add-apt-repository ppa:deadsnakes/ppa

    Do you think it would make sense to provide a Dockerfile for reproducibility? I would happily provide one if I could get this to work.

    Here's what I did, I ran the command:

    docker run -it ubuntu:impish /bin/bash
    

    and then followed the sequence of steps in the README order.

    opened by Pet3ris 6
  • Got CLientConnectorCertiticateError while trying to access https://alpha4.starknet.io/gateway/add_transaction.

    Got CLientConnectorCertiticateError while trying to access https://alpha4.starknet.io/gateway/add_transaction.

    Environment:

    • OS: macOS Monterey v12.5.1
    • Python 3.7.9
    • Cairo version: 0.9.1
    • Warp Version: 2.1.0

    Description: I'm using. the example_contracts ERC20 to transpile the solidity code into cairo code, this generate a warp_output dir successfully with 3 files, ERC20__WC__WARP_abi.json, ERC20__WC__WARP_compiled.json, ERC20__WC__WARP.cairo and when I try to deploy the contract file I get this error:

    Captura de Pantalla 2022-08-31 a la(s) 22 38 31
    opened by ArturVargas 5
  • refac: starknetCli

    refac: starknetCli

    • refactored existing functions
    • created buildCairoCommand to generate starknet commands
    • created callCairoCommand that executes the execSync
    • broke down functions to be used for testing
    opened by syahirAmali 5
  • update deployment instruction in docs

    update deployment instruction in docs

    The current deployment instruction warp deploy <path to Cairo contract> returns an error when you call it. I updated it with the right deployment command.

    opened by jelilat 5
  • Implement return operation

    Implement return operation

    This PR instroduces the RETURN operation. It adds an additional return result to each segment and the run_to function. It's called an output. Per EVM specification, as soon as the output is requested, the contract should return a slice of memory and the execution should stop.

    The output is implemented as a 128-bit packed big-endian felt-array that is serialized to the output (for now) to enable verification of it.

    Other changes include tracking test files to properly regenerate bats.

    opened by murcake 4
  • Remove all compile repitions for multifile input

    Remove all compile repitions for multifile input

    We remove all redundancies in compile by deferring to solc. Solc produces a single linked ast for multiple file inputs so this resolves the full dependecy chain.

    There is a remarkable speed up to UniStark as a result of this pr.

    opened by JorikSchellekens 3
  • Transpile libraries

    Transpile libraries

    The idea here is to clone the ContractDefinition nodes of kind Library, and change its kind to Contract. This way, it does not interfere with the references to the Library node functions, and it transpiles the Library clone as a contract.

    opened by LuisLara-UH 3
  • Transcoding library

    Transcoding library

    Utils for translation between javascript and cairo should be abstracted into a library. Right now they are used as test utils exclusively.

    We could e.g. restructure the repo similarly to hardhat: https://github.com/NomicFoundation/hardhat/tree/main/packages.

    opened by piwonskp 0
  • Bump json5 from 2.2.1 to 2.2.3 in /docs

    Bump json5 from 2.2.1 to 2.2.3 in /docs

    Bumps json5 from 2.2.1 to 2.2.3.

    Release notes

    Sourced from json5's releases.

    v2.2.3

    v2.2.2

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).
    Changelog

    Sourced from json5's changelog.

    v2.2.3 [code, diff]

    v2.2.2 [code, diff]

    • Fix: Properties with the name __proto__ are added to objects and arrays. (#199) This also fixes a prototype pollution vulnerability reported by Jonathan Gregson! (#295).
    Commits
    • c3a7524 2.2.3
    • 94fd06d docs: update CHANGELOG for v2.2.3
    • 3b8cebf docs(security): use GitHub security advisories
    • f0fd9e1 docs: publish a security policy
    • 6a91a05 docs(template): bug -> bug report
    • 14f8cb1 2.2.2
    • 10cc7ca docs: update CHANGELOG for v2.2.2
    • 7774c10 fix: add proto to objects and arrays
    • edde30a Readme: slight tweak to intro
    • 97286f8 Improve example in readme
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies javascript 
    opened by dependabot[bot] 0
  • Compiling cast of address to uint160

    Compiling cast of address to uint160

    The following pattern is often repeated in solidity contracts:

    uint256(uint160(addr)
    

    Where the author's intent is to use the address as a number, Warp returns the following error when encountering this pattern:

    TypeError: Explicit type conversion not allowed from "address" to "uint160". Warp changed address size to be 251 bits. Consider replacing uint160 casts with uint256 casts
    

    Can/should this be implicitly converted to a felt (which is an address on starknet)? Any negative implications for this?

    opened by amanusk 0
Owner
Nethermind
Nethermind - full .NET Core Ethereum node for Windows, Linux, MacOS
Nethermind
UniHub API is my solution to bringing students and their universities closer

?? UniHub API UniHub API is my solution to bringing students and their universities closer... By joining UniHub, students will be able to join their r

Abdelbaki Boukerche 5 Nov 21, 2021
The python SDK for Eto, the AI focused data platform for teams bringing AI models to production

Eto Labs Python SDK This is the python SDK for Eto, the AI focused data platform for teams bringing AI models to production. The python SDK makes it e

null 5 Apr 21, 2022
OpenZeppelin Contracts written in Cairo for StarkNet, a decentralized ZK Rollup

OpenZeppelin Cairo Contracts A library for secure smart contract development written in Cairo for StarkNet, a decentralized ZK Rollup. ⚠️ WARNING! ⚠️

OpenZeppelin 592 Jan 4, 2023
Ethereum Gas Fee for the MacBook Pro touchbar (using BetterTouchTool)

Gasbar Ethereum Gas Fee for the MacBook Pro touchbar (using BetterTouchTool) Worried about Ethereum gas fees? Me too. I'd like to keep an eye on them

TSS 51 Nov 14, 2022
The most expensive version of Conway's Game of Life - running on the Ethereum Blockchain

GameOfLife The most expensive implementation of Conway's Game of Life ever - over $2,000 per step! (Probably the slowest too!) Conway's Game of Life r

null 75 Nov 26, 2022
buys ethereum based on graphics card moving average price on ebay

ebay_trades buys ethereum based on graphics card moving average price on ebay Built as a meme, this application will scrape the first 3 pages of ebay

ConnorCreate 41 Jan 5, 2023
Gnosis-py includes a set of libraries to work with Ethereum and Gnosis projects

Gnosis-py Gnosis-py includes a set of libraries to work with Ethereum and Gnosis projects: EthereumClient, a wrapper over Web3.py Web3 client includin

Gnosis 93 Dec 23, 2022
Bendford analysis of Ethereum transaction

Bendford analysis of Ethereum transaction The python script script.py extract from already downloaded archive file the ethereum transaction. The value

sleepy ramen 2 Dec 18, 2021
🚧 finCLI's own News API. No more limited API calls. Unlimited credible and latest information on BTC, Ethereum, Indian and Global Finance.

?? finCLI's own News API. No more limited API calls. Unlimited credible and latest information on BTC, Ethereum, Indian and Global Finance.

finCLI 5 Jun 16, 2022
Ethereum transactions and wallet information for people you follow on Twitter.

ethFollowing Ethereum transactions and wallet information for people you follow on Twitter. Set up Setup python environment (requires python 3.8): vir

Brian Donohue 2 Dec 28, 2021
A modular dynamical-systems model of Ethereum's validator economics.

CADLabs Ethereum Economic Model A modular dynamical-systems model of Ethereum's validator economics, based on the open-source Python library radCAD, a

CADLabs 104 Jan 3, 2023
EthSema - Binary translator for Ethereum 2.0

EthSema is a novel EVM-to-eWASM bytecode translator that can not only ensure the fidelity of translation but also fix commonly-seen vulnerabilities in smart contracts.

weimin 8 Mar 1, 2022
Powerful Ethereum Smart-Contract Toolkit

Heimdall Heimdall is an advanced and modular smart-contract toolkit which aims to make dealing with smart contracts on EVM based chains easier. Instal

Jonathan Becker 69 Dec 26, 2022
Ross Virtual Assistant is a programme which can play Music, search Wikipedia, open Websites and much more.

Ross-Virtual-Assistant Ross Virtual Assistant is a programme which can play Music, search Wikipedia, open Websites and much more. Installation Downloa

Jehan Patel 4 Nov 8, 2021
A web app via which users can buy and sell stocks using virtual money

finance Virtual Stock Trader. A web app via which users can buy and sell stocks using virtual money. All stock prices are real and provided by IEX. Fe

Kiron Deb 0 Jan 15, 2022
This is my personal version of Pac-Man using python, which is the first assignment of EA Software Engineering Virtual Experience Program from Forage.com

Vac-Man in Python This is my personal version of Vax-man game using python, which is the first task of EA Software Engineering Virtual Experience Prog

ZiXiang Luo 3 Jan 5, 2022
A fast, distributed, high performance gradient boosting (GBT, GBDT, GBRT, GBM or MART) framework based on decision tree algorithms, used for ranking, classification and many other machine learning tasks.

Light Gradient Boosting Machine LightGBM is a gradient boosting framework that uses tree based learning algorithms. It is designed to be distributed a

Microsoft 14.5k Jan 8, 2023
Official Python client for the MonkeyLearn API. Build and consume machine learning models for language processing from your Python apps.

MonkeyLearn API for Python Official Python client for the MonkeyLearn API. Build and run machine learning models for language processing from your Pyt

MonkeyLearn 157 Nov 22, 2022
🏆 A ranked list of awesome machine learning Python libraries. Updated weekly.

Best-of Machine Learning with Python ?? A ranked list of awesome machine learning Python libraries. Updated weekly. This curated list contains 840 awe

Machine Learning Tooling 12.2k Jan 4, 2023