Skip to content

Commit

Permalink
added scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
brendaloya committed Jun 10, 2021
1 parent 3c7aa36 commit 5fa6b61
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/03_add58tips.js
Expand Up @@ -122,7 +122,7 @@ async function add58tips(masterAdd, net ) {
for (var i = 1; i < 58; i++) {
try {
var gasP1 = await fetchGasPrice()
let tx = await contractWithSigner.addTip(i, 1, { from: pubAddr, gasLimit: gas_limit, gasPrice: gasP1 });
let tx = await contractWithSigner.addTip(i, i, { from: pubAddr, gasLimit: gas_limit, gasPrice: gasP1 });
var link = "".concat(etherscanUrl, '/tx/', tx.hash)
var ownerlink = "".concat(etherscanUrl, '/address/', tellorMasterAddress)
console.log('Yes, a tip was sent for request id ', i)
Expand Down
92 changes: 92 additions & 0 deletions scripts/06_readrequestQ.js
@@ -0,0 +1,92 @@
//npx hardhat run --network rinkeby scripts/06_readrequestQ.js
/*******************************************************************/

/**********Read requestQ**************************************/

/******************************************************************/
require('dotenv').config()
const helpers = require("./helpers/helpers");
const ethers = require('ethers');
const fetch = require('node-fetch-polyfill')
const path = require("path")
const loadJsonFile = require('load-json-file')
const TellorMaster = artifacts.require("./TellorGetters.sol");
var tellorMAbi = TellorMaster.abi;

//Rinkeby
tellorMaster = '0x88dF592F8eb5D7Bd38bFeF7dEb0fBc02cf3778a0'
netw = "mainnet"


var _UTCtime = new Date().toISOString().replace(/T/, ' ').replace(/\..+/, '')
var gas_limit = 100000

console.log(_UTCtime)
console.log('https://www.etherchain.org/api/gasPriceOracle')


async function readreqids(masterAdd,net ) {
try {
if (net == "mainnet") {
var network = "mainnet"
var etherscanUrl = "https://etherscan.io"
} else if (net == "rinkeby") {
var network = "rinkeby"
var etherscanUrl = "https://rinkeby.etherscan.io"
} else {
console.log( "network not defined")
}

var infuraKey = process.env.WEB3_INFURA_PROJECT_ID
var tellorMasterAddress = masterAdd
var pubAddr = process.env.MIGRATE_PUB
var privKey = process.env.MIGRATE_PK
console.log("infuraKey", infuraKey)
console.log("Tellor Address: ", tellorMasterAddress)
console.log("nework", network)

} catch (error) {
console.error(error)
console.log("network error or environment not defined")
process.exit(1)
}


//Get wallet and network ready
try {
var provider = ethers.getDefaultProvider(network, infuraKey);
let wallet = new ethers.Wallet(privKey, provider);
let contract = new ethers.Contract(tellorMasterAddress, tellorMAbi, provider);
var contractWithSigner = contract.connect(wallet);

} catch (error) {
console.error(error)
console.log("oracle not instantiated")
process.exit(1)
}

try {
//Read data

var vars1 = await contractWithSigner.getRequestQ();
for(i=0;i<=51;i++){
//console.log('Request ', i, ': ', vars1[i]*1 )
var vars2 = await contractWithSigner.getRequestIdByRequestQIndex(i);
console.log('Request ID by index ', i, ': ', vars2*1, "tip: ", vars1[i]*1 )
}


} catch (error) {
console.error(error)
process.exit(1)
}
process.exit()
}

readreqids(tellorMaster, netw)
.then(() => process.exit(0))
.catch(error => {
console.error(error);
process.exit(1);
}
);

0 comments on commit 5fa6b61

Please sign in to comment.