Giter Club home page Giter Club logo

chainql's Introduction

chainql

Query Substrate blockchains using Jsonnet.

ChainQL is a utility for representing chain data in a JSON format and using Jsonnet to process and manipulate the output. It is supposed to be a more convenient alternative to querying the chain data with PolkadotJS.

Install

With Rust installed, run

cargo install chainql

to install ChainQL globally.

If you want to install and launch it locally, clone the repository and, in the repository, run

cargo build --release

./target/release/chainql

Usage

To see all options, run

chainql --help

ChainQL operates on a .jsonnet file. With option -e, it can treat input as jsonnet code and evaluate it directly from the command line.

To supply a jsonnet function with arguments, use options from the top level arguments section of the help message, such as --tla-str=${your arg name here}=${your arg value} for a string, or --tla-code=${arg name}=${your code} for jsonnet code to be evaluated and the result passed as the value. Both strings and code can be supplied from files and environment (see standard library section of the help message), as well.

Inside the code, you can call cql.${method name from the ones defined below} for any built-in utility method defined in the ChainQL Rust code itself. These currently are:

cql.chain(/* chain url to get the data from */)
cql.dump(/* chain metadata, dump data, optional parameters, to create a jsonnet representation of a mock chain storage */)
cql.toHex(/* array of bytes to convert to hex string */)
cql.fromHex(/* string to convert to an array of bytes */)
cql.calc(/* array of tokens to evaluate in postfix notation */)
cql.ss58(/* address to get the hex representation from */)

Examples

  • chainql -e "(1 + 7) / 3"

    Option -e allows to run some jsonnet code from the input field and prints the result back into the terminal.

  • chainql -e "(import 'parachain-spec.json') {id+: '-local'}" > new-parachain-spec.json

    Applies -local to the value of the field id in the top field of some chain spec file. The resulting file would look something like

    {
        "name": "some-parachain",
        "id": "parachain-id-local",
        // ...
    }

For examples with files and their usage, see the examples folder.

chainql's People

Contributors

certainlach avatar fahrrader avatar mrshiposha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

mrshiposha

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.