const BandChain = require('@bandprotocol/bandchain.js');
const { Obi } = require('@bandprotocol/obi.js');//BandChain POA mainnet endpoint URL
//const endpoint = 'http://poa-api.bandchain.org';
//BandChain dev-net endpoint URL
const endpoint = 'http://guanyu-devnet.bandchain.org/rest';const getBTCPrice = async () => {
// Instantiating BandChain with REST endpoint
const bandchain = new BandChain(endpoint);// Create an instance of OracleScript with the script ID
const oracleScript = await bandchain.getOracleScript(76);// Create a new request, which will block until the tx is confirmed
'panther winner rain empower olympic attract find satoshi meadow panda job ten urge warfare piece walnut help jump usage vicious neither shallow mule laundry';
const requestId = await bandchain.submitRequestTx(
// Get final result (blocking until the reports & aggregations are finished)
const finalResult = await bandchain.getRequestResult(requestId);
let result = new Obi(oracleScript.schema).decodeOutput(
Buffer.from(finalResult.response_packet_data.result, 'base64')
console.log('RequestID: ' + requestId);
console.error('Data request failed');