A Python application that extracts Polygon staking reward claim history from Ethereum contracts and stores it in a SQLite database. Built to run in a Docker container with unit tests included.
2. Polygon is an L2 built from Ethereum. We can track Polygon staking activity by reading from contracts on the Ethereum chain. Write some Python code to extract the reward claim history for any arbitrary address by reading the data from the relevant Polygon contracts on Ethereum. Store the results in SQLite or any SQL database.
a. Should build and run in a Docker container.
b. Bonus points for good comments and unit tests.
c. You may find these references useful:
i. https://docs.polygon.technology/pos/reference/contracts/genesis-contracts/#parent-chain-ethereum-mainnet
ii. https://github.com/0xPolygon/polygon-docs/blob/main/docs/pos/reference/contracts/stakingmanager.md
iii. https://github.com/0xPolygon/pos-contracts/blob/main/docs/autogen/src/contracts/staking/StakingInfo.sol/contract.StakingInfo.md
- Docker
- An Ethereum RPC URL (e.g., from Infura or Alchemy)
git clone <repository-url>
cd polygon-reward-extractorEnsure you have an .env file in the project root with the following:
ETH_RPC_URL=<your_ethereum_rpc_url>To build and run the container:
docker-compose up --buildIt is recommended to run the container multiple times to verify full functionality.
To stop the container:
docker-compose downTo execute unit tests:
docker-compose run polygon-reward-extractor python -m unittest discover -s test -v