📈
Everipedia
  • Home
  • Everipedia API
    • Everipedia.org REST API
  • Everipedia OraQles
    • About
    • Data Partners
      • Associated Press
  • Current OraQles Projects
    • January 5th, 2021 Senate Runoff
      • Ethers.js tutorial
      • Solidity Tutorial
  • Past OraQles Projects
    • 2020 US Presidential Election
      • 2020 US Presidential Election - Ethereum
        • Fetch election calls with Solidity
        • Fetch election calls with web3
        • Mainnet Oracle Data
        • Kovan Testnet Oracle Data
      • 2020 US Presidential Election - EOS
Powered by GitBook
On this page
  • 🚀 Want a shortcut? 🚀
  • Walkthrough

Was this helpful?

  1. Current OraQles Projects
  2. January 5th, 2021 Senate Runoff

Ethers.js tutorial

PreviousJanuary 5th, 2021 Senate RunoffNextSolidity Tutorial

Last updated 4 years ago

Was this helpful?

🚀 Want a shortcut? 🚀

.

Walkthrough

  1. npm install oraqle-contracts ethers

  2. Use the following JavaScript code to request results from either oraqle.

const ethers = require("ethers");
const addresses = {
  kovan: "0x0792724900B551d200D954a5Ed709d9514d73A9F",
  mainnet: "0x3E961f9A77146F6230709D767d60025f1Ed3Bfef",
};
const positions = ["U.S. Senate Class II", "U.S. Senate Class III"];
const abi = require("oraqle-contracts/artifacts/contracts/associated-press/Jan2021SenateRunoffs.sol/Jan2021SenateRunoffs.json")
  .abi;
  
const checker = async (network: "kovan" | "mainnet") => {
  let provider = ethers.getDefaultProvider(network);
  const contractAddress = addresses[network];

  const contract = new ethers.Contract(contractAddress, abi, provider);

  const lastNames = await Promise.all(
    positions.map((position) => contract.winners(position))
  );

  return lastNames;
};

  

3. Still having issues?

Tweet to and any engineering questions (or send a DM on Twitter to )

Start with our example code on GitHub
Refer to our example repo
@dawsonbotsford
@everipedia
@dawsonbotsford