Pastel Explorer API (Backend)
This is a backend application that stores blockchain data into the sqlite database and serves block, transaction and address data via REST GET endpoints for visualization in the frontend.
It's designed to integrate with Pastel (pastel.network) cryptocurrency but it should work for all Bitcoin-like currencies like Bitcoin, Zcash.
Script | Description | Note |
---|---|---|
build |
Builds app in prod mode | |
preinstall |
Checks is yarn was used package manager | It runs automatically before every install |
seedblockchain |
Runs a script to synchronize blockchain data with sqlite | |
start |
Starts app locally | |
lint |
Checks linter rules | |
type-check |
Checks TypeScript types | |
typeorm |
Helper to run migration commands |
If you want to create a new Entity or add some fields to existing entities you need to create a migration file.
yarn typeorm migration:generate ./src/migration/NameOfMigration -d ./src/datasourcecon.ts
Run migrations:
yarn db:migrate
Create dotenv file from .env.example
and fill the secrets.
cp .env.example .env
# Install deps
yarn
# Run migrations
yarn db:migrate
# Start the app
yarn start
- Install node lts version via nvm, install yarn, pm2 globally.
- Install and run pasteld node via pastel-utility.
- Prepare deploy script:
# restart-app.sh
# use the proper node version and project path
#!/bin/bash
PATH="$PATH:/home/ubuntu/.nvm/versions/node/v20.13.1/bin/"
cd /home/ubuntu/pastel-explorer-backend
git pull
yarn install
NODE_ENV=production yarn build
pm2 delete explorer-api explorer-worker-update-blocks explorer-worker-update-data
yarn db:migrate
pm2 start pm2.yaml
# use to update all
yarn update-all
# use to update from block n to the last block
yarn update-all startAt [block_number]
# use to update a single block
yarn update-all [block_number]
# use to update all blocks
yarn update-blocks
# use to update from block n to the last block
yarn update-blocks startAt [block_number]
# use to update a single block
yarn update-blocks [block_number]
# use to update all tickets
yarn update-tickets
# use to update from block n to the last block
yarn update-tickets startAt [block_number]
# use to update a single ticket by Block Height
yarn update-tickets [block_number]
# use to update all senses
yarn update-senses
# use to update a single sense by TXID
yarn update-senses [TXID]
# use to update a single sense by Block Height
yarn update-senses [block_number]
# use to update all cascade
yarn update-cascades
# use to update a single cascade by TXID
yarn update-cascades [TXID]
# use to update a single cascade by Block Height
yarn update-cascades [block_number]
# use to update all nfts
yarn update-nfts
# use to update a single nft by TXID
yarn update-nfts [TXID]
# use to update a single nft by Block Height
yarn update-nfts [block_number]
# use to update all address
yarn update-addresses
# use to update a single address
yarn update-addresses [address]