Kaio is a Rust-based blockchain event listener and processor specifically designed to interact with the StarkNet blockchain. It listens for specific events emitted from smart contracts, parses them, and stores the results in a PostgreSQL database. Kaio is intended to help developers monitor and react to smart contract events on StarkNet, providing an efficient way to build real-time data pipelines for decentralized applications.
- Listens for
BetPlaceevents on StarkNet smart contracts. - Parses event data, including user address, bet amount, probabilities, and more.
- Automatically syncs the latest blocks and stores event data in a PostgreSQL database.
- Efficient handling of large event streams.
- Supports automatic reconnection and resynchronization.
Before you start, make sure you have the following installed:
- Rust (latest stable version)
- PostgreSQL (version 12 or higher)
- Docker (optional, if you want to use Docker for the database setup)
git clone https://github.com/AkiraaCorp/kaio.git
cd kaio-
RPC Endpoint:
You can modify the RPC URL in the main function (let rpc_url = Url::parse(...)) to point to a different StarkNet endpoint if needed. -
Contract Addresses:
Update thecontract_addressesvector with the addresses of the contracts you want to monitor.
When you run Kaio using cargo run, it will:
-
Connect to the Specified RPC Endpoint:
Ensure that your specified RPC provider (e.g., https://free-rpc.nethermind.io/sepolia-juno/) is accessible (its free but you will be rate limit) -
Check the Database:
If the database is not initialized, it will automatically create the required tables. -
Start Listening for Events:
Kaio will start processing blocks from the last synced block and look forBetPlaceevents. Each event will be parsed and stored in the database. -
Log Events and Store Data:
Successfully parsed events will be printed to the console and stored in thebetstable in your PostgreSQL database.
If you want to listen to a different set of contracts, update the following section in the code:
let contract_addresses = vec![
Felt::from_hex("CONTRACT_TO_LISTEN")
.expect("Invalid contract address"),
];Add or remove contracts as needed.
- Ensure that your PostgreSQL instance is running and accessible at the specified
DATABASE_URL. - Check firewall or connection issues if you are using a remote PostgreSQL instance.
- If event data parsing fails, verify the contract ABI and event signature.
- You can print the raw event data using
println!to debug the issue.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to submit issues or pull requests if you have any improvements or suggestions!
Kaio was developed by [AkiraaCorp]. Reach out at contact@sightbet.com for inquiries.
