With this API you can retrieve informations from the Casper's blockchain. It's build with Laravel and follow the Laravel's standards.
You'll find :
- Database Scripts
- Jobs
- Routes
Step by step guide of How-To install the API
composer install
Copy the file .env.example to .env. First define the MySQL's connection :
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=
DB_USERNAME=
DB_PASSWORD=
Then specify the parameters of the Casper's blockchain :
CASPER_CHAIN="casper"
RPC_ENDPOINT="https://..../rpc"
CORS_URL="https://..."
FIREBASE_SERVER_KEY="..."
NOTIFICATION_ICON="https://analytics.caspercommunity.io/assets/icon/favicon-32x32.png"
NOTIFICATION_URL_LINK="https://analytics.caspercommunity.io"
It can be "casper" of "casper-test" depending if you want to connect to the Mainnet of the Testnet
Specify an RPC endpoint to retrieve the info from the casper's blockchain. It should be a valid domain name otherwise you'll have CORS issues.
If you have CORS issues while retrieving the peers, you can setup CORS Anywhere and deploy it on Heroku. Then specify the URL in the .env file.
If you want to use the notifications's system, check the Firebase documentation.
Notification icon when a notification is send
Notification URL when a notification is send
If the configuration parameters of the database are correctly set, these commands will create the necessary tables.
cd /path/to/api
php artisan migrate
When you deploy the API on the web, configure the CORS file to allow the requests from your domain. Check the file /config/cors.php
Check the Task Scheduling documentation to activate the jobs and start retrieve data from the Casper's blockchain.
cd /path/to/api
php artisan serve
Get the last blocks from the blockchain and retrieve the data
Similar to the the GetBlockInfo's job, it retrieve historical data from the last block found to the block 0. It's running by block of 5000 block to not overload the server.
When there is a switch-block, we retrieve informations of the Era for each validators
Check if a notification should be send
Retrieve the information of the account (Account Hash and mainpurse)
Retrieve the balance of the account not yet processed and also the balance of the account not updated since more than a week.
Retrieve all the peers informations
Retrieve the validators informations
Once you have run at least each jobs one time (except api:ProcessHistory), you can run the tests via the command line
See also the "actions" tab on github. The tests are running after each commit.
php artisan test
The routes where specially define for the associated application "Casper Analytics"
GET /holders
GET /validator/delegations/{validator}
GET /validator/infos/{validator}
GET /validators
GET /validators/charts
GET /validator/charts/{validator}
POST /notification
GET /notification/{token}
POST /notification/register-token
DELETE /notification/{notificationToken}/{id}
GET /validators/list
GET /delegators/list
Check the Firebase documentation
The Casper Analytics API is open-sourced software licensed under the MIT license. The Laravel framework is open-sourced software licensed under the MIT license.