📔
Liberland Wiki
  • 📖Public Documents
  • 👍Primers
    • 🙋‍♀️Congress
    • 💂Executive
    • 👨‍⚖️Judiciary
    • 🤴Senate
  • 🚦Regulations
    • ✍️Drafts
      • 👮Internal Regulation of the Security Commission on the Structural and Functional Organization of the
    • 👩‍⚖️In Force
      • 🏰Orders
        • 👨Order of the President of Liberland no. 1/2021, on the Decisions of the Cabinet.
        • 👩Order of the President of Liberland no. 2/2021, on the Interim Legislature
  • ✅Policies
    • 🧑‍⚖️In Force
      • ⚖️Justice
        • 🔏Privacy policy
  • 👨‍💻Blockchain
    • 💫White Paper
    • 👨Tokenomics Primer
    • 💫Roadmap
    • 👨API
      • ⌨️Chain Explorer API
      • For CEXes
    • 🌐Ecosystem
      • 🌉How to Bridge to Ethereum
      • 🌉How to Bridge to Solana
      • How to Bridge to TRON
      • 🔁Liberland Exchange
      • How to Acquire LLD
      • How to Use Polkadot.js
      • How to use SubWallet
      • How to use Talisman
      • Known Issues
    • 🪪For Citizens and E-Residents
      • 🗳️Voting
      • Senate
      • Onboarding
      • Claiming Residency
      • Congress
      • Governance
      • Companies
    • 🖥️For Validators, Nominators & Stakers
      • Run a validator
      • Non-technical run a validator
      • Staking
      • ETH Liquidity Staking
      • SOL Liquidity Staking
      • Update node
      • Resync node
    • For Developers & Testers
      • Build, run & test using source code
      • Run in Docker
      • Manual testing guide
      • Runtime upgrade
      • Rust API docs
      • Bootstrapping new testnet
      • Chain Crash Recovery Procedure
  • Media
    • Press Kit
Powered by GitBook
On this page
  • Overview
  • Endpoints & reference docs
  • Paging
  • Entities
  • assetTransfer
  • merit
  • transfer
  • staking
  • Sample GraphQL queries
  • Fetching LLD transfers of given user
  • Sample raw queries
  • Fetching LLD transfers of a given user
  • Fetching LLD transfers of a given user since block number
  • Fetching LLM transfers of a given user
  • Fetching asset transfers of a given user
  • Fetching staking events of a given user
  1. Blockchain
  2. API

Chain Explorer API

PreviousAPINextEcosystem

Last updated 6 months ago

Overview

Liberland is running a chain indexer & explorer with publicly available GraphQL API. This API allows fetching & filtering historical information about the chain, especially data about past events and extrinsics (transactions).

For interacting with the API, you can use one of many or run raw HTTP queries.

Endpoints & reference docs

API & GraphQL Playground endpoints:

  • Liberland Mainnet: https://archive.mainnet.liberland.org/

  • Bastiat (Liberland Testnet): https://archive.testchain.liberland.org/graphql

Visit the to see up-to-date reference schema and docs.

Paging

Queries can use first param to limit the amount of returned entries and after param to get next page of data. Use hasNextPage and endCursor values of pageInfo entity to populate them. You can also use totalCount value to know total number of entries.

Entities

assetTransfer

All transfers of any -based assets. Includes LLM (which is asset 1), but not LLD. Contains following values:

  • id - unique identifier of this transfer - based on blockNumber and eventIndex

  • fromId - Address of the account that sent the asset

  • toId - Address of the account that received the asset

  • value - Amount of the asset transferred. Subject to decimals config of given asset (so value 1000000000000 for LLM asset means 1 LLM)

  • blockId - Hash of the block containing this transfer

  • blockNumber - Number of the block containing this transfer

  • extrinsicIndex - Index of the extrinsic in the block that caused this transfer. May be null if transfer wasn't done by extrinsic.

  • eventIndex - Index of the transfer event in the block.

  • block - Additional details about the block, including timestamp.

merit

All transfers of the LLM token. Contains following values:

  • id - unique identifier of this transfer - based on blockNumber and eventIndex

  • fromId - Address of the account that sent the asset

  • toId - Address of the account that received the asset

  • value - Amount of the asset transferred. Subject to decimals config of given asset (so value 1000000000000 for LLM asset means 1 LLM)

  • blockId - Hash of the block containing this transfer

  • blockNumber - Number of the block containing this transfer

  • extrinsicIndex - Index of the extrinsic in the block that caused this transfer. May be null if transfer wasn't done by extrinsic.

  • eventIndex - Index of the transfer event in the block.

  • block - Additional details about the block, including timestamp.

transfer

All transfers of the LLD token. Doesn't include actions like staking or transaction fees. Contains following values:

  • id - unique identifier of this transfer - based on blockNumber and eventIndex

  • fromId - Address of the account that sent the asset

  • toId - Address of the account that received the asset

  • value - Amount of the asset transferred. Subject to decimals (so value 1000000000000 for means 1 LLD)

  • blockId - Hash of the block containing this transfer

  • blockNumber - Number of the block containing this transfer

  • extrinsicIndex - Index of the extrinsic in the block that caused this transfer. May be null if transfer wasn't done by extrinsic.

  • eventIndex - Index of the transfer event in the block.

  • block - Additional details about the block, including timestamp.

staking

LLD staking events. Contains following values:

  • id - unique identifier of this staking event - based on blockNumber and eventIndex

  • userId - Address of the account that this event refers to

  • value - Amount of the asset transferred. Subject to decimals (so value 1000000000000 for means 1 LLD)

  • method - Method that triggered this event. Possible values:

    • Bonded - User staked LLD

    • Withdrawn - User unstaked LLD

    • Rewarded - User got rewarded with interest

  • blockId - Hash of the block containing this transfer

  • blockNumber - Number of the block containing this transfer

  • extrinsicIndex - Index of the extrinsic in the block that caused this transfer. May be null if transfer wasn't done by extrinsic.

  • eventIndex - Index of the transfer event in the block.

  • block - Additional details about the block, including timestamp.

Sample GraphQL queries

Fetching LLD transfers of given user

Includes paging, fetches 50 entries per page.

query Transfers($userId: String, $cursor: Cursor) {
  transfers(
    filter: {
      or: [
        { fromId: { equalTo: $userId } },
        { toId: { equalTo: $userId } }
      ],
    },
    after: $cursor,
    first: 50,
    orderBy: BLOCK_NUMBER_DESC
  ) {
    nodes {
      id,
      fromId,
      toId,
      value,
      eventIndex,
      block {
        number
        timestamp
      },
    }
    pageInfo {
      hasNextPage,
      endCursor,
    }
    totalCount
  }
}

Sample raw queries

Fetching LLD transfers of a given user

URL: https://archive.mainnet.liberland.org/ Method: POST

Payload:

{
    "operationName": "Transfers",
    "variables": {
        "userId": "5EYCAe5g8CDuMsTief7QBxfvzDFEfws6ueXTUhsbx5V81nGH"
    },
    "query": "query Transfers($userId: String, $cursor: Cursor) {\n  transfers(\n    filter: {or: [{fromId: {equalTo: $userId}}, {toId: {equalTo: $userId}}]}\n    after: $cursor\n    first: 50\n    orderBy: BLOCK_NUMBER_DESC\n  ) {\n    nodes {\n      id\n      fromId\n      toId\n      value\n      eventIndex\n      block {\n        number\n        timestamp\n      }\n    }\n    pageInfo {\n      hasNextPage\n      endCursor\n    }\n    totalCount\n  }\n}\n"
}

To fetch next page, pass endCursor from previous call as cursor variable.

Fetching LLD transfers of a given user since block number

URL: https://archive.mainnet.liberland.org/ Method: POST

Payload:

{
    "operationName": "Transfers",
    "variables": {
        "userId": "5EYCAe5g8CDuMsTief7QBxfvzDFEfws6ueXTUhsbx5V81nGH",
        "sinceBlockNumber": 1000
    },
    "query": "query Transfers($userId: String, $sinceBlockNumber: BigFloat, $cursor: Cursor) {\n  transfers(\n    filter: {or: [{fromId: {equalTo: $userId}}, {toId: {equalTo: $userId}}], blockNumber: {greaterThan: $sinceBlockNumber}}\n    after: $cursor\n    first: 50\n    orderBy: BLOCK_NUMBER_DESC\n  ) {\n    nodes {\n      id\n      fromId\n      toId\n      value\n      eventIndex\n      block {\n        number\n        timestamp\n      }\n    }\n    pageInfo {\n      hasNextPage\n      endCursor\n    }\n    totalCount\n  }\n}\n"
}

To fetch next page, pass endCursor from previous call as cursor variable.

Fetching LLM transfers of a given user

URL: https://archive.mainnet.liberland.org/ Method: POST

Payload:

{
    "operationName": "Merits",
    "variables": {
        "userId": "5EYCAe5g8CDuMsTief7QBxfvzDFEfws6ueXTUhsbx5V81nGH"
    },
    "query": "query Merits($userId: String, $cursor: Cursor) {\n  merits(\n    filter: {or: [{fromId: {equalTo: $userId}}, {toId: {equalTo: $userId}}]}\n    after: $cursor\n    first: 50\n    orderBy: BLOCK_NUMBER_DESC\n  ) {\n    nodes {\n      id\n      fromId\n      toId\n      value\n      eventIndex\n      block {\n        number\n        timestamp\n      }\n    }\n    pageInfo {\n      hasNextPage\n      endCursor\n    }\n    totalCount\n  }\n}\n"
}

To fetch next page, pass endCursor from previous call as cursor variable.

Fetching asset transfers of a given user

URL: https://archive.mainnet.liberland.org/ Method: POST

Payload:

{
    "operationName": "AssetTransfers",
    "variables": {
        "userId": "5EYCAe5g8CDuMsTief7QBxfvzDFEfws6ueXTUhsbx5V81nGH"
    },
    "query": "query AssetTransfers($userId: String, $cursor: Cursor) {\n  assetTransfers(\n    filter: {or: [{fromId: {equalTo: $userId}}, {toId: {equalTo: $userId}}]}\n    after: $cursor\n    first: 50\n    orderBy: BLOCK_NUMBER_DESC\n  ) {\n    nodes {\n      id\n      asset\n      fromId\n      toId\n      value\n      eventIndex\n      block {\n        number\n        timestamp\n      }\n    }\n    pageInfo {\n      hasNextPage\n      endCursor\n    }\n    totalCount\n  }\n}\n"
}

To fetch next page, pass endCursor from previous call as cursor variable.

Fetching staking events of a given user

URL: https://archive.mainnet.liberland.org/ Method: POST

Payload:

{
    "operationName": "Stakings",
    "variables": {
        "userId": "5EYCAe5g8CDuMsTief7QBxfvzDFEfws6ueXTUhsbx5V81nGH"
    },
    "query": "query Stakings($userId: String, $cursor: Cursor) {\n  stakings(\n    filter: {userId: {equalTo: $userId}}\n    after: $cursor\n    first: 50\n    orderBy: BLOCK_NUMBER_DESC\n  ) {\n    nodes {\n      id\n      userId\n      method\n      value\n      eventIndex\n      block {\n        number\n        timestamp\n      }\n    }\n    pageInfo {\n      hasNextPage\n      endCursor\n    }\n    totalCount\n  }\n}\n"
}

To fetch next page, pass endCursor from previous call as cursor variable.

asset - ID of the asset being transferred. See .

👨‍💻
👨
⌨️
GraphQL clients
Playground
pallet-assets
list of assets on Polkadot.js Apps