GithubHelp home page GithubHelp logo

nickkjolsing / warp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nethermindeth/warp

0.0 0.0 0.0 165.36 MB

Bringing Ethereum Virtual Machine to StarkNet at warp speed!

License: Apache License 2.0

Shell 0.35% Python 90.12% Makefile 0.24% Solidity 8.49% TypeScript 0.80%

warp's Introduction

Warp

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

Table of Contents ๐Ÿ“‹

Installation โš™๏ธ

Prerequisites: Make sure your Solidity compiler version is >= 0.8.0

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
sudo apt install -y libboost-all-dev
sudo apt-get install -y python3.7-venv
python3.7 -m venv ~/warp
source ~/warp/bin/activate
pip install z3-solver

MacOs:

brew install [email protected]
brew install gmp
brew install boost
brew install z3
python3.7 -m venv ~/warp
source ~/warp/bin/activate

Install Warp:

pip install sol-warp

Setting up autocompletion

Warp comes with support for command line completion in bash, zsh, and fish

for bash:

 eval "$(_WARP_COMPLETE=bash_source warp)" >> ~/.bashrc

for zsh:

 eval "$(_WARP_COMPLETE=zsh_source warp)" >> ~/.zshrc

for fish:

_WARP_COMPLETE=fish_source warp > ~/.config/fish/completions/warp.fish

Usage ๐Ÿ’ป

You can transpile your Solidity contracts with:

warp transpile FILE_PATH CONTRACT_NAME

CONTRACT_NAME is the name of the primary contract (non-interface, non-library, non-abstract contract) that you wish to transpile

To deploy the transpiled program to Starknet use:

warp deploy CONTRACT.json

To invoke a public/external method use:

warp invoke --program CONTRACT.json --address ADDRESS --function FUNCTION_NAME --inputs 'INPUTS'

Here's an example that shows you the format of the inputs for inputs:

Let's say we want to call the following Solidity function in a contract that we've transpiled & deployed on StarkNet:

struct Person {
    uint age;
    uint height;
}
function validate(address _ownerCheck, Person calldata _person, uint _ownerCellNumberCheck)
  public view returns (bool) {
    return (owner == _ownerCheck && ownerAge == _person.age
        && ownerCellNumber == _ownerCellNumberCheck);
}

The command to call this function would be:

warp invoke --program CONTRACT.json --address ADDRESS --function validate \
        --inputs '[0x07964d2123425737cd3663bec47c68db37dc61d83fee74fc192d50a59fb7ab56,
        (26, 200), 7432533831]'

The --inputs flag, if not empty, should always be an 'array'. As you can see, we have passed the struct fields as a tuple, their order should be the same as their declaration order (i.e age first, person second). If the first argument to the validate function was an array of uint's, then we'd pass it in as you'd expect:

--inputs = '[[42,1722,7], (26, 200), 7432533831]'

If you're passing in the bytes Solidity type as an argument, use the python syntax, for example:

--inputs = '[[10,20], b"\x01\x02"]'

You can check the status of your transaction with:

warp status TX_HASH

Testing with Warp

You'll find an example of how to write tests in your solidity contract, and then call warp test to run them in src/warp/test_tool/example. For the tests to work, you'll need to run warp test from a parent directory where your solidity contracts are in a directory named contracts, as per the example mentioned above.

Solidity Constructs Currently Not Supported

Support Status Symbol
Will likely never be supported โŒ
Support will land soon โš’๏ธ
Will be supported in the future โ—
Currently Unkown โ“
Solidity Support Status
try/catch โ“
msg.value โŒ
tx.origin โ—
tx.gasprice โ“
block.basefee โŒ
block.chainid โ—
block.coinbase โ“
block.difficulty โŒ
block.gaslimit โ“
gasleft() โ“
functions as data โŒ
precompiles โ—
create/create2 โ—
Selfdestruct โŒ
BlockHash โ—
Yul Support Status
linkersymbol โ“
codeCopy โ“
codeSize โ“

Run solc --optimize --ir-optimized <file> to see if your Solidity results in any of these YUL constructs.

Want to contribute? ๐Ÿ‘

Your contributions are always welcome, see contribution guidelines.

License

Apache License Version 2.0, January 2004.

warp's People

Contributors

temyurchenko avatar swapnilraj avatar cicr99 avatar jorikschellekens avatar glitch18 avatar nickkjolsing avatar matilote avatar scooletz avatar sambarnes avatar tkstanczak avatar natdurlik avatar yodaboots avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.