Warping solidity contracts to cairo on windows

Ovia SeshadriOvia Seshadri
3 min read

StarkNet is a permissionless decentralized ZK-Rollup. It operates as an L2 network over Ethereum, enabling any dApp to achieve unlimited scale for its computation – without compromising Ethereum's composability and security.

On StarkNet, developers can easily deploy any business logic using StarkNet Contracts. StarkNet provides Ethereum-level composability – facilitating easy development and innovation. While Cairo is the native language for a StarkNet contract that fully optimizes the scaling potential of StarkNet, teams are developing transpilers to Cairo from Solidity and other programming languages. These transpilers will allow for a quick deployment on StarkNet. The warp command provides this functionality to convert solidity contracts to cairo.

While Warp is easy to install on Ubuntu and MacOS, it gets tricky for windows users. Being a software engineer/researcher on Windows I'm often told off for staying on windows. This is to help those of you like me!

You can go the hard way of installing a Linux VM on your machine or spinning a Linux server on the cloud but trust me this is way easier. You will need something called WSL. WSL stands for windows subsystem for Linux. WSL enables you to use Linux tools, like Bash or Grep, completely integrated with Windows tools, like PowerShell or Visual Studio Code, with no need to dual-boot. You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.

One way of installing WSL is typing "PowerShell" on ur start bar and opening the app in admin mode. You can then run the command

wsl --install

An easier way is to go to Microsoft Store and get prebuilt ubuntu set up, I have tried this on Ubuntu 20.4.x. You can directly open this app after its installation and you have a new Linux system ready for our purpose. Note that this may take a while to boot. Go ahead and install some dependencies needed for warp such as Python (I recommend 3.7/3.8), node, npm, pip, and yarn via npm through the following commands:

sudo apt update
sudo apt install libz3-dev libgmp3-dev
sudo apt install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt install python3.8

check if the installation is done correctly by running

python3.8 --version

you can install node and the package manager npm via

sudo apt install nodejs
sudo apt install npm

Make sure to verify the correct installation by running:

node -v
npm --version

Now you can install yarn.

npm install -g yarn
yarn --version
export PATH="$PATH:$(yarn global bin)"

If you have done all this correctly, you are ready to install warp. You can clone this git repo and run the following commands from the root folder

yarn global add @nethermindeth/warp
warp version
warp install --verbose
warp install --python <path/to/python3.8> --verbose

Now you are all set to wrap and transpile your contracts on starknet. An example ERC20 solidity contract is given in the folder "example_contracts". you can cd into it and run

warp transpile ERC20.sol

If it went right, you should now have a warp_output/example_contracts folder in the root warp folder containing the cairo file. Enjoy converting all your solidity contracts easily into cairo for starknet!

1
Subscribe to my newsletter

Read articles from Ovia Seshadri directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ovia Seshadri
Ovia Seshadri

I am a research engineer at CoinDCX with over 8 years of expertise in the blockchain field. I hold a Ph.D. in Computer Science and Engineering from IIT Delhi, and my research has primarily focused on scaling Proof-of-Work blockchains. I work primarily in Blockchains, Web3, and cryptography. I am actively involved in the technology community as the director of the Phoenix Guild Chennai chapter, a community that aims to empower female and non-binary individuals in Tamil Nadu in the realm of Web3. I enjoy participating in discussions on the future of technology, particularly in the Web3 domain and dedicate my free time to delivering technical talks and workshops, sharing my knowledge and passion with others. More about me at - https://oviaseshadri.github.io/