Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Latest commit

 

History

History

pyband

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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()