Supported protocols • Chainstack blog • Chainstack docs • Blockchain API reference • Start for free
An (almost) on-chain game where you race the Ronin chain based on block hashes using the Foundry framework.
See the full details in the Chainstack Developer Portal — Ronin: On-Chain meta racing game
Before you start, ensure you have the following:
- Chainstack account: Needed to deploy a Ronin node. Start for free.
- Foundry: Used for compiling, testing, and deploying the contract. Follow the installation instructions here.
- web3.py: Necessary for participation and winner calculation & submission scripts. Installation can be done via pip:
pip install web3
.
-
Clone the repository: Access all necessary files for the game.
git clone https://github.com/Chainstacklabs/race-ronin-chain.git cd race-ronin-chain
-
Add your Chainstack RPC node: Add your Chainstack RPC node URL to the
foundry.toml
file.[profile.default] version = "0.8.19" src = "src" out = "out" libs = ["lib"] eth_rpc_url = "CHAINSTACK_NODE_ENDPOINT"
-
Generate the contract ABI: If you modify the contract, generate a new ABI with:
forge build --silent && jq '.abi' ./out/RaceRoninChain.sol/RaceRoninChain.json > ./abi/RaceRoninChain.abi
- Deploy the contract: Ronin does not support EIP-1559, so use legacy transactions.
forge create src/RaceRoninChain.sol:RaceRoninChain --private-key YOUR_PRIVATE_KEY --constructor-args TREASURY_ADDRESS --legacy
Replace YOUR_PRIVATE_KEY
with your deployer private key and TREASURY_ADDRESS
with the address to receive the house fees.
- Interact with the contract: Use the provided Python scripts to enter races and compute & submit winners.
enter_race.py
: For generating predictions and entering races.compute_stats_and_submit_winner.py
: For calculating and submitting race winners.
Ensure to provide necessary variables like private keys, addresses, and Chainstack
endpoints within the scripts.