Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chainstacklabs/race-ronin-chain
An (almost) on-chain game where you race the Ronin chain based on block hashes
https://github.com/chainstacklabs/race-ronin-chain
evm foundry gaming ronin web3
Last synced: about 1 month ago
JSON representation
An (almost) on-chain game where you race the Ronin chain based on block hashes
- Host: GitHub
- URL: https://github.com/chainstacklabs/race-ronin-chain
- Owner: chainstacklabs
- License: mit
- Created: 2024-03-10T08:16:48.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-03-11T07:28:37.000Z (10 months ago)
- Last Synced: 2024-03-11T08:38:28.330Z (10 months ago)
- Topics: evm, foundry, gaming, ronin, web3
- Language: Solidity
- Homepage: https://docs.chainstack.com/docs/ronin-on-chain-meta-racing-game
- Size: 126 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Chainstack is the leading suite of services connecting developers with Web3 infrastructure
Supported protocols •
Chainstack blog •
Chainstack docs •
Blockchain API reference •
Start for free# Race Ronin Chain
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](https://docs.chainstack.com/docs/ronin-on-chain-meta-racing-game)
## Prerequisites
Before you start, ensure you have the following:
- **Chainstack account**: Needed to deploy a Ronin node. [Start for free](https://chainstack.com/).
- **Foundry**: Used for compiling, testing, and deploying the contract. Follow the installation instructions [here](https://getfoundry.sh/).
- **web3.py**: Necessary for participation and winner calculation & submission scripts. Installation can be done via pip: `pip install web3`.## Quick Start
1. **Clone the repository**: Access all necessary files for the game.
```
git clone https://github.com/Chainstacklabs/race-ronin-chain.git
cd race-ronin-chain
```2. **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"
```3. **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
```
3. **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.
4. **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.
```
```