Zk arcade repo
To install Beast, run the following command:
curl -L https://raw.githubusercontent.com/yetanotherco/zk_arcade/main/install_beast.sh | bash- Rust
- Elixir
- Node.js
- Docker
- Foundry
-
You need to run Aligned locally.
-
Make sure you are running Docker.
-
Send funds to your wallet from anvil pre-funded account with:
cast send <YOUR_WALLET_ADDRESS> --value 10ether --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --rpc-url http://localhost:8545 -
Add the
devnetnetwork to your wallet using the following parameters:- Network Name: Anvl
- Chain ID: 31337
- RPC URL: http://localhost:8545
- Currency Symbol: ETH
-
Deploy the Leaderboard contract with:
make deploy_contract NETWORK=devnet -
Set the Contract proxy address in
web/config/dev.exs:config :zk_arcade, :leaderboard_address, "<COMPLETE_ADDRESS_FROM_OUTPUT>"
-
Start the server:
make web_run
If you want to clean the database, run:
web_clean_db
As admin user, run:
cd /tmp
git clone [email protected]:yetanotherco/zk_arcade.git
cd zk_arcade
make debian_deps DB_PASSWORD=<>
make release
make release_install
As app user, run:
cdto the repo
cd zk_arcade
- Generate a SECRET_KEY_BASE with:
MIX_ENV=prod mix phx.gen.secret
- Create the env file, depending on the network:
- mainnet
make create_env_mainnet DB_PASSWORD=<> SECRET_KEY_BASE=<> PHX_HOST=<> NEWRELIC_KEY=<>
- Run the service with:
make create_service
As admin user, run:
cd /tmp
git clone [email protected]:yetanotherco/zk_arcade.git
cd zk_arcade
make release
make release install
As app user, run:
systemctl restart zk_arcade --user
First, we run a preprocessing step on the address whitelist to ensure it contains no duplicate or invalid addresses. Then, we use the valid addresses to generate the Merkle proof data for the new campaign, which will be stored in the database and added to the NFT contract.
The preprocessing script requires Python with pandas. Set up a virtual environment:
# Create virtual environment
python3 -m venv ~/.python_venvs/pandas_venv
# Activate virtual environment
source ~/.python_venvs/pandas_venv/bin/activate
# Install dependencies
pip install -r data/requirements.txtTo run the preprocessing:
- Put your addresses in
whitelist_addresses.csv, or provide your own CSV file. - Activate the Python virtual environment:
source ~/.python_venvs/pandas_venv/bin/activate
- Run the preprocessing script:
Where:
make preprocess_whitelist WHITELIST_PATH=<whitelist_path> INSERTED_DIRECTORY=<inserted_directory>
WHITELIST_PATH: Path to the CSV file containing the addresses to whitelistINSERTED_DIRECTORY: Directory containing previously inserted addresses (default:data/inserted, for devnet use:data/inserted_devnet)
- Removed addresses will be written to
removed_addresses.csv, and the addresses to generate Merkle proof data will be written tonew_addresses.csvintodatadirectory.
-
Complete
.envfile intomerkle_tree/.envwith the required environment variables.DATABASE_URL=postgresql://<USER>:<PASSWORD>@<HOST>:<PORT>/<DB_NAME> -
Run:
make generate_merkle_tree WHITELIST_PATH=data/new_addresses.csv OUTPUT_FILE=./merkle_tree/merkle_output.json MERKLE_ROOT_INDEX=<campaign_number> INSERTED_DIRECTORY=<directory>
Where:
WHITELIST_PATH: Path to the CSV file with addresses (usuallydata/new_addresses.csvfrom preprocessing)OUTPUT_FILE: Path where the Merkle proof JSON will be writtenMERKLE_ROOT_INDEX: Campaign number (must match the index the merkle root will take in the contract)INSERTED_DIRECTORY: Directory where filtered addresses CSV will be saved asinserted_<MERKLE_ROOT_INDEX>.csv
For devnet, use:
INSERTED_DIRECTORY=./data/inserted_devnet -
This command generates the Merkle proof data, stores the Merkle paths in the backend database, writes the campaign Merkle root to the output file, and saves filtered addresses to the specified directory.
-
Add the new campaign Merkle root to the NFT contract by running:
make add_merkle_root NETWORK=<network>
The following is a step by step on how to mark all pending proofs as failed and verify that the change is consistent.
See which proofs are currently pending or failed.
SELECT COUNT(*) FROM proofs WHERE status = 'pending';
SELECT COUNT(*) FROM proofs WHERE status = 'failed';if you want to see their ids you can do:
SELECT id FROM proofs WHERE status = 'pending';
SELECT id FROM proofs WHERE status = 'failed';BEGIN;
UPDATE proofs SET status = 'failed' WHERE status = 'pending';Confirm that the number of failed proofs now equals the old failed count plus the old pending count, that is:
SELECT COUNT(*) FROM proofs WHERE status = 'pending';
SELECT COUNT(*) FROM proofs WHERE status = 'failed';If everything went well commit the changes
COMMIT;otherwise, rollback and start again
ROLLBACK;