This is where the results of the draw-calculator-cli are stored.
The draw calculator CLI is instantiated periodically from the cron workflow. This workflow checks if the most recent drawId
for a network is greater than the last committed draw, and if so, runs the draw-calculator-cli.
This data serves as the data source for the hosted Netlify API. More information on how to use this API can be found here.
This repository can be cloned/forked and the data reproduced or continued.
You'll need to add the following secrets to the repository (under settings/Secrets -> Repository Secrets):
Secret | Value/Description |
---|---|
ALCHEMY_MAINNET_URL | Mainnet RPC URL |
ALCHEMY_RINKEBY_URL | Rinkeby RPC URL |
MATICVIGIL_URL | Polygon RPC URL |
MUMBAI_URL | Mumbai RPC URL |
You'll also need a Github Personal Access Token in order to trigger the workflow remotely using the repository_dispatch
API.
The script at ./scripts/sync.js
will fire requests for the workflow to run from the genesis drawId (= 1) to the most recent drawId.
- Add the environmental secrets to your Github repo as shown above.
- Add your Personal Access Token and the other environmental variables to the
.envrc
as shown in the.envrc.example
. - Install the repo using
yarn
. - Enable Github Actions if you have not done so already.
- Update the constants in
./scripts/sync.js
to target this repo. - Run the sync script using
yarn sync
. This may take some time. You can see the progress by viewing the workflows executing in the Actions tab in your repo.
After following the appropriate steps to add the network to the draw-calculator-cli, do the following:
- Add the new network RPC endpoint URL to the repo secrets.
- Add this under the
env
section in the workflow cron.yaml "Run Draw Calculator CLI (if required)" step alongside the other env variables. This makes the secret available to the workflow as it runs. - Add logic to check if the CLI tool needs to be run here.
- Add a workflow step to commit prize files if they were created.
The generated file structure is:
v4-draw-results
│ README.md
│ package.json
│ ...
└───api
└───prizes
└───1 (chainId for mainnet)
│ └─── 0xb9a179dca5a7bf5f8b9e088437b3a85ebb495efe (Prize Distributor address)
│ └─── draw
│ └─── 1
│ │ 0xa123..json
│ │ 0xa124..json
│ │ ...
│ │ prizes.json
│ │ status.json
|
│ └─── 2
│ ...
└───137 (chainId for polygon)
└─── 0x8141bcfbcee654c5de17c4e2b2af26b67f9b9056 (Prize Distributor address)
│ └─── draw
│ └─── 1
│ │ 0xa123..json
│ │ 0xa124..json
│ │ ...
│ │ prizes.json
│ │ status.json
|
│ └─── 2
│ ...
File | Description |
---|---|
0xa123..json | Data for a winning address for a draw |
prizes.json | Index file including all winners for draw |
status.json | Metadata about the CLI run (status and time elapsed) |
Where prizes.json
is an index of all the individual address files and status.json
includes .
The file structure is according to Prize Distributor address (not by Ticket) is because a Ticket can mave multiple associated Prize Distributors. NOTE : The use of lower case strings for addresses.
For example:
-
./api/prizes/1/0xb9a179dca5a7bf5f8b9e088437b3a85ebb495efe/draw/1/prizes.json
will display all prizes for chainId = 1 (Ethereum Mainnet) for Prize Distributor (address:0xb9a179dca5a7bf5f8b9e088437b3a85ebb495efe
) for draw 1.This is also viewable at the Netlify API.
-
./api/prizes/137/0x8141bcfbcee654c5de17c4e2b2af26b67f9b9056/draw/12/prizes.json
will display all prizes for chainId = 137 (Polygon/Matic) for Prize Distributor (address:0x8141bcfbcee654c5de17c4e2b2af26b67f9b9056
) for draw 12.This is also viewable at the Netlify API.