Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1. Check-in with the BatchRegistry contract #12

Open
phipsae opened this issue Jan 1, 2025 · 11 comments
Open

1. Check-in with the BatchRegistry contract #12

phipsae opened this issue Jan 1, 2025 · 11 comments

Comments

@phipsae
Copy link
Collaborator

phipsae commented Jan 1, 2025

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 Optimism.

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.

289478961-7c2414dd-1247-4f22-90c9-89efe2372c54

💡 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:

  1. Clone the repo to your local machine (If you haven't already)
  2. Navigate to the cloned directory in your terminal.
  3. Create a new branch using git checkout -b [your-branch-name]

2. Spin up Your Local SE-2

Set up your local environment:

  1. Run yarn install (install dependencies)
  2. Run yarn start (starts SE2 front-end)
  3. Go to http://localhost:3000/. You should see SE-2 app.

💡 You'll notice that the dApp points to the Optimism 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:

  1. The Batch is open (should be open already :D)
  2. Your EOA address is on the allowed list (ping us if you are not on the list)
  3. 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 Optimism, we'll deploy it locally so we can test.

  1. Start your local hardhat node: yarn chain
  2. Deploy the BatchRegistry contract: yarn deploy
    a. Check packages/hardhat/deploy/00_deploy_your_contract.ts
  3. Change the dApp chain to hardhat in scaffold.config.ts (targetNetwork should be chain.hardhat)
  4. 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.

  1. Create a CheckIn.sol contract in packages/hardhat/contracts/
  2. Declare an interface for the BatchRegistry contract (More info here: Interfaces in Solidity By Example)
  3. The constructor should receive the address of the BatchRegistry contract
  4. Implement a function in your contract that calls the checkIn BatchRegistry function.
  5. (Optional) You can implement an owner pattern to avoid other people calling the function in your contract ;)
  6. Tweak the 00_deploy_your_contract.ts script to deploy your contract (and pass the address of the BatchRegistry contract)

Test it!

6. Check-in live

Once you have tested that your contract works, it's time to deploy it to Optimism and check-in live!

😯 We're dealing with real money now that we're deploying to Optimism! You should have some oEth from your onboarding process. And don't worry, the Optimism chain is much less expensive to deploy on than mainnet.

  1. Create a deployer account to deploy your contract (yarn generate)
  2. Send some Optimism ETH to it
  3. Check your account balances (yarn account)
  4. Tweak the 00_deploy_your_contract.ts script to only deploy your contract to Optimism (you don't want to deploy the BatchRegistry contract, which is already deployed by us!)
  5. Deploy your contract to Optimism (yarn deploy --network optimism)
  6. Change the dApp chain to Optimism in scaffold.config.ts
  7. Go to the Debug page and check that your contract is there
  8. 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.

@FrankiePower
Copy link

CheckIn Successful.

@aliveevie
Copy link

Hey @phipsae, I'm NOT in allowList, showing false
https://speedrunethereum.com/builders/0x85ba183Fb4c16D435B076DDe459dAfc8eFF864d8
and I complete everything and joined, can you please add me

@All-Khwarizmi
Copy link
Contributor

Checkin 🫡

@NikolaiL
Copy link
Contributor

NikolaiL commented Jan 7, 2025

Checked In

@aliveevie
Copy link

aliveevie commented Jan 7, 2025

@phipsae, please whitelist me, I have been in speedrun for almost two months, and I completed up to five challenges. I was upgraded to buidl since last week. https://speedrunethereum.com/builders/0x85ba183Fb4c16D435B076DDe459dAfc8eFF864d8
image

@DimaKush
Copy link
Contributor

DimaKush commented Jan 7, 2025

Done

@obah
Copy link
Contributor

obah commented Jan 7, 2025

Checked in

@phipsae
Copy link
Collaborator Author

phipsae commented Jan 7, 2025

@phipsae, please whitelist me, I have been in speedrun for almost two months, and I completed up to five challenges. I was upgraded to buidl since last week. https://speedrunethereum.com/builders/0x85ba183Fb4c16D435B076DDe459dAfc8eFF864d8 image

@aliveevie, your BG profile shows that you're in Batch 13? And you are not part of the Telegram channel of Batch 12? How did you come across this repository? Pls text me on TG (@phipsae).

@ludmila-omlopes
Copy link
Contributor

checked in

@livinalt
Copy link

Check-in done

@Shnikbakht
Copy link

Just checked in!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants