Deploy a dapp on your Arbitrum rollup devnet
First, review the Arbitrum integration, Quickstart: Deploy an Arbitrum Orbit rollup, and Deploy a smart contract to your Arbitrum rollup pages.
Dependencies
- a funded account to deploy your smart contract
- an Arbitrum rollup devnet running
Setup and contract deployment
Clone the
gm-portal
from GitHub and start the frontend:bashcd $HOME git clone https://github.com/jcstein/gm-portal.git cd gm-portal && git checkout arbitrum cd frontend && yarn && yarn dev
cd $HOME git clone https://github.com/jcstein/gm-portal.git cd gm-portal && git checkout arbitrum cd frontend && yarn && yarn dev
In a new terminal instance, set your private key for the faucet as a variable and the RPC URL you're using:
bashexport PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 export ARB_RPC_URL=http://localhost:8547
export PRIVATE_KEY=0xb6b15c8cb491557369f3c7d2c287b053eb229daa9c22138887752191c9520659 export ARB_RPC_URL=http://localhost:8547
Change into the
gm-portal/contracts
directory in the same terminal and deploy the contract using Foundry:bashcd $HOME/gm-portal/contracts forge script script/GmPortal.s.sol:GmPortalScript --rpc-url $ARB_RPC_URL --private-key $PRIVATE_KEY --broadcast
cd $HOME/gm-portal/contracts forge script script/GmPortal.s.sol:GmPortalScript --rpc-url $ARB_RPC_URL --private-key $PRIVATE_KEY --broadcast
In the output of the deployment, find the contract address and set it as a variable:
bashexport CONTRACT_ADDRESS=<your-contract-address-from-the-output-above>
export CONTRACT_ADDRESS=<your-contract-address-from-the-output-above>
Interact with the contract
Next, you're ready to interact with the contract from your terminal!
Send a "gm" to the contract:
bashcast send $CONTRACT_ADDRESS \ "gm(string)" "gm" \ --private-key $PRIVATE_KEY \ --rpc-url $ARB_RPC_URL
cast send $CONTRACT_ADDRESS \ "gm(string)" "gm" \ --private-key $PRIVATE_KEY \ --rpc-url $ARB_RPC_URL
Now that you've posted to the contract, you can read all "gms" (GMs) from the contract with this command:
bashcast call $CONTRACT_ADDRESS "getAllGms()" --rpc-url $ARB_RPC_URL
cast call $CONTRACT_ADDRESS "getAllGms()" --rpc-url $ARB_RPC_URL
Next, query the total number of gms, which will be returned as a hex value:
bashcast call $CONTRACT_ADDRESS "getTotalGms()" --rpc-url $ARB_RPC_URL
cast call $CONTRACT_ADDRESS "getTotalGms()" --rpc-url $ARB_RPC_URL
(Optional) In order to interact with the contract on the frontend, you'll need to fund an account that you have in your Ethereum wallet. Transfer to an external account with this command:
bashexport RECEIVER=<receiver ETH address> cast send --private-key $PRIVATE_KEY $RECEIVER --value 1ether --rpc-url $ARB_RPC_URL
export RECEIVER=<receiver ETH address> cast send --private-key $PRIVATE_KEY $RECEIVER --value 1ether --rpc-url $ARB_RPC_URL
TIP
If you are in a different terminal than the one you set the private key in, you may need to set it again.
Update the frontend
Next, you will need to update a few things before you can interact with the contract on the frontend:
- Change the contract address on
gm-portal/frontend/src/App.tsx
to your contract address - Match the chain info on
gm-portal/frontend/src/main.tsx
with the chain config of your L2 - If you changed the contract, update the ABI in
gm-portal/frontend/GmPortal.json
fromgm-portal/contracts/out/GmPortal.sol/GmPortal.json
. This can be done with:
cd $HOME
cp dev/gm-portal/contracts/out/GmPortal.sol/GmPortal.json dev/gm-portal/frontend
cd $HOME
cp dev/gm-portal/contracts/out/GmPortal.sol/GmPortal.json dev/gm-portal/frontend
Interact with the frontend
Now, login with your wallet that you funded, and post a GM on your GM portal!