🔨Deploy
Install dependencies
Run the following command:
This will end up installing:
Scarb (Cairo/Starknet packet manager) - Includes a specific version of the Cairo compiler.
Starkli - Starkli is a command line tool for interacting with Starknet.
Starknet Foundry - Is a toolchain for developing Starknet smart contracts.
Ethereum Foundry - Is a toolchain for developing Ethereum smart contracts.
Another starknet dependency used in this project:
[comment]: TODO add install ZKSync dockerized L1-L2 or in-memory-node if/when necessary, for make tests
Deploy Payment Registry (on Ethereum)
First, the Ethereum Payment Registry must be deployed. For Ethereum the deployment process you will need to:
Create your
.env
file: you need to configure the following variables in your own .env file on the contracts/ethereum/ folder. You can use the env.example file as a template for creating your .env file, paying special attention to the formats providedNOTE:
You can generate ETHERSCAN_API_KEY following these steps.
STARKNET_MESSAGING_ADDRESS is for when a L1 contract initiates a message to a L2 contract on Starknet. It does so by calling the sendMessageToL2 function on the Starknet Core Contract with the message parameters. Starknet Core Contracts are the following:
Sepolia:
0xE2Bb56ee936fd6433DC0F6e7e3b8365C906AA057
Mainnet:
0xc662c410C0ECf747543f5bA90660f6ABeBD9C8c4
ZKSYNC_DIAMOND_PROXY_ADDRESS is for when a L1 contract initiates a message to a L2 contract on ZKSync. It does so by calling the requestL2Transaction function on the ZKSync Core Contract with the message parameters. ZKSync Diamond Proxy's addresses are the following:
Sepolia:
0x9A6DE0f62Aa270A8bCB1e2610078650D539B1Ef9
Mainnet:
0x32400084C286CF3E17e7B677ea9583e60a000324
You can generate the STARKNET_CLAIM_PAYMENT_SELECTOR value and the STARKNET_CLAIM_PAYMENT_BATHC_SELECTOR with
starkli
, by running, for example:
You can generate the ZKSYNC_CLAIM_PAYMENT_SELECTOR and the ZKSYNC_CLAIM_PAYMENT_BATCH_SELECTOR value by using
cast sig
, by running, for example:
Deploy Ethereum contract
This will deploy a ERC1967 Proxy smart contract, a Payment Registry smart contract, and it will link them both. The purpose of having a proxy in front of our Payment Registry is so that it is upgradeable, by simply deploying another smart contract and changing the address pointed by the Proxy.
Deploy Escrow (on Starknet)
After the Ethereum Payment Registry is deployed, the Starknet Escrow must be declared and deployed.
On Starknet, the deployment process is in two steps:
Declaring the class of your contract, or sending your contract’s code to the network
Deploying a contract or creating an instance of the previously declared code with the necessary parameters
For this, you will need to:
Create your
.env
file: you need to configure the following variables in your own .env file on the contracts/starknet folder. You can use the env.example file as a template for creating your .env file, paying special attention to the formats providedNote
STARKNET_ESCROW_OWNER is the only one who can perform upgrades, pause and unpause the smart contract. If not defined, this value will be set (by deploy.sh) to the current deployer of the smart contract.
Declare and Deploy: We sequentially declare and deploy the contracts, and connect it to our Ethereum Payment Registry.
First alternative: automatic deploy and connect of Escrow and Payment Registry
This make target consists of 3 steps:
make starknet-build; builds the project
make starknet-deploy; deploys the Escrow on the Starknet blockchain
make ethereum-set-escrow; sets the newly created Starknet contract address on the Ethereum Payment Registry, so that the L1 contract can communicate with the L2 contract
Second alternative: manual deploy and connect of Escrow and Payment Registry
This may be better suited for you if you plan to change some of the automatically declared variables, or if you simply want to make sure you understand the process.
Deploy Escrow (on ZKSync)
After the Ethereum Payment Registry is deployed, the ZKSync Escrow must be deployed.
For this, you will need to:
Create your
.env
file: you need to configure the following variables in your own .env file on the contracts/zksync folder. You can use the env.example file as a template for creating your .env file, paying special attention to the formats providedWe deploy the contract, and connect it to our Ethereum Payment Registry.
First alternative: automatic deploy and connect of Escrow and Payment Registry
This make target consists of 3 steps:
make zksync-build; builds the project
make zksync-deploy; deploys the Escrow on the ZKSync blockchain
./set_zksync_escrow.sh; sets the newly created ZKSync contract address on the Ethereum Payment Registry, so that the L1 contract can communicate with the L2 contract
Second alternative: manual deploy and connect of Escrow and Payment Registry
This may be better suited for you if you plan to change some of the automatically declared variables, or if you simply want to make sure you understand the process.
Recap
At this point, we should have deployed an Ethereum smart contract, Payment Registry, as well as declared and deployed 2 L2 Escrows, one on Starknet and another one on ZKSync, both connected to Ethereum Payment Registry to act as a bridge between these chains.
More deploy targets
There also exists more make targets that can help us deploy more easily and more quickly our smart contracts. Once we have correctly configured out .env files, as explained above, we can use the following make targets:
To deploy only our Ethereum Payment Registry and our Escrow on Starknet:
To deploy only our Ethereum Payment Registry and our Escrow on ZKSync:
To deploy everything stated above, our Ethereum Payment Registry, an Escrow on Starknet and another Escrow on ZKSync:
Last updated