🌍Avail: Deploying Your First Dymension RollApp (Pt. 2)

ilaNihas 🌍
12 min readFeb 12, 2024

--

In the first episode of our two-part series on Avail’s recent Clash of Nodes challenge, which focuses on deploying our first Dymension RollApp, we explored the Dymension Project, discussed the installation of roller, RollApp initialization, funding our addresses, RollApp registration, provided two alternative methods for running your RollApp, offered troubleshooting tips, guided on updating your Avail wallet, explained how to export your keys, and outlined the process for registering your RollApp on GitHub. Following a recent announcement on the Avail Discord server, it’s now required to deploy smart contracts on our RollApp and ensure our RPC endpoints are accessible over HTTPS.

The #rollapp-verification channel on the Avail Discord was temporarily reopened, but it’s closed again while the team works through the current backlog:

Once the channel reopens again, we’ll be ready to carry out the necessary steps and create a ticket to start the verification process. This is necessary for your RollApp to appear on the Dymension Leaderboard. In this part, we’ll cover:

  • Adding your RollApp to Metamask
  • Deploying a smart contract and executing its functions
  • Using Caddy for HTTPS-Protected Access to Our RPC
  • Linking our RPC to a custom domain
  • Editing our RollApp JSON configuration file
  • Filing the rollapp verification ticket

To successfully navigate through this process, you’ll need a domain and a VPS where a Dymension RollApp has already been deployed, complete with testnet funds in your wallets. It’s essential that you’ve gone through the first part of this series to ensure you’re prepared.

Please be aware: Since the Dymension RollApp challenge has ended, it’s now too late to deploy a RollApp for the Avail Clash of Nodes challenge.

Step 1: Adding your RollApp to Metamask

To add your RollApp to Metamask, start by opening the network menu on the top left and clicking the “Add network” button, followed by selecting “Add a network manually”:

To fill out the fields, proceed as follows:

  • Network Name: Choose any name you prefer for display purposes in Metamask
  • New RPC URL: Enter the RPC URL specified in your .json file from “Part 10: Registering Your RollApp in Github”. This is usually your VPS IP address followed by port 8545
  • Chain ID: This can be found in your .json file as well. Alternatively, use the command “roller config export” to view your Chain ID. Remember, it’s in hex format, so convert it to decimal using a tool like RapidTables, and then input the decimal value

Follow these steps to successfully add your RollApp network to Metamask and click the “Save” button.

Step 2: Checking Your Account Balance

If we followed all the steps correctly in the first part, we should be able to export the RollApp sequencer key with the command:

roller keys export rollapp_sequencer

This command will return a hex value. To import this into Metamask, click on “Add account or hardware wallet” followed by “Import account”. Then, paste the hex value into the field labeled “Enter your private key string here” and finally click the “Import” button:

After these steps, you should be able to see the token, with the denomination and amount specified in the first part, in your Metamask wallet:

Step 3: Deploying A Smart Contract And Executing Its Functions

For the second requirement, which demands functional implementation in your RollApp, we’ll deploy a basic smart contract using the Remix IDE.

While I’m interested in providing a definitive example for everyone to follow, doing so might risk the Avail team not approving your rollapp verification tickets if identical contracts are submitted by multiple users. Therefore, I encourage you to select a unique basic smart contract as your template. A set of examples can be found on GitHub by searching for “Solidity example”:https://github.com/search?q=solidity%20example&type=repositories. This approach ensures diversity in submissions, enhancing the likelihood of your RollApp being verified.

Now, start by navigating to the Remix IDE website and head over to the file explorer section. Here, delete any pre-existing contracts (= .sol files) within the “contracts” folder and proceed to create a new file:

Next, copy the smart contract you’ve selected into the .sol file you've created within the text editor area of Remix:

Then, move to the “Solidity compiler” section. Here, choose the compiler version that matches the one specified in your contract (for example, 0.8.0) and click the “Compile XXX.sol” button to compile your smart contract successfully:

After compiling, navigate to the “Environment” dropdown and select “Injected Provider — MetaMask”. Now, open your MetaMask wallet and wait a bit. This will allow the Remix IDE to detect and interact with your account. Verify in the “Account” section that the correct account is active and that the balance reflects your custom token accurately. Ensure your smart contract file is the one chosen in the “Contract” dropdown. Now, you’re ready to hit the “Deploy” button. This will trigger a transaction in your MetaMask account, which you’ll need to confirm:

If the deployment is successful, you’ll see a confirmation message in the output window:

Should your smart contract include multiple functions, it’s a good practice to execute them to ensure the outputs are as expected and everything functions correctly:

Step 4: Prepare Your Domain

To ensure secure access to our RPC via HTTPS, buying a domain and setting it up is a necessary step. You have the freedom to select any domain provider that suits your preferences. When making your choice, consider factors like customer service quality and pricing. It’s difficult for me to suggest a specific domain provider as there are numerous good options available. However, based on my positive personal experiences, I chose IONOS for my needs. Once you’ve purchased your domain, I recommend setting up a subdomain. This approach allows you to use the same domain for additional projects in the future by simply creating more subdomains. You’ll then need to configure its DNS settings. This involves creating an A-Record that points to your node’s IP address. Based on the domain provider you choose, the configuration setup interface should generally look something like this (replace “rollapp” with your subdomain’s name):

Step 5: Using Caddy for HTTPS-Protected Access to Our RPC

To ensure the rollapp RPC endpoints are securely served via HTTPS, it’s necessary to secure our RPC access. Given the operation of these endpoints across various ports, the setup of reverse proxies is required. To simplify this process, bypassing the complexity of Apache or NGINX, we’ll use Caddy Server. Begin by installing the essential packages with the following commands, entering them into your terminal one at a time:

  1. Install keyring and prerequisites:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl

2. Add the Caddy GPG key:

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg

3. Add the Caddy repository to your sources:

curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list

4. Update your package list:

sudo apt update

5. Install Caddy:

sudo apt install caddy

6. To sart the Caddy service, you can use the following command:

sudo systemctl start caddy

This command activates the Caddy server, allowing it to begin serving your rollapp RPC endpoints securely over HTTPS as configured.

To ensure that Caddy can generate SSL certificates for secure HTTPS communication, you need to open ports 80 and 443. Use the following commands to allow traffic on these ports through the firewall:

sudo ufw allow 80
sudo ufw allow 443

To set up your Caddy server for managing HTTPS communication for your rollapp, you’ll need to create a configuration file known as “Caddyfile” in the /etc/caddy directory. Follow these steps to create the file and configure it accordingly:

  1. Navigate to the Caddy configuration directory:
cd /etc/caddy

2. Create the “Caddyfile”:

touch Caddyfile

Now, you need to define the configuration within the Caddyfile. This involves specifying how Caddy should handle requests to your subdomain and reverse proxy those requests to your rollapp’s Status, Rest, and EVM endpoints.

3. Open the Caddyfile with your preferred text editor, for example, using nano:

sudo nano Caddyfile

4. Copy the configuration snippet below and paste it into the Caddyfile. Remember to replace rollapp.ilanihas.xyz with your actual subdomain:

https://rollapp.ilanihas.xyz:443 {

handle_path /evm* {
reverse_proxy http://127.0.0.1:8545
}

handle /status* {
reverse_proxy http://127.0.0.1:26657
}

handle /rest* {
reverse_proxy http://127.0.0.1:1317
}
}

This configuration directs Caddy to reverse proxy requests made to specific paths (/status, /rest, /evm) to the corresponding local ports of your rollapp services. After editing, save and close the file. If you’re using nano, you can do this by pressing CTRL + X, then Y to confirm the changes, and Enter to exit. Finally, restart the Caddy service to apply the changes:

sudo systemctl restart caddy

This completes the setup for your rollapp’s secure HTTPS access through Caddy. Your services should now be securely accessible via the internet with SSL certificates automatically managed by Caddy.

To confirm that your setup is correctly configured and operational, you should test it by accessing your rollapp’s “Status” endpoint through a web browser. Follow these steps to perform the verification:

  1. Open your web browser
  2. Navigate to https://<your-domain>/status — ensure you replace <your-domain> with the actual domain you've configured in your Caddyfile, such as https://rollapp.ilanihas.xyz/status

Upon successful configuration, you should observe the following:

  • The browser connection should indicate that it is secure, typically shown by a lock icon near the website address. This confirms that the SSL certificate is correctly installed and the site is served over HTTPS
  • You should receive a JSON string as a response, indicating that your request has successfully reached your rollapp’s backend and that your node is in a healthy state

→ If you encounter the message “Priority is too low,” this suggests your node is not in optimal health. Although I don’t have a lasting fix, a temporary workaround is to restart your services, which should address the issue for the time being:

sudo systemctl restart sequencer
sudo systemctl restart relayer

To integrate your RollApp with MetaMask and ensure a successful connection, follow these steps to update the RPC URL in MetaMask with your new domain:

  1. Open MetaMask: Access your MetaMask extension in your browser
  2. Access Settings: Click on the profile icon or menu button, then find and select “Settings” from the dropdown or menu list.
  3. Navigate to Networks: Within the Settings menu, look for the “Networks” section and select it. This is where you can add or edit custom RPC networks
  4. Select Your RollApp Network: Find the network connection you previously added for your RollApp. Click on it to edit the network’s details
  5. Update the RPC URL: In the “New RPC URL” field, you’ll need to replace the old IP-based URL with the new domain-based URL you’ve set up with Caddy. Make the following change (ensure you replace my domain with your actual domain):

Test the Connection: Ensure there are no errors when you save the changes. You can test the connection by attempting a transaction within MetaMask using the newly configured network. Successful connection without errors indicates that MetaMask can communicate with your RollApp over the secure, domain-based URL:

If you’re running into problems with transactions, changing your RPC URLs could be a solution, particularly because the Blockpi endpoint tends to get congested. Your first step should be to look for alternative URLs that might fix the issue. I suggest reaching out on the Dymension Discord server, as there’s a good chance someone there will be willing to let you use their RPC endpoint. After obtaining new URLs, make sure to update them in the relevant files. Don’t forget to save the original RPC URLs somewhere safe, so you can go back to them if necessary:

  • nano ~/.roller/config.toml
  • nano ~/.roller/relayer/config/config.yaml
  • nano ~/.roller/rollapp/config/dymint.toml

Your mnemonic is in there, so proceed with caution. Once you’ve completed these steps, remember to restart your services. Also, if your transaction seems to be stuck, restarting the services might also help resolve the issue:

sudo systemctl restart sequencer
sudo systemctl restart relayer

Step 6: Editing Our RollApp JSON configuration file

Now that we’ve successfully set everything up, it’s time to update the JSON file in the pull request we submitted earlier. Here’s how to do it: Open the pull request you previously submitted, click on the three dots in the top right corner of the file you want to edit and select “Edit file” from the dropdown menu:

In the file editor, locate the parameters for rpc, rest, and evm/rpc and update the URLs to reflect your own domain. Once you’ve made sure all the information is accurate, proceed to click the “Commit changes…” button to finalize your updates.

Step 7: Creating The Rollapp Verification Ticket

Once the #rollapp-verification channel on the Avail Discord becomes accessible again, we’ll need to proceed by selecting the “Create ticket” option and provide all the required details. While I’d like to to provide a concrete example, I’m concerned that duplicated content may lead to the Avail team potentially rejecting the verification submissions. Your ticket submission should comprehensively cover the following points:

  • Detailed description of your smart contract(s), showcasing its functionalities and unique features
  • Share the secure links (HTTPS) to show your app talks safely over the internet
  • Explain how to check if your app is working right, to show it’s reliable
  • Tell them you’ve made changes to the JSON file in your submission for better accuracy and ease of use
  • Let them know you’re open to talking more if they need more info or have questions

After submitting, all we can do is wait and hope that our rollapp submission gets approved :-)

Hey everyone, I’m excited to share that I’ve partnered with Dotcom Canvas, a standout German brand known for its exquisite crypto-themed wall art. Their acrylic glass pieces are particularly impressive.

Discover their unique collection via my affiliate link. For a special treat, use the code CRYPTOTRIBE at checkout to get a 15% discount. To see these art pieces in their full glory, take a peek at this promotional video. It’s a great way to visualize how they could elevate your space.

Let’s enjoy some awesome crypto art together!

Disclosure: By using my affiliate link for purchases, I receive a commission.

About me

Hi! I’m ilaNihas, a big football fan (or soccer, if you prefer). After 13 years in IT, I paused my career to explore crypto, blockchain, and Web3. I’m fascinated by the potential and constantly searching for interesting projects, airdrops, and new nodes to explore. Join me as I combine my passions for sports, writing, and tech. Let’s dive into the world of crypto and blockchain together!

Thanks for reading! Please share your feedback in a comment and follow me on my socials if you enjoyed the article. I’ve also set up a Discord community where we can get together and have discussions about interesting crypto-related topics. You’re welcome to join us and be part of the conversation → https://discord.gg/zN4dH35JJZ

Please note that the content provided on this blog is intended solely for educational, informational, and entertainment purposes and should not be considered as financial advice. In summary, always do your own research, evaluate the information critically, and seek professional advice when necessary. Stay informed, exercise caution, and make well-informed decisions based on your own unique circumstances.

--

--

ilaNihas 🌍

Crypto reptile | Join us on this ride through the cryptoverse, as we explore the strangest corners of the blockchain -> https://discord.gg/zN4dH35JJZ