{"size": 1628, "ext": "js", "max_stars_repo_path": "API_AccessRequest/Oracle.js", "max_stars_repo_name": "XinFinOrg/XinFin-ChainLink", "max_stars_repo_stars_event_min_datetime": "2021-11-11T04:11:23.000Z", "max_stars_repo_stars_event_max_datetime": "2021-11-11T04:11:23.000Z", "max_issues_repo_path": "API_AccessRequest/Oracle.js", "max_issues_repo_name": "XinFinOrg/XinFin-ChainLink", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "API_AccessRequest/Oracle.js", "max_forks_repo_name": "XinFinOrg/XinFin-ChainLink", "max_forks_repo_forks_event_min_datetime": "2021-06-06T04:31:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T14:48:10.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 32.56, "max_line_length": 90, "alphanum_fraction": 0.7389434889}
/* eslint-disable */
const Xdc3 = require("xdc3");
require("dotenv").config();

console.log("testing", process.env.PRIVATE_KEY)
async function main() {
  const xdc3 = new Xdc3(
    new Xdc3.providers.HttpProvider("https://rpc.apothem.network")
  );

  const deployed_private_key = process.env.PRIVATE_KEY;

  //Oracle ABI & Contract address to pass here
  const oracleABI = require("./ABI/OracleAbi.json");
  const oraclecontractAddr = process.env.ORACLE_CONTRACT;

  //Chainlink Node Account Address can be fetched from GUI - http://localhost:6688
  const chinlinknode = process.env.ACCOUNT_ADDRESS;

  //Defining OracleContract
  const oraclecontract = new xdc3.eth.Contract(oracleABI, oraclecontractAddr);
  console.log("orclecontract", oraclecontract)
  const account = xdc3.eth.accounts.privateKeyToAccount(deployed_private_key);
  const nonce = await xdc3.eth.getTransactionCount(account.address);
  const gasPrice = await xdc3.eth.getGasPrice();
  const tx = {
    nonce: nonce,
    data: oraclecontract.methods.setFulfillmentPermission(chinlinknode, true).encodeABI(),
    gasPrice: gasPrice,
    to: process.env.ORACLE_CONTRACT,   // Oracle contract address
    from: account.address,
  };

  const gasLimit = await xdc3.eth.estimateGas(tx);
  tx["gasLimit"] = gasLimit;

  const signed = await xdc3.eth.accounts.signTransaction(
    tx,
    deployed_private_key
  );
  xdc3.eth
    .sendSignedTransaction(signed.rawTransaction)
    .once("receipt", console.log);

  let status = await oraclecontract.methods.getAuthorizationStatus(chinlinknode)
  console.log("Status", status);
}

main().catch(e => console.error(e));
