ZK Rollup Tutorial Part 5
Congratulations! If you’ve made it this far, your Sovereign ZK Rollup built on Nomos should be up and ready to use. Since it is EVM-compatible, any Solidity contract that can run on Ethereum can be deployed just the same on this Sovereign Rollup. Transactions to deploy contracts and interact with the chain can be submitted to the sequencer node’s RPC endpoint via JavaScript libraries such as web3.js. For more information on the API used by Reth, see here.
On this page, we’ll go through a simplified example of deploying Uniswap and two token contracts on the Sovereign Rollup, together with a frontend and a block explorer.
Our first example will be to deploy contracts for Uniswap, as well as two ERC-20 tokens for trading on this exchange. This process is handled by the test_deploy.js file in the nomos-example-uniswap-contracts directory, only requiring the user to input some basic configuration arguments. Before you begin, make sure the account you are deploying from has enough ETH to pay the gas of the deployment transaction. The deployment script is found in the following repository:
https://github.com/logos-co/nomos-example-uniswap-contracts/
To enter the nomos-example-uniswap-contracts folder from the main nomos-example-sovereign-rollup directory, run the following command:
cd nomos-example-uniswap-contracts
Then, set the following environment variables, which will serve as arguments for the deployment script:
| Variable | Required | Description | Format | Default |
|---|---|---|---|---|
UNISWAP_DEPLOYER_PRIVATE_KEY |
✅ | Deployment wallet private key | 0x + 64 hex chars |
❌ |
UNISWAP_DEPLOYER_RPC |
❌ | Ethereum node RPC URL | URL string | http://localhost:8545 |
UNISWAP_DEPLOYER_GAS_PRICE |
❌ | Custom gas price | ETH as float | 0.000005 |
UNISWAP_DEPLOYER_GAS_LIMIT |
❌ | Custom gas limit | ETH as float | 6000000 |
For example, to add the deployer’s private key, run:
UNISWAP_DEPLOYER_PRIVATE_KEY=0x[PRIVATE-KEY-HERE]
Finally, run the following script. It will output the addresses of the Uniswap Router contract, and two tokens named NMO and MEM.
./deploy-contracts.sh
With the contracts deployed, we are ready to run a frontend application to handle swaps between the NMO and MEM tokens. The code for this application can be found in the following repository:
https://github.com/logos-co/nomos-example-uniswap
To enter the nomos-example-uniswap folder from the main nomos-example-sovereign-rollup directory, run the following command:
cd nomos-example-uniswap