Adopt Pets on Arbitrum Testnet

Ferdinand de Antoni
5 min readMay 19, 2021

--

Arbitrum is a promising new L2 layer on top of Ethereum which should give us better scaling and lower costs for dApps.

Arbitrum has not yet launched a mainnet, but this should come quite soon. They do, however, have a testnet that you can currently use. This post describes how to set up your environment to run the Demo Pet Shop dApp.

Note that Arbitrum also has a Quick Start Guide, but that one describes a setup using a local blockchain (not the Arbitrum Testnet), and leaves some things out that that an Ethereum+Arbitrum noob like me might not know.

Prerequisites

For any of this to work, you must have Docker and Git installed. You must also have a GitHub account.

Create a MetaMask Wallet for Testing

First of all we will need to install MetaMask. To keep things simple I strongly suggest installing MetaMask on a browser you exclusively use for development (just to avoid mixing it with your real wallet). You can do so by navigating to metamask.io. Note that MetaMask currently has no plugin for Safari so I used Firefox. Once the MetaMask plugin is installed, create a new wallet:

When creating a new wallet, MetaMask will generate a secret backup phrase for you:

Click on the box to reveal it because you will need it in a future step. Copy/paste the words somewhere so you can easily access them later on.

Configure and Fund Arbitrum Testnet Account

After the new wallet is created, add the Arbitrum testnet by clicking on the top right dropdown and selecting ‘Custom RPC’:

Create the custom testnet by providing the Arbitrum Testnet details (taken from here):

Click ‘Save’ and you are now set to access the Arbitrum testnet with your MetaMask wallet. Before we can use it though, we will need to ‘bridge’ the Arbitrum testnet with the L1 testnet of Kovan. To do that, visit the link https://bridge5.arbitrum.io in the browser where you installed MetaMask. This link will open MetaMask and ask you to connect your wallet. Click ‘Next’ and then ‘Connect’ to confirm the link. After confirming the connection, you should see the following page show up:

Note the ‘your address’ part, this is your address on the Arbitrum network! You will need to send kETH to this address, but before we can do that, we will need to collect kETH on the `Kovan Test Network`! You can do so using the Kovan Faucet.

Navigate to https://faucet.kovan.network/ to request for some test Eth. Note that you will need to be logged into GitHub to do so. Copy the address of your MetaMask wallet, and tell Faucet to send you the kETH. You can easily get the address of your wallet by clicking on the ‘Account’:

After you have given your address to the Faucet, switch to the ‘Kovan Test Network’ to see if it arrived. If you can see your kETH on there, transfer some to your Arbitrum Testnet address. Go back to the ‘Arbitrum Token Bridge’ page, enter an amount to transfer (e.g. 0.05), and click on the ‘Deposit’ button:

A MetaMask wallet window will pop-up, giving you an overview of the transaction. Click ‘Confirm’. Now your Arbitrum address should have kETH 0.05 (and your Kovan Test Network address kETH 0.05 + gas costs less).

Pet Shop dApp

Now that our Arbitrum account is funded, we can deploy the Pet Shop smart contracts to it. You will need Node, Yarn, and Truffle to do so. On OSX you can install these using brew:

$ brew install node yarn
$ npm install -g truffle

With truffle installed, clone the project:

git clone https://github.com/OffchainLabs/demo-dapp-pet-shop

This project is the same as the Truffle Pet Shop Tutorial, but already configured for use with Arbitrum.

Once cloned, we need to edit the truffle-config.js file to suit our needs. Firstly, update the mnemonic to the MetaMask ‘Backup Phrase’ you saved earlier. Second, in the networks section edit the remote_arbitrum link to the right link (the cloned repo might still be using version 4):

truffle-config.js

With the configuration updated, download all the dependencies the project needs, and deploy the smart contracts to Arbitrum Testnet:

$ yarn
$ truffle migrate --network remote_arbitrum

If all goes well the Truffle migrate command will compile the contracts (using a docker image) and deploy them to the ‘remote_arbitrum’ network (which points to Arbitrum Testnet in truffle-config.js).

Now start the dApp by running the following:

$ yarn start

This should start up a node instance with the Pet Shop dApp and open up a browser page pointing to http://localhost:8080 (make sure this page is opened on the browser that has your MetaMask walled installed):

MetaMask will ask you if you want to connect your wallet to the dApp. Click ‘Next’ and ‘Confirm’. Once done, you can now start adopting pets over the Arbitrum test network:

All done! You have now successfully deployed a dApp to Arbitrum, and adopted a French Buldog called Collins.

--

--