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
andminCount
- the
calldata
(request parameters) associated with the request
For more information on each these, please refer to our wiki.
The library is available on PyPI
pip install pyband
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
: 1calldata
: The hex string representing OBI-encoded value of{symbol:BTC,multiplier:1000000}
minCount
: 4askCount
: 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()