Skip to main content

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 python@3.7
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

To see the cairo output of the transpilation process:

warp transpile FILE_PATH CONTRACT_NAME --cairo-output

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 Unknown ❓
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.

Metadata

Release files for sol-warp 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sol-warp 1.2.0
File Size Uploaded Provenance Actions
sol-warp-1.2.0.tar.gz 21.0 MB Without provenance Details for sol-warp-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sol-warp 1.2.0
File Interpreter ABI Platform Actions
sol_warp-1.2.0-py3-none-any.whl Python 3 none any Details for sol_warp-1.2.0-py3-none-any.whl

Total release size: 42.2 MB

Release files / sol-warp-1.2.0.tar.gz

Download URL sol-warp-1.2.0.tar.gz
Size 21.0 MB
Tags Source
SHA-256 checksum
How to use checksums
81845fd8d5670b35be6e9c35ae770b8f816dcbecab591f8f5f4e043a72b9ba35
BLAKE2b-256 checksum
How to use checksums
e9acc5f6d6f82e29403060d4a3b4d87e1c3ad1bc8fc58c6ca8ffc39a0d171499
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.8.10 Linux/5.10.16.3-microsoft-standard-WSL2

Release files / sol_warp-1.2.0-py3-none-any.whl

Download URL sol_warp-1.2.0-py3-none-any.whl
Size 21.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
082aea80d95bd8b822709ccfcad9cb4f04ab1d71d5bf92a14993206b7c24c6e3
BLAKE2b-256 checksum
How to use checksums
5c5ad9551b0694b664f449c267317ef686fc9ed4a31cd165ce9f14fcaecf17ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.12 CPython/3.8.10 Linux/5.10.16.3-microsoft-standard-WSL2

Security for sol-warp 1.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page