Description
Goal
Check-in into the BatchRegistry contract.
💡 This issue doesn't require you to raise a PR, just get yourself checked-in. Create a local branch to work on this.
BatchRegistry contract
The BatchRegistry contract is deployed on Arbitrum.
You can find the contract code in packages/hardhat/contracts/BatchRegistry.sol
. It's also available in the externalContracts.ts
file in packages/nextjs/contracts/
(for front-end use in future issues).
You can see/interact with the contract on the Debug page of SE-2: Clone this repo, run yarn install
and yarn start
and go to http://localhost:3000/debug.
💡 You can check if you wallet address is in the allowList ;)
Checking-in
There are many ways to check-in into the Contract. Here we'll use the Scaffold-ETH 2 way ™.
1. Create your own branch
Before you begin, make sure you're working on a separate branch. Here's how:
- Clone the repo to your local machine (If you haven't already)
- Navigate to the cloned directory in your terminal.
- Create a new branch using
git checkout -b [your-branch-name]
2. Spin up Your Local SE-2
Set up your local environment:
- Run
yarn install
(install dependencies) - Run
yarn start
(starts SE2 front-end) - Go to http://localhost:3000/. You should see SE-2 app.
💡 You'll notice that the dApp points to the Arbitrum chain. Check the scaffold.config.ts
file to see how it's configured.
3. Understand the checkIn
function
Go the the BatchRegistry.sol
contract and check the checkIn
function. You'll see that in order to check in, 3 things are required:
- The Batch is open (should be open already :D)
- Your EOA address is on the allowed list (ping us if you are not on the list)
- To be able to call the functions, they must be called from a contract (not an EOA!)
So you'll need to deploy a contract that calls the checkIn
function on the BatchRegistry
contract.
4. Set up the local environment
Instead of deploying a contract on Arbitrum, we'll deploy it locally so we can test.
- Start your local hardhat node:
yarn chain
- Deploy the BatchRegistry contract:
yarn deploy
a. Checkpackages/hardhat/deploy/00_deploy_your_contract.ts
- Change the dApp chain to hardhat in
scaffold.config.ts
(targetNetwork should bechains.hardhat
) - Start the front-end if you haven't already:
yarn start
If you go to the Debug page, you should see the BatchRegistry
contract (but this time is deployed locally!)
💡 You'll need to tweak the deploy script to make yourself the owner of the BatchRegistry
contract (so you can update the allowList, etc.)
5. Deploy a contract that calls the checkIn
function
Now it's time to create a contract that calls the checkIn
function. E.g.
- Create a
CheckIn.sol
contract inpackages/hardhat/contracts/
- Declare an interface for the
BatchRegistry
contract (More info here: Interfaces in Solidity By Example) - The constructor should receive the address of the
BatchRegistry
contract - Implement a function in your contract that calls the
checkIn
BatchRegistry function. - (Optional) You can implement an owner pattern to avoid other people calling the function in your contract ;)
- Tweak the
00_deploy_your_contract.ts
script to deploy your contract (and pass the address of theBatchRegistry
contract)
Test it!
6. Check-in live
Once you have tested that your contract works, it's time to deploy it to Arbitrum and check-in live!
😯 We're dealing with real money now that we're deploying to Arbitrum! You should have some Eth from your onboarding process. And don't worry, the Arbitrum chain is much less expensive to deploy on than mainnet.
- Create a deployer account to deploy your contract (
yarn generate
) - Send some Arbitrum ETH to it
- Check your account balances (
yarn account
) - Tweak the
00_deploy_your_contract.ts
script to only deploy your contract to Arbitrum (you don't want to deploy theBatchRegistry
contract, which is already deployed by us!) - Deploy your contract to Arbitrum (
yarn deploy --network arbitrum
) - Change the dApp chain to Arbitrum in
scaffold.config.ts
- Go to the Debug page and check that your contract is there
- Call the
checkMeIn
function!
✅ You should be checked-in! (You can check it by calling the yourContractAddress
function)
In future issues, we'll be showing this info on the UI.