Skip to main content

Python library for BandChain

Project description

PyBand

BandChain Python Library

⭐️ Features

This helper library allows users to request the latest request result that match scertain input parameters. The parameters that can be specified are:

  • The oracleScriptID
  • the askCount and minCount
  • the calldata (request parameters) associated with the request

For more information on each these, please refer to our wiki.

📦 Installation

The library is available on PyPI

pip install pyband

💎 Example Usage

The example code below shows how the library can be used to get the result of the latest request for the price of Bitcoin. The specified parameters are

  • oracleScriptID: 1
  • calldata: The hex string representing OBI-encoded value of {symbol:BTC,multiplier:1000000}
  • minCount: 4
  • askCount: 4
from pyband import Client, PyObi


def main():
    c = Client("http://guanyu-devnet.bandchain.org/rest")
    req_info = c.get_latest_request(1, bytes.fromhex("0000000342544300000000000f4240"), 4, 4)
    oracle_script = c.get_oracle_script(1)
    obi = PyObi(oracle_script.schema)
    print(obi.decode_output(req_info.result.ResponsePacketData.result))


if __name__ == "__main__":
    main()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyband-0.1.0.tar.gz (12.3 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page