Skip to content

3Dpass/explorer

 
 

Repository files navigation

3dpscan

3dpscan is a blockchain explorer for The Ledger of Things.

Terminology

  • Data indexing: we use js scripts to query blockchain history data, normalize and save them to database.
  • Scan: it's a process that we index blockchain data in a height asc order.

Prerequisites

  1. Node.js: Version 18.0.0 or higher
  2. Yarn: Version 3.6.0 or higher (package manager)
  3. MongoDB: For data storage
  4. Full Archive Blockchain Node: A running blockchain node with --pruning archive flag
    • The node should be synced from genesis block
    • Example command to run the node:
    ./target/release/poscan-consensus \
      --base-path ~/3dp-chain/ \
      --chain mainnetSpecRaw.json \
      --name "my 160 USD dedicated server" \
      --validator \
      --telemetry-url "wss://submit.3dpass.network/submit 0" \
      --author <your mining pub key> \
      --no-mdns \
      --unsafe-ws-external \
      --unsafe-rpc-external \
      --rpc-cors all \
      --ws-port 9945 \
      --rpc-port 9934 \
      --pruning archive

Code structure

This code base can be divided into 3 parts: data indexing, servers(restful and graphql) and fronted pages.

Data indexing

Currently, we have the following packages for data indexing.

Data servers

We have a RESTful server and a GraphQL server, and the RESTful server will be finally replaced by the GraphQL server.

The site package call APIs from servers and render fronted pages.

Setup

We should install MongoDB first for data storage.

Then generally we should first index necessary data, then setup restful and graphql servers, and finally the site. Servers rely on the indexed data, and site reply on the APIs by the servers.

Step 1: Install Dependencies

Install Backend Dependencies

cd backend
yarn install

Install Frontend Dependencies

cd site
yarn install

Step 2: Set Up MongoDB

Option A: Using Docker Compose (Recommended for Development)

The project includes a compose.yml file for easy MongoDB setup:

# From the project root
docker-compose up -d

This will start MongoDB with:

  • Port: 27017
  • Username: admin
  • Password: password
  • Data directory: ./data/db

Option B: Manual MongoDB Installation

Install MongoDB following the official MongoDB installation guide.

Step 3: Configure Environment Variables

Each indexer and server requires environment variables. Create .env files in the respective package directories.

Common Environment Variables

All indexers and servers need these variables:

MongoDB Connection Variables

Each indexer uses its own MongoDB database. You'll need to set these for each indexer:

# Block Scan
MONGO_BLOCK_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_BLOCK_SCAN_NAME=block_scan

# Account Scan
MONGO_ACCOUNT_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_ACCOUNT_SCAN_NAME=account_scan

# Runtime Scan
MONGO_RUNTIME_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_RUNTIME_SCAN_NAME=runtime_scan

# Identity Scan
MONGO_IDENTITY_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_IDENTITY_SCAN_NAME=identity_scan

# Asset Scan
MONGO_ASSET_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_ASSET_SCAN_NAME=asset_scan

# Pallet Assets Scan
MONGO_PALLET_ASSET_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_PALLET_ASSET_SCAN_NAME=pallet_asset_scan

# Pallet Proxy Scan
MONGO_PALLET_PROXY_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_PALLET_PROXY_SCAN_NAME=pallet_proxy_scan

# Pallet Recovery Scan
MONGO_PALLET_RECOVERY_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_PALLET_RECOVERY_SCAN_NAME=pallet_recovery_scan

# Multisig Scan
MONGO_MULTISIG_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_MULTISIG_SCAN_NAME=multisig_scan

# Vesting Scan
MONGO_VESTING_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_VESTING_SCAN_NAME=vesting_scan

# Uniques Scan (if needed)
MONGO_UNIQUES_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_UNIQUES_SCAN_NAME=uniques_scan

Chain Configuration

# Chain identifier (required for server)
# Valid values: 3dpass, polkadot, kusama, paseo, statemine, statemint, westmint, etc.
# For The Ledger of Things, use: 3dpass
CHAIN=3dpass

# Chain RPC endpoint (WebSocket URL)
# This should point to your full archive node
WS_URL=ws://localhost:9945
# Or for secure connection:
# WS_URL=wss://your-node.example.com:9945

Server Configuration

# REST API Server Port (default: 5010)
PORT=5010

# GraphQL Server Port (default: 7100)
PORT=7100

# Optional: Simple mode for call parameters
SIMPLE_MODE=0

# Optional: Achainable profile integration
ACHAINABLE_PROFILE_URL=https://api.achainable.com
ACHAINABLE_AUTHORIZATION_KEY=your-api-key-here

Frontend Configuration

Create a .env file in the site/ directory:

# Chain identifier for the frontend
# Must match one of the supported chains (3dpass, polkadot, kusama, etc.)
REACT_APP_PUBLIC_CHAIN=3dpass

# API endpoint (REST API server)
REACT_APP_PUBLIC_API_END_POINT=http://localhost:5010

# GraphQL endpoint
REACT_APP_PUBLIC_GRAPHQL_END_POINT=http://localhost:7100/graphql

# Optional: SubSquare API endpoint
REACT_APP_PUBLIC_SUBSQUARE_API_END_POINT=https://{chain}.subsquare.io/api

Creating .env Files

For each indexer package, create a .env file in its directory:

# Example: backend/packages/block-scan/.env
MONGO_BLOCK_SCAN_URL=mongodb://admin:password@localhost:27017
MONGO_BLOCK_SCAN_NAME=block_scan
WS_URL=ws://localhost:9945
CHAIN=3dpass

Step 4: Run the Indexers

Indexers scan the blockchain and store data in MongoDB. You should run them in order, starting with the most fundamental ones.

4.1 Block Scan (Required - Start First)

The block scan indexes blocks, extrinsics, events, calls, and transfers. This is the foundation for all other indexers.

cd backend/packages/block-scan
node src/index.js

Or using PM2 (recommended for production):

cd backend/packages/block-scan
NODE_ENV=production pm2 start src/index.js --name block-scan --log-date-format 'YYYY-MM-DD HH:mm Z'

4.2 Runtime Scan (Recommended)

Indexes runtime metadata versions:

cd backend/packages/runtime-scan
node src/index.js

4.3 Account Scan (Recommended)

Updates latest account balance information:

cd backend/packages/account-scan
node src/index.js

4.4 Additional Indexers (Optional)

Run these based on your needs:

# Identity Scan
cd backend/packages/identity-scan
node src/index.js

# Asset Scan
cd backend/packages/asset-scan
node src/index.js

# Pallet Assets Scan
cd backend/packages/pallet-assets-scan
node src/index.js

# Pallet Proxy Scan
cd backend/packages/pallet-proxy-scan
node src/index.js


# Multisig Scan
cd backend/packages/multisig-scan
node src/index.js

# Vesting Scan
cd backend/packages/vesting-scan
node src/index.js


### Running Multiple Indexers

For production, use PM2 to manage multiple indexers:

```bash
# Install PM2 globally if not already installed
npm install -g pm2

# Start all indexers
cd backend/packages/block-scan && pm2 start src/index.js --name block-scan
cd ../runtime-scan && pm2 start src/index.js --name runtime-scan
cd ../account-scan && pm2 start src/index.js --name account-scan
# ... repeat for other indexers

# View status
pm2 status

# View logs
pm2 logs

# Stop all
pm2 stop all

Step 5: Run the Servers

Once you have indexed some data, you can start the servers.

5.1 REST API Server

The REST API server provides endpoints for blocks, extrinsics, accounts, transfers, etc.

cd backend/packages/server
node src/index.js

The server will start on http://localhost:5010 (or your configured PORT).

5.2 GraphQL Server (Recommended)

The GraphQL server is the modern API and will eventually replace the REST server.

cd backend/packages/graphql-server
node src/index.js

The GraphQL endpoint will be available at http://localhost:7100/graphql.

5.3 Additional Servers (Optional)

# Identity Server
cd backend/packages/identity-server
node src/index.js  # Default port: 5011

# Multisig Server
cd backend/packages/multisig-server
node src/index.js  # Default port: 6011

# Pallet Assets Server
cd backend/packages/pallet-assets-server
node src/index.js  # Default port: 5100

Step 6: Run the Website

Once the servers are running, start the frontend:

cd site
yarn start

The website will be available at http://localhost:3000.

Building for Production

cd site
yarn build

This creates an optimized production build in the build/ directory.

Verification

Check Indexer Status

  1. Block Scan: Check MongoDB for the block_scan database and verify blocks are being indexed
  2. Account Scan: Check the account_scan database for account data
  3. Monitor indexer logs for errors

Check Server Status

  1. REST API: Visit http://localhost:5010/overview - should return network overview data
  2. GraphQL: Visit http://localhost:7100/graphql - should show GraphQL playground

Check Website

  1. Visit http://localhost:3000
  2. The homepage should display network statistics
  3. Try searching for a block or account

Troubleshooting

MongoDB Connection Issues

  • Verify MongoDB is running: docker ps or mongod --version
  • Check connection string format: mongodb://username:password@host:port
  • Ensure MongoDB is accessible from your network

Indexer Not Starting

  • Verify blockchain node is running and accessible
  • Check WS_URL is correct and node has --unsafe-ws-external flag
  • Ensure node is fully synced (for initial indexing)
  • Check indexer logs for specific errors

Server Not Starting

  • Verify required indexers have run and created data
  • Check MongoDB databases exist
  • Verify CHAIN environment variable is set correctly
  • Check server logs for initialization errors

Website Not Loading Data

  • Verify REST API or GraphQL server is running
  • Check REACT_APP_PUBLIC_API_END_POINT and REACT_APP_PUBLIC_GRAPHQL_END_POINT in site .env
  • Check browser console for API errors
  • Verify CORS is enabled on the server

Production Deployment

For production deployment:

  1. Use PM2 or similar process manager for all services
  2. Set up proper logging and monitoring
  3. Use environment-specific .env files
  4. Configure reverse proxy (nginx) for the website
  5. Set up MongoDB replication for high availability
  6. Use secure MongoDB connections
  7. Configure proper firewall rules

Indexer Order and Dependencies

Critical Path:

  1. Block Scan (must run first)
  2. Runtime Scan (recommended early)
  3. Account Scan (can run in parallel with block scan)

Optional (can run in parallel after block scan):

  • Identity Scan
  • Asset Scan
  • Pallet Assets Scan
  • Pallet Proxy Scan
  • Multisig Scan
  • Vesting Scan

Notes

  • Initial indexing can take a long time depending on chain size
  • Indexers run continuously and sync new blocks as they are produced
  • You can run multiple indexers in parallel after the initial block scan
  • The REST API server and GraphQL server can run simultaneously
  • The website requires at least one API server (REST or GraphQL) to be running

REST API

1. Network overview:

URL: https://api.3dpscan.xyz/overview

{
  "latestHeight": 1337566,
  "finalizedHeight": 1337564,
  "totalIssuance": "771319474246270346717",
  "signedExtrinsics": 1135042,
  "transfers": 1085854,
  "accounts": 3897
}

4. Accounts list:

URL: https://api.3dpscan.xyz/accounts?page=0&page_size=25

Parameters:

  • page=0 - page number
  • page_size=25 - number of accounts per page

Response:


  "items": [
    {
      "address": "d1HXD9afZhqTM95iN66QKRh1D1Gzuwtvvox84GGe8L4xF1L51",
      "data": {
        "total": "3000020989978690000",
        "free": "3000018973978690000",
        "reserved": "2016000000000",
        "miscFrozen": "3000000000000000000",
        "feeFrozen": "0x000000000000000029a2241af62c0000"
      },
      "detail": {
        "nonce": 10,
        "consumers": 1,
        "providers": 1,
        "sufficients": 0,
        "data": {
          "free": "0x000000000000000029a2355caf6e81d0",
          "reserved": 2016000000000,
          "miscFrozen": "0x000000000000000029a2241af62c0000",
          "feeFrozen": "0x000000000000000029a2241af62c0000"
        }
      }
    },...
  ],
  "page": 1,
  "pageSize": 25,
  "total": 7999
}

2. Transfers list:

URL: https://api.3dpscan.xyz/transfers?page=0&page_size=25&signed_only=true

Parameters:

  • page=0 - page number
  • page_size=25 - number of transfers per page
  • signed_only=true - if only signed transfers required (the true is recommended for most of the cases)

Response:

{
  "items": [
    {
      "indexer": {
        "blockHeight": 1276047,
        "blockHash": "0x9c947e48bee48be9aaf1654141512667348c3af93b026030b737091b91c52975",
        "blockTime": 1740088569406,
        "eventIndex": 14,
        "extrinsicIndex": 7
      },
      "from": "d1GgtEoKL4Kwd12zTdpkV9KChrvvP5ZjhQRVEmjkTTmBVW9Cy",
      "to": "d1FnU4K1YphVHFvQ2FgkLYhcvshb83YkXK52jTDU17uPrcX4n",
      "balance": "218280695797780",
      "isSigned": true,
      "isNativeAsset": true
    },
  ],
  "page": 0,
  "pageSize": 25
}

3. Transfers history for a given address (both incoming and outgoing):

URL: https://api.3dpscan.xyz/accounts/d1FygYC5r7rJz4P7y14oJRKEGBwohkNpV2h1h6vjudz2DUvfP/transfers?page=0&page_size=25

Parameters:

  • ../d1FygYC5r7rJz4P7y14oJRKEGBwohkNpV2h1h6vjudz2DUvfP/.. - the address to query blockcain data for
  • page=0 - page number
  • page_size=25 - number of transfers per page

Response:

{
  "items": [
    {
      "indexer": {
        "blockHeight": 1173176,
        "blockHash": "0x915604004e69261a5e8852a98627840ab087443a79b1f126d7d7c9ea05a306db",
        "blockTime": 1733800300272,
        "eventIndex": 59
      },
      "from": "d1Dhvwtmm6213dcHSQGjVrgBUAPXqyPCkxed6GoWjWpMBM4Zz",
      "to": "d1FygYC5r7rJz4P7y14oJRKEGBwohkNpV2h1h6vjudz2DUvfP",
      "balance": "1044776119402",
      "isSigned": false,
      "isNativeAsset": true
    },
 {
      "indexer": {
        "blockHeight": 1164150,
        "blockHash": "0xb805115134298d9f50a0c02b50947f66431d1118ee6389dd380c55be959cdb59",
        "blockTime": 1733248259849,
        "eventIndex": 10,
        "extrinsicIndex": 5
      },
      "from": "d1FygYC5r7rJz4P7y14oJRKEGBwohkNpV2h1h6vjudz2DUvfP",
      "to": "d1CG3nyJJgJnURJHVsQvE2zHCEay2459Bsv6wF7aLiBZ7xT44",
      "balance": "2744665400000000",
      "isSigned": true,
      "isNativeAsset": true
    }, 

  ],
  "page": 0,
  "pageSize": 25,
  "total": 6803
}

4. Extrinsic data by txid or extrinsic id:

By txid (extrinsic hash):

By extrinsic id (blockHeight-extrinsicIndex):

Response:

{
  "indexer": {
    "blockHeight": 1341436,
    "blockHash": "0x3a4b3e148349ea3b70107fecc96aeb379346e82e4264edc27805db82c842592b",
    "blockTime": 1744087081836,
    "extrinsicIndex": 6
  },
  "version": 132,
  "hash": "0x4321d4e370b2d43116e8bf5fdb8a260a01d90321f84c3192fb265424246c8b18",
  "isSuccess": true,
  "call": {
    "callIndex": "0x0804",
    "section": "balances",
    "method": "transferAll",
    "args": [
      {
        "name": "dest",
        "type": "LookupSource",
        "value": "d1CQTPpCb9YTAowLmzMByyRpue8QmvJZxMXvSxPqiJeQpFpFu"
      },
      {
        "name": "keepAlive",
        "type": "bool",
        "value": true
      }
    ]
  },
  "eventsCount": 4,
  "isSigned": true,
  "listIgnore": false,
  "nonce": 1254,
  "signer": "d1Hsqexg7GJuHYwaqJ5k5EXvHc4f1MBK5zWMCqK3mhHGmWMiJ",
  "signature": "0xf2484deb8180465b19752d77e7e35c3b4402c84e213b6248a323e58dd36bce01b94063d4ffe5a92c10fed9ddf784ad2afbb4725fc07853143f0b908db7839c8d",
  "tip": "0",
  "lifetime": [
    1341431,
    1345527
  ],
  "callsCount": 1,
  "isFinalized": true
}

4. Block data by its hash or height:

By block hash:

By block height:

Response:

{
  "height": 1341597,
  "hash": "0xb72b088ebfb6d027994b13e8ff54dae78b01cfd17424c1979746cba0dc2dbb0a",
  "time": 1744097039876,
  "validator": null,
  "parentHash": "0x536f5815be7664393583acb241b90f0b8c038d698007073f294a21f712c9240f",
  "stateRoot": "0xf16951200533462351b1afe459a13e678114dcae7c4e7395566d3f533a70dab4",
  "extrinsicsRoot": "0x3d0a6cf04b7279d0d4a14d8bb125b0b1d54ab5f79ff208d9b4a56e8f4d28165b",
  "digest": {
    "logs": [
      {
        "preRuntime": [
          "0x706f7363",
          "0xe67f0c973a5d521831514b62ceaa24e6c6bc22cf1ab363459e990d1c0d52f51a"
        ]
      },
      {
        "seal": [
          "0x70736332",
          "0xadef01000000000000000000000000000000000000000000000000000000000000004191ca50d2a9a54242b5c00da9e83d1959fa4755e39aa0413fa32d634512817329da6cdc7e27edc5242a4f82568f91b1b84d4570e552211e184e61f511f57348a3ce9483f262859db121545b0ffdd43295455d907a9a3637493cd06e0d9ccb936f127a99e52548622fa756ae9a61cd6756730742c8217708136ba27cb58a3e75743b85e1701f51c92c3bc11eb21e8ac87f19d9b085fa0b790bf9e9902b013abfe407040713a1f9833f7f8d67f1826be1de9a59bbe4406eb5179fff3eb181"
        ]
      },
      {
        "other": "0x6772696432642d312e336120202020200c2c475545371dd6b8de50fc574f2afbfa8170eb832c797a905443fd503f5057103cda1fa8cd0b6f267ac3b9d36e4f888bdc3960db70d8cfb54c16090fd0c1e920afdb48a6edd355d1e489d229dcd1fb1927b242bf49a8fb719b96325437fd28bb6978d05b76f80af0dfbdeba49c461559e7b661836b7e8773fb30951bccdb1618d23b7049dcf6b546a64477f640d0c9db600fb3ece5589766d8af7f9dd799d04330af8940e9abf51733197828bc54953bcc13eeef8219b040cf8164af7ea5b7eb2f58ad8707ad19cb3dee9d94fccb45a0c31ecff073dbdf3d79382bc5a4c4ca4792433d971cd82313a3f05a40e03398e7f8c53f38269c8f94e3442b67c601bccc4171227f12b30e34f28bbfdcb8d8a0d9bddd1f6f94cc3de8defd4f71dcdb0f08cb5071c35348659a0ba618a451f0295dafeb17381def1f40976321439ec494"
      },
      {
        "other": "0x6772696432642d312e33612020202020bb9933500cb86bb0ef7a15c230fc5b19263506d2e600cba3966400c1dc4b7c4704a075abed4aa1fc4a1bdd0ade764f81355a3966635e4ff82793cbb78db29fc5de174172e1d667758f4f491405267aa2936de31b9def10037d1c0fd5fb995f85fad46d34ae18112a1b722ff6ee8ac1b4faccd01a55260f5b072bcf4a1cd733d4e54beb6da7b507550160450d232376fc9150895b5f56b2671c5b01bfa86f4e336bfb76eb13c49054282490885ecb8ae8382758bcb37e4ea27dfdf68daa0fc4487510d6be24bcd50a49583accf432832ad40ff9f66a1ba15e48efaf71b6ca05c17cb692f89d9aca9ae05ed3e2bb92ebca041146a3daee27279a607c5cf7fbad97e311dd8cbb94af45da7f9f15015a8b09edb0f8b84a5e1282646ce489bdb9db8f044fc49a3d6901e4d8bd3df3ef06c1d4a68b6cb0438231e2b1964b7fa4da59cd"
      },
      {
        "other": "0x6c7a7373b7c2a1576904c25d307ec72096bf409c3f777ec8fc12633998cd26b3300c5379bcda6e0690055cde6939984c40e482819ccde67339c0305994e263309b83cb06c1379c4d26cfc1669389ccd41d9cda69329b4e26a194a71389988700dc409ca640b802a805bb9904d012c13511ac1dc26e20004d60590990c2015ab319a87501ae016f269309b0ea019ad3816e33907980e008080ec81281320769342140461083806a00d6043580c809802329321fc04fc098988a09bce48630b4f2ba231cc96b094f2ce42a1cba8cd40b84d8be714009b4c066194712d6220403d1cd49401c3026281d80a58030f043012a6667100f2005a30fc1392da06f0c1554cd0201ec0378853007a821c0224472c00b02114991cc03c403652602240e081f433ca07ec0e8a9cb19c15b4482d3445a28940b831ef04b206711303a7900d02435d0281cd04f785dc1440a8e599a0f05180a9014e51ac0294093515914d96109c6357ee7ac075828a059deb7d4f41aea155bebfa5641a6d652becf85545a7533b88d0a144b9b523b61343cc6d700ec035c46b2048410c8230561207b813d1b90035c03e12647681d201f0638a01fc1b39af604042968ccd04e5dd81b05496041c51d9ba206b40e64103f257070a0f0c1ef4baa179a1377980ec957c81ec17fd6f104a62bca299b9a103b60dc0748acd632e00601c7003cc0c00764427a80b00b401b002e5acc079e08ac037a88b039c1380b78e3000d008a011ed3916e01e404e1a3900da02ec0a3908c005802bd49b80aa00ac0f7b064826c001c023fc7040a9b7780db81e800fd31840dbc48f185906b60f44c2993f8021602ed186813a01f88c6807b8830f204e12600af96830554fe3c39980d80ee04ec493992d077401691f651c4131e0e1cd34811b178e0ed89d61193569607640df5380265a06459cc024923fd63b00ee01390264d3634a085c10ed88d03340538187b0f810d608770f284dc8c00cf64ae1363360976c9d097d065ec9e80fc829a04fb649410603b04529e71d1555a77f5be4a2e92c01e701d40d1d16c015d433804889187ae284950857d949a2a83eded24d05d3af098adc06bfac1c1af02f046982bb01bd833f31960bec09ea1cda74e0e385d49ba452124cec1ae01d3576403585e05b1007360cf819a2ccdb7807a47c6ec700c703f047564e440ed89a945b60060004101900440c499de0144032004515e7839f04d04fb41173b7a07b81351b66009cbd09ba02a46d2c8d3819c507601680f182a720160d74438b3f902e02e83026084e0060c163c94986d95dc0ae456e98c3834c2e68408bb2e17fb440840681a4015a0fcbc72c00c77aea4835f61cc9da7946779b43c408d80de41de0e744e47a6d12760f78c3c897c02800c0486d004b026aa4700d7018a434cc2600d88082022aae1048e81c0b15a29ac0aa19e022cc0e754f1c02b03a200c1c7801f9075288118a9021a03ba0ac1cec80cf043f63401870193412a4270123124032a613647c0ce0cc30010639e05a00fed96222fe09b81b99a36643d4328926d21934fda8b2c7d825b03b407d5272b180df993109897302a8a5f413e001c458a0ac004e24e44d00ef1369eb19ce69b7365bc0c48180a2e7004623591c28934507807b81850a41931fe6800d1fb16b385e74ecf0f9f2c403ead19e603d851f82ba019c92d116b808cb120fa72c0352a36c19728af5368a8bd59b95101780d84d0e83b803406d441d58093079de1eddf3c3b4f1806f25dcb7b2cf5ba2bc007a988809a341320624682705d58b800b532caadb309c84cc48813b226ce5be8438cd662dfc8aa3806025c03bc06528f302da09a0c49095d025446642705c816ab8e502d406348ba817604506bf85a4808a634e06a804b117272bc001c092a08122d4253d0a700fa03d24344442084a61e006f00e5580003e204c00fe7a0d443e2856d9f816c06f808a2cfb8017068e0fb5cd909e934ca08901601ad215e2267dcdc825904916448062026605ecc9d80d99a8b83700a540bfb169354d85ecc74294be4be457a66c7e446281f3460e044cca0523903de1366094b845110126546e2c98181dcd95184d4342185265e0ae01a0519b124629ed8d80b5806bd4a1059f02f734be69b41331b6184ee04141c7335c03760c7c1ce52d5038a0cc903719c716f960241a680b1079bef7911913e7a76bc0405e3d81405d003f059c14d590001805a06a604deb377e5624e29dab7a7136d6ece3c211b4d9638625b1971cdc74b089008e033086981d7161ba64446d80b521b0033c13701ac41640ae566695446300d5a21a021c05430a60310066808890ed056c24bc94188d00098c9181f0211475fc012427250187f814c054a6545c9d84d01a823a62f60e60043016da05404380bd017f6252024848d1120018e016080409b102fccb0c0cc81a9331ea00c8dd030202fde7360cc5967e38245ea8a470a122b6e75453781b0022128d089f80400190a42f8f0911e926602cc0620268b4080994121825c552e07e806a11b205d22724870d24704f20a8015351c520e401b154084dc8002c4a0e8485c11ea902051803ec972b8bb07320a9010eb1f705fc131601736992a21624ab4026ac6c104932285a60cac4feb08815e2055c9a202d2067a4d3001f03190058e0581a5835d36740fdcda1025a06d20dbd9b00a63067d0c58960032c171cce0c197835c273d0d5c07c82f2466bef0cda55b19e7ca4cb1d7c7804361aeb6bdd89aef2532caff5e91ad2805200540240058206c0ee403b12b2a01608e85fd187b74ca214c044aa1a11e26261d511008014e889000503ca06f843081ad206904482fb5c6e88ad01675327ec0378471b4e5e6037701e162c409b038d634c205c01c18b777d00ea8062186232182f68c4cba6417992527083115ab253a60c89dd109e78a44709b730eae36c43f5c649072001207331e4036c5157e654c60488fe346628c588ba433452276c52320837b7252747e1314c2e94f4ec84e46781ab04e628dc11b04d0f50273f2cc05e403018540592c33466aa718c3016713160aacc1982a50542471c024a25e358e33959286a011b0ad4254c3342fc4b800e1980815108380158011739caf7045a0bf580a04e0ec8b0b452029448de0331050a0c79d8c818705246b381881220403003889a11b2905080da0144ab090356466c15c00e136c7edd0d81137c267ded3dd0a1b5ca64dee1899d5b05f7bc4c661717af300004be2161783635af6a93de512b8a7e200a01c6a18a075c0124149fbda1998d700f2601c0b503353714217c046accd1383951134606c143816b207c137144077881698ab050c02650cd03c106ac4dfc013806607cee200009a85e1078028c83f88be04764e1108b00e90186036cc4f82060188449026c0c4087310001fe0eac08e1a2e02320410854011919c92f62120528064807942740514c7580f502580543cb0b06332db44df05481973297645bcbb112a263ae3d7cf3090891a5e814c73c8b2503e62f94e710c8a129ee19455ba4e040601dd1e00cd5e68083f7c605f01cba4dd2b8060024a4a3c0ef8a19646a07500f1a394103a0ec01410cdd5c03d903f2c9bc1338230334c098c5bb922d017009695cd2a6505948ac4513028c23c4075614c123605d66930040130e1508000c086bb09038202e116b820a075e21c49678313063eccf45d58a6946920a901609331066a0cffda83bbc36bb4c9fd19133bb60deed098d5ae5f5166be9d612187459cae48d6cbaa255926ab95c412b8a509e6b0d4ccce0df03c509a021376e0f3c26a9cfe6e1540c7085939a81e07f4003891c805303f0c1fc04403e4070e801c1691a4f04dc017c046abd10066067d0548056016c01409230373178ee0f05c600ba442e220c9dc036c1325222c00aa09411800cd8a6efc405383c671ee022407c80fc348a0404051905d11c206d1c14012c009401650d808da0164452c1d1c138f4a6453097eb917f0b484b647b795622144651c6afa4931d4e2cbd02a8c97125eef10545074f3ce42228f7022d04180664dbb04d91b8063f4720dfc5fa9986098a02110840941c609fa649c0990124227a049e09cc813801c02e2a77851b01f603ca688c1228905244813406a13336ee8641238252355c0b1418a1aaf030c2af1e666d4019026945b80b441548262107e28140b9bae7033a2bb0ce681f4014669340a74aea05602b28d220af405264a9058f01b67651eb3099e5b07f6d04c6c8b93ae6f3e24bead62fb4625b30a8bdb81ab79504a8c4d4729ae25314993d199278a71c0fd4117002227bc080c5fb1a57c4600e3c41c9b4d06dc030c9f9839907460fa9a705b8503181e049c2bd4cc4821803f2c5f01e903f1008667b002082b330c400a415e4a0e042c0269044802800607310ac13715ac074061802700f48e901130b47215203600a8b89703ee0165472028816fa23040f200ee70ae21d006da10d10f0224887d811b0221e4859eb912c26c4e3df44c990a3990cef1becd18c75d0b5f31c43260497bdf415101cbdce2088a0a8494002d497a20d04131819a83b708be158c2e79dac0f9e6e704e7997d17be5d746f7953d1ffe4c74907af8f287eb67d75216c65eeeb038c77aa0c39e86d3d7711caf4b7e7b7cff4a0af436ee981b603a820080f3c1fc8232f78c0d341f414cdb1001900225346cc009019c23c1101a00880041837001c00c0a6e89826534736f3474a0f9402e9336000c0a38c2b0bf006f70018427906901000e9cc35002b00c401e19c30336104e6258045826f31080db418bbbd000061360dc53344a0f68177180c0096135630efe45f6800931582214c4a80d60670e38399810f3b181c47886994d84c78a957a642cec40731d3128e17bcb91873807ead9c8252b3e20a844e50107bf2306b470c0c6012d03404f601eb8011f760065816699a3071826a08c203c309915a4412273c4ac821e22cc0e141081121034a07b80be33570358062091a81e6048407809dd034407b685809a081ac148c67340d39aac14080de9c920a4c048a48845258126225807b01460119774608d8142997813de07a5135833883cc33551c4ac815502cc047a671046bbac0e2204b4ed5072fe15658a00d131a8a45ba4a4ed30715224e708fbda91a53843fe47511aca02e3a64856a6ce381a7824e26f20cd81f601f2e28a0e401e183c9271e05584e4914d05c62f6d5a704d9b38388236e2eb817299b605c00deda62f381e3836827600f0c5f39bc600582cedd91815807e040a40068a6e27d60dbc001031a77ec33145e6d5803100ce37c4079442c313610e800b91bb01c607fc40a457bc862101c6de44d2004520c8071444bf8a8617a22cb04073b32127618385e9073b081ccc8829c01e476c009a099903387fea09480528de20294f8b87f93f5b1ee0e8c127194400d88f56c7704c18581a8330c339290469c012015a732e1312da06c48d68156039c0580cbc83b70278c760093824e433013840a45145a7091b735e0c9510681cd0386083c9108a340430d3248008500f79209039813825048300b208f984980d99270530121822e23aa090c58cba33071e2994d310a6d342c088012a8278f512a340949da60e32669d2920729d24a768838b9923383fdec48d09c1dff5e267d28e172df23ab408c593034829c92d111a66d6c9284e1818b892584263c1479b2709ab9a65f20db0264c209d5833707460e7c9b209b00774b307882c1ce72d341c7010727c40e9417602fb77980f2c1c41cd5e1037707de45c01b60bf8698bce07060f951c789d030140b60266061c09831607224f2800510af365e000c16d3b77134e6e3040201b13248266942ef95130e581038681854a041c1f4819d800e1a4404e1ef78f237e70effd6f23d59745cac0ddb38e022c87209896367271662d412f97af0099181014c13330c03684bf298a2904d0cc04d0c7399c2904d4d5035b1344a6b8a413637804ec4da29c02904dce7011b138ca748a41383c00c6c4ec29e42904e4f902d913d4a7d88fe84c0ff897b8410885810912b81420c87cd1601851674489991a9a42032e292811d424b34b006a4530025084c269b80dd8af924d0c9dcd4201cd151809f2146998435244614c5a029d13c4051015889e7456e665915132c73580a28416d89f945c266a10c532f135d4a4dc1668a0d361486e90ce331b3628a55c1978a23366887310d73345367ca4d81ac8aa546be67790e0336f36d0a3141c18af9371087c10e933993724a4b81d68b23376488090f233c33778a3541eb8b4d37b888598fb3bee47cca39c0028b77301488b1d04c01c4028b3273c20e8008183b3484e87e0262044524e01945e5986a44b0e8d603e207451ec02545fb989a44dce92e05620a459982311940b40c659a8474c3037106a2ccc2988fa01a063ecd4d327692188411958191835608aa9146c13549993b12a2054017b10b732b08b61c95c2c152c69331c626200af19893604cada4cd219259991313700638cdc9b2c65c107254e12ccca089e8037c67a4dab3b0b83f487c96665c450c01ee34326e01d9ac22a4444b33342292010f1a493754ed7e12d22525999d114f00938d3c9bd477130a291412cd1008aa805f46aa4c013bb385748ac96688c456c02ae35b260c9deec2ea45c4b344c22c2016f1b0930c4e02e18d231259a29116700c38d9c989270770d291a12cd1608b68067c6da4c61306a96f48dc9668bc45cc036e373263c984d43a95744b346422f201cf1bc93244c32a5ed23d262a46f98ca9214a61f7000d2680284108020070220a01e718293300efe601d203259a3b110b000b8c2c99b072b301a90312cd5f0888800ec42210f039898134824966a04445c008e31726841cdcc0ca4184b3508223a005f18e93480e7a607d20f259a871123003b8c8c9a70743304a90912cd4508948023c6524d50324892b4854966a3444bc014e32f26b4193c41895304b3520226a00bf19a93600eaa60dd21b259a93113b006b8cec9b3075b307a90f12cd4b08a0803bc6824db03b098434884966a64451c020e34726e41d9cc24a4484b3638229a012b12684780eda613d227259b1f1153009b8d4c9bf067312aa91513022356c608900d33c985a69365b42bc4178025115f00a78d7c985075930c291812cd9408b2805fc6ca4c40302896748cc966cac45ac032e36b262c182c436956c4b365c22e201af1b8931c0e2261cd239259b31117700e38ddc991071730f291e12cd9a08be8077c6fa4ca038e987f48fc966cdc440c03ee303265c1c8cc02a4044b37742212001b10484340e52602d205259bbd110f00138c3c99d072f302290412cdc0088a800fc62a4d0039a9817482c966e0c446c00ae31b268c1cecc0ea41c4b370c2242006f190934c0c82248d211259b89112700438c9c9a90647105254a12cdc608968027c65a4d60326892f485c9979198635e48ba994cc1a349b9aa1382070009089c802dc6724d90399983b4874966e5444fc01ce33f26d41d7cc20a4404b3830228a010b12284700eca611d223259c1b114b008b8d2c9bb076b309a91312ce0f08a8804bc6a24df03b8985348a4967084455c028e35726041ddcc2ca4584b384822ba015f1ae93080cfa257d22f259c27116300bb8d8c987060310ca55912ce1508b48063c6d24c50384986b48d49670b445bc034e36f26341c3cc38a4704b386022ea01bf1ba93200e2a61dd23b259c33117b00eb8dec993071b30fa91f12ce5b0880807ec40210b0390980348049672e4441c000e3072664189c484a4084c708c2b19c24374c5a6039a4e43d089101200fc444c003e313267c1c34c0aa4144b39042232004f18c93440c72246d20d259c85111f00338c7c9a5063f104254812ce440892801fc64a4d403a29827484c96722c44ac012e32b26ac1d2cc16a42c4b391c226200af198935c0ea260cd219259c91113700638cdc9b10757307290e12cc6605044f409d623d0cd01d74c1fe43e8e8680b88a1e13e088811b83b19846888a9d2801a114a8289912b23a0769309a91303a8603a22a2852e228c47a0ede61502296757808145600a92458480019d44ad64598ebc811d8af615908be101833d88616ac09d94027116582bf9197206060112d0919c4092369c6249045303986da8d781ba0b8b17142b745ca0b34472c8301db1c3aa4740ef181898bca17388f31078389987c08f59e62ff01fd080107a4600549038c9802c8031c19024d2076002101c215071f301310213869050641b401f206e4300e4a60412078713c0ae48518074414886c1cacc0b8415ce35017790d9015483690f0318893c4a3958850325221e038108822148371085608dbcc5ad9149022c852912551eaa2bec555e62e348c28150430c8a02910519b6322f3178647040c621c2456d495a8ebb1cd798bf923fa07210ff22eca519484d904bcc8b41239044468e559152c2a49ec915e6469093a824044ec8d6217b628b65030e3514d238d5708ecba9c6b4c8f012e205c02870975827c45d88f02959530165eef324b04c9c179232847ed2e56d9eb33379929426c60cb91b2202c97974de1db7bcc967139f06d48e810315002a76aceade64c289ed83a647b8826281c53f167cef3268c405c1f12018419d41ba816b02379938220a6007902a2104a14941a582fbccddf108f00f0623d49f50daa14ac26de66fe88658096419885ea88850e161aef3306c441c0692108436d452a88eb113799872228604390a221f2a30d45658a7bccc57117f0294860111749c1b32ac62de663a88dd8186437889aa4fed1d0738ef3324c47dc0e121f8454d28e6d06b20385c68871171b2d984ed4901a669249330264133c49bc0ff2270463948d2942b27b7999da255609d91562358a5d94b0595bbcd10b12e705a06b9d5ca5328a5facbcde6894899182ee46488f429b25339665ef3451c4d7c195236040194e829bab36b79a2ca27360d991ce2048a7b94ec59d3bcd18313d707448f610424817b7dacf8de68d0880983de40288302429d028703ef346fc413c00d205041f94242832b05b79a3ba211601590462138a199428584bbcd1fb10c7012483210ba5108a1bac34de680c888180ce420886c28a25119621ef350dc44fc094193f53d946028aab14b79a8aa22f605190be2228937766458c3c2674340899d92ec1f8a388d3539a47a80f4092223e606090fa22a0a37148258ffbcd4af122f03f488c116e4a6fb48ac8ede6a668935823644d88c62555d28074eef353ac4a9c13922a846a94ba295eb2b379aa1225c60ab91722390a6494be5977bcd527131f05d48c811e65360a66accade6aa289ad832646b880229ce537166cef3658c4e5c1c01b9750894f629d6b3a379b30227a60e791ea2080a0294fa59efbcd99f100f07b4804105e5050a04ac06de6cde88258016409883e2846506160aef3676c421c02920884269231ec4eb09379b3f221860239062217092074361c67bcd81710ff019484010d6493fb22ac42e0f5a12443d6c7860be514869b15122dc05b04531177020c85e1112513ca31ac60de6c3888d9817e436889828fa51c9637ef3723c47bc0ec19ef553948c2902b1fb79b95a245607d911622d8a4d9490591bbcdccb1267046489a118a52a8a4fac9cde6e748951826e45488d4297252b9655ef3741c4b7c15522e047192c7ed7ab2eb79ba4a26360b9918e23c896b74cc1d93bcdd43135706448d610025398a6dacd8de6eb089c9835e472881029ea53a9673ef375fc4f3c1cd23d040f940429f2b3db79bb3a20160f5900620b8a099408580bbce1bb10470060611d47a5088a0bac14de70ec8841804e410884c2461d899611f05bd054216f62cb040267035487481a8a18123a60f3b177a20ee889cd9d12584bee7c24a1c29b7459258616bba6892ff0c4dd52499d869eeb824ddc38b763927661e3bb5893ef000ddca4a15807ecf3e919b87a7017494605bb047b210e331841b80"
      }
    ]
  },
  "eventsCount": 344,
  "extrinsicsCount": 5,
  "isFinalized": true
}

Parameters:

  • "height" – the block height
  • "hash" – the block hash
  • "time" – the block time
  • "validator" – deprecated field, always null. There's no validator in the block header taking place in LoT.
  • "parentHash" – the parent block hash
  • "stateRoot" - the block state root hash
  • "extrinsicsRoot" - the extrinsics root hash
  • "digest" - the PoW component digest containing the consesnsus logs:
    • "logs":
      • "preRuntime" - block author's public key
      • "seal" - the seal encoded data containing the RandomX(Grid2d μ = x) hash (sealed with the block difficulty)
      • "other" - Grid2d (μ = 0) hashid (encoded data)
      • "other" - proof of context historic hash encoded (encoded data)
      • "other" – Nonce (encoded 3D model of the object in the content of .obj file format)
  • "eventsCount" - total number of events emitted by all the modules
  • "extrinsicsCount" - total number of extrinsics in the block
  • "isFinalized" - GRANDPA blockchain finalization status from the PoA component (the blocks are being finalized by the validator set/masternodes).

Explore the Proof of Scan protocol description for better understanding of the block components.

5. Difficulty extraction

  • The difficulty is always in the first 4 bytes (8 hex chars) of the seal's second element, little-endian encoded.

Example:

async function fetchCurrentDifficulty(API_BASE) {
  // 1. Get latest finalized block height
  const overview = await fetch(`${API_BASE}/overview`).then(res => res.json());
  const { finalizedHeight } = overview;

  // 2. Fetch the block data
  const blockRes = await fetch(`${API_BASE}/blocks/${finalizedHeight}`).then(res => res.json());

  // 3. Extract and decode difficulty
  const sealLog = blockRes?.digest?.logs?.find(log => log.seal);
  const seal = sealLog?.seal;
  if (seal && seal.length > 1) {
    const sealHex = seal[1].replace(/^0x/, '');
    const difficultyHexLE = sealHex.slice(0, 8);
    const bytes = difficultyHexLE.match(/../g);
    if (bytes) {
      const diff = parseInt(bytes.reverse().join(''), 16);
      return diff;
    }
  }
  throw new Error('Difficulty not found in block');
}

Notes:

  • The API endpoint is defined by your config, e.g., API_BASE.
const config = {
const API_BASE: 'https://api.3dpscan.xyz', // Explorer REST API Link
};

About

The Ledger of Things open source blockchain explorer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.8%
  • Other 0.2%