Demo project for the MetaMask Delegation Toolkit
This is a public demo project that showcases the MetaMask Delegation Toolkit. It contains the same game logic as the Red Balloon Game deployed at EthCC '24 in Brussels.
This project includes the following packages/apps:
@rb/web
: a Next.js app that contains the game logic@rb/contracts
: a Hardhat project that contains the smart contracts used in the game
- Node.js v20.x
- Docker Compose
- Bun
The project is set up so you can run the game locally out of the box.
git clone --recursive https://github.com/MetaMask/demo-red-balloon.git
cd demo-red-balloon
bun install
Note
You will need to populate the bunfig.toml
file with your @codefi
NPM token in order to install the @codefi/delegator-core-viem
package.
cp .env.example .env
Note
Make sure to update the .env
file with your INFURA_API_KEY
, since we need it to fork the Sepolia network locally.
bun db:start
bun db:studio
open https://local.drizzle.studio
bun chain:start
Note
This step may take a while (~1 minute) to complete. Please wait before moving on to the next step.
Tip
Otterscan (local block explorer) is available at http://localhost:5100
bun seed
bun dev
open http://localhost:3000
In order to deploy the game to production, you'll need to update the .env
file with the desired values.
Warning
When deploying contracts to production, you'll need to ensure that the account tied to the DEPLOYER_PRIVATE_KEY
has sufficient ETH to pay for the PRIZE_ETH
plus gas costs.
In order to deploy the contracts to a live network:
- Ensure that the target live network is configured in the
hardhat.config.ts
file. - From the
packages/contracts
directory, run the following command:
bun deploy --network <network_name>
- The contracts addresses for
<network_name>
will be populated in theapps/web/src/contracts/deployedContracts.ts
file.
Note
Make sure the NEXT_PUBLIC_CHAIN_ID
and NEXT_PUBLIC_CHAIN_URL
values in the .env
file match the network you are deploying to.
From the apps/web
directory, run the following command:
bun db:seed
You can either run the web app locally against the production contracts and database, or deploy it to a hosting provider of your choice (e.b., Vercel, Netlify, etc.).