REST Ethereum Validator API
I've called two APIs sequentially. First, I find the validator indexes, and then I get their public keys.
https://RPC_ENDPOINT/eth/v1/beacon/states/8765432/sync_committees
https://RPC_ENDPOINT/eth/v1/beacon/states/8765432/validators?id=943501&id=1239839&id=513381&id=482814&id=1082134&id=462664&id=752468
-
Checks if the slot is before the Paris merge slot. If yes, returns an error.
-
Compares the slot with the current slot to ensure it's not in the future.
-
Fetch Block Hash
-
Fetch Block by Hash( BlockByHash function)
-
Calculate Fees
-
Process Transactions:
- Iterates over each transaction in the block.
- Fetches transaction receipts.
- Calculates the cost and checks if the transaction is a MEV transaction by comparing gas price with three times the base fee.
-
Calculate Reward
### fetch current head slot blocks
https://RPC_ENDPOINT/eth/v1/beacon/headers
https://RPC_ENDPOINT/eth/v2/beacon/blocks/8765432
More info:
docker compose -f docker-compose.dev.yml up
- Create an ".env" file, similar to ".env.sample". Fix the value of "RPC_ENDPOINT".
go run .
check requests.http file https://marketplace.visualstudio.com/items?itemName=humao.rest-client
@todo
@todo
- 📌 gin
- 📌 go-ethereum
- 📌 spf13/viper
- ✅ GET /blockreward/{slot}
- ✅ GET /syncduties/{slot}
- 💡 Better naming conventions and folder structure
- 💡 Caching with Redis
- 💡 Include API versioning,