# Home

Welcome to Everipedia's Documentation Portal.

## Everipedia Projects&#x20;

### [Everipedia](https://everipedia.org/)&#x20;

### [PredIQt](https://prediqt.com/)&#x20;

### [Everipedia OraQles](https://docs.everipedia.org/everipedia-oraqles/about)&#x20;

###


# Everipedia.org REST API

Everipedia.org has a fully documented REST API available for use.\
\
Learn more and ask any questions at <https://api.everipedia.org/docs/>


# About

Everipedia OraQles is a service that allows for verified first parties to bring real-world information on-chain.

### Background&#x20;

One of the core challenges for blockchain applications is the integration of real world information onto the blockchain. Blockchains and the applications built on top of them can run autonomously, but they're unable to integrate information about real world events. Services that take these events and log them on-chain are known as oracles.&#x20;

The *oracle problem* generally refers to the fact that oracles are central points of failure in decentralized systems. While an application can run trustlessly and autonomously on-chain, it carries risk if it relies on information provided by an oracle. If the oracle is corruptible, the application itself could fail.&#x20;

### Oracle Design&#x20;

This problem has led to a number of experiments in [oracle design](https://academy.binance.com/en/articles/blockchain-oracles-explained). Some developers have attempted to make decentralized oracles that don't rely on information provided by any single party. Examples of this include Augur's resolution system and [Chainlink price feeds](https://chain.link/solutions/defi). While these oracles offer protection against corruption by a single entity, they are often slow to resolve, overly complex, and occasionally unreliable. The process required to reach a decentralized consensus can take so long that it's not actually useful for on-chain applications. And in some cases, such strong guarantees may not be required.&#x20;

Other applications simply rely on centralized oracles provided by developers or community members. These have the advantage of being fast, but they require users to simply trust the price feed without context or guarantees. Often the source of the oracle and its process is opaque, leaving room for potential manipulation.&#x20;

Everipedia OraQles is an attempt to create a new type of on-chain oracle-- what we call *first-party oracles*. These oracles utilize a different process to provide information that is both fast and reliable.&#x20;

### How Everipedia OraQles Work&#x20;

Everipedia OraQles offer the speed of centralized oracles with stronger security guarantees than existing options. We do this by leveraging existing trust, reputation, and social standing from well-known institutions.&#x20;

Certain classes of events don't necessarily require a robust decentralized oracle. For example, users trust institutions like ESPN to properly report sports scores every day. Everipedia OraQles simply allows users to verifiably access information from parties they already know and trust, on-chain.&#x20;

These companies, parties, and institutions have long-built reputations, and they stand to lose that reputation if they were to report false information.  The potential benefit to one of these parties for reporting falsely is so outweighed by the reputational hit they'd take that it creates a strong guarantee for users on-chain that they're getting good info.&#x20;

In certain decentralized systems, information providers must stake capital in order to participate in an oracle. They stand to lose this capital if they provide false information. Everipedia OraQles leverage *social* capital-- in essence, these institutions stake valuable social capital that can be easily lost if they cheat the system.&#x20;

Everipedia OraQles allows users to access information from parties they already know and trust on-chain. It leverages reputation and social capital to provide strong guarantees to users, and it provides information faster and more reliably than other oracle options out there.&#x20;

### Using Everipedia OraQles&#x20;

If you're a developer who'd like to get started using Everipedia OraQles, you can do so here.&#x20;


# Data Partners


# Associated Press

### Associated Press Wallet Addresses&#x20;

* ETH Mainnet:&#x20;
  * [0x436ee8cb3a351893b77f8b57c9772daec3a96445](https://etherscan.io/address/0x436ee8cb3a351893b77f8b57c9772daec3a96445)
* Kovan Testnet:&#x20;
  * [https://kovan.etherscan.io/address/0x436ee8cb3a351893b77f8b57c9772daec3a964](https://kovan.etherscan.io/address/0x436ee8cb3a351893b77f8b57c9772daec3a96445)
* EOS Mainnet: <https://bloks.io/account/associapress>

### Associated Press Verification&#x20;

* Click here to see AP's native documentation with wallet and address verification&#x20;
  * <https://developer.ap.org/ap-elections-api/>

* here's AP's ETH mainnet wallet &#x20;
  * <https://etherscan.io/address/0x436ee8cb3a351893b77f8b57c9772daec3a96445>

* here's AP's Kovan wallet&#x20;
  * <https://kovan.etherscan.io/address/0x436ee8cb3a351893b77f8b57c9772daec3a96445>

* here's the AP website page where they verify that public key&#x20;
  * <https://developer.ap.org/ap-elections-api/>

* click here to see a full list transactions by AP&#x20;
  * <https://etherscan.io/txs?a=0x436ee8cb3a351893b77f8b57c9772daec3a96445>

* EOS account and such&#x20;


# January 5th, 2021 Senate Runoff

## How It Works

The Associated Press is using Everipedia's OraQle software to publish Senate Runoff results on January 5th, 2021. Results are available both on the Kovan testnet and Ethereum mainnet.\
\
This Oracle is similar to the U.S. Presidential election results which were published on November 3rd, 2020.

### [View the Live Dashboard](https://oraqle.everipedia.org/oracles/jan-2021-senate)

![](https://4237340628-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKpcvqHmxdH4lqjGSp7%2F-MPzYQgVh6IgS17cRggC%2F-MPzZ24t4ltZHfoRQnF8%2Fimage.png?alt=media\&token=1360ea84-ff7e-444a-9e88-ea571c4d106b)

### Deployed Addresses

Kovan: <https://kovan.etherscan.io/address/0x0792724900B551d200D954a5Ed709d9514d73A9F>

Mainnet: <https://etherscan.io/address/0x3E961f9A77146F6230709D767d60025f1Ed3Bfef>


# Ethers.js tutorial

### 🚀  Want a shortcut? 🚀&#x20;

[**Start with our example code on GitHub**](https://github.com/EveripediaNetwork/oraqle/blob/master/packages/smart-contracts/scripts/get-winner.js).&#x20;

### Walkthrough&#x20;

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?&#x20;

1. [Refer to our example repo](https://github.com/EveripediaNetwork/oraqle)
2. Tweet to [@dawsonbotsford](https://twitter.com/dawsonbotsford) and [@everipedia](https://twitter.com/Everipedia) any engineering questions (or send a DM on Twitter to [@dawsonbotsford](https://twitter.com/dawsonbotsford))


# Solidity Tutorial

### 🚀  Want a shortcut? 🚀&#x20;

[**Start with our boilerplate Solidity smart contract on GitHub**](https://github.com/EveripediaNetwork/oraqle/blob/master/packages/smart-contract-example-consumers/contracts/associated-press/IsPerdueWinner.sol).&#x20;

### Walkthrough&#x20;

1. Install the contract via npm&#x20;

```
npm install oraqle-contracts
# OR
yarn add oraqle-contracts
```

2\. Set `pragma` and import the senate contract at the top of your smart contract

```
pragma solidity 0.6.11;

import "oraqle-contracts/contracts/associated-press/Jan2021SenateRunoffs.sol";
```

3\. Paste in this example code and change the parts your need! Don't forget to change the deployed contract address for production.

```
contract IsPerdueWinner {
    Jan2021SenateRunoffs internal senateRunoffContract;

    constructor() public {
        senateRunoffContract = Jan2021SenateRunoffs(
            0x0792724900B551d200D954a5Ed709d9514d73A9F
        );
    }

    function isPerdueWinner() public view returns (bool) {
        return
            keccak256(
                bytes(senateRunoffContract.winners("U.S. Senate Class II"))
            ) == keccak256(bytes("Perdue"));
    }
}
```

4\. Validate on kovan that you are getting [the following results](https://oraqle.vercel.app/oracles/jan-2021-senate/kovan):

![](https://4237340628-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKpcvqHmxdH4lqjGSp7%2F-MPrKxSZ8vRpVmb4t3D4%2F-MPrNZmuSqph58oCkXOP%2Fimage.png?alt=media\&token=a0d9038b-2983-458c-abba-2249d7721698)

5\. Replace the smart contract address on line 6 above with [`the production contract address`](https://etherscan.io/address/0x3E961f9A77146F6230709D767d60025f1Ed3Bfef#code) and get ready for January 5th!&#x20;

6\. Still having issues?&#x20;

1. [Refer to our example repo](https://github.com/EveripediaNetwork/oraqle)
2. Tweet to [@dawsonbotsford](https://twitter.com/dawsonbotsford) and [@everipedia](https://twitter.com/Everipedia) any engineering questions (or send a DM on Twitter to [@dawsonbotsford](https://twitter.com/dawsonbotsford))


# 2020 US Presidential Election

The Associated Press used Everipedia's OraQle software to publish U.S. Presidential election results on November 3rd, 2020. The Ethereum Oracle is powered by Chainlink.

### What is this?

[View a dashboard of the data here](https://everipedia.org/oraqle/ap) or [read our announcement here](https://everipedia.org/blog/ap-and-everipedia-team-up-to-publish-us-election-race-calls-on-the-blockchain). The Associated Press verified all of their smart contract addresses under ["**Election Race Calls on the Blockchain"** here.](https://developer.ap.org/ap-elections-api/)

![](https://4237340628-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKpcvqHmxdH4lqjGSp7%2F-MPvSDXMJCIb9-EKYunw%2F-MPvSoB-58baesmVx9jf%2Fimage.png?alt=media\&token=2b112ed5-5da1-4768-947c-38d60da54b75)

### What if I am not a developer?

You can view the election data off the blockchain in our example app at <https://everipedia.org/oraqle/ap> and follow along with [our announcements on Twitter](https://twitter.com/everipedia).


# 2020 US Presidential Election - Ethereum


# Fetch election calls with Solidity

If you want to connect to the AP Election results in Solidity and deploy an Ethereum smart contract, learn how here.

### 🚀  Want a shortcut? 🚀&#x20;

[**Start with our boilerplate Solidity smart contract on GitHub**](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/ethereum/contracts/TestnetConsumer.sol).&#x20;

### Walkthrough&#x20;

1. Begin by starting a [Truffle project ](https://www.trufflesuite.com/)or using [Remix](https://remix.ethereum.org/)
2. Set `pragma` and import the election results contract at the top of your smart contract

```
pragma solidity ^0.6.12;

import "https://raw.githubusercontent.com/EveripediaNetwork/everipedia-ap-2020/master/ethereum/contracts/TestnetConsumer.sol";
```

3\. Paste in this example code and change the `selectWinner` function to do what you need with the data!

```
contract FetchPresidentialWinners {
    struct Winner {
      string winner;
      uint256 resultNow;
      uint256 resultBlock;
    }
    
    ATestnetConsumer internal winners;
    
    constructor() public {
        // the deployed kovan test contract address
        winners = ATestnetConsumer(0x12B7B8Dea45AF31b6303E00C735332A8b6752856);
        
        // the deployed mainnet contract address
        // winners = ATestnetConsumer(0x0792724900B551d200D954a5Ed709d9514d73A9F);
    }
    
    
   function selectWinner(string memory _state) public view returns (string memory winner, uint256 resultNow, uint256 resultBlock)
  {
    (string memory winner, uint256 resultNow, uint256 resultBlock) = winners.presidentialWinners(_state);
    return (winner, resultNow, resultBlock);
  }
}
```

4\. Validate on kovan that you are getting what you expect from the `presidentialWinners` mapping.

If you're using the above solidity code, you can [see here the "already declared states" (all Kovan test data)](https://everipedia-ap-2020.vercel.app/kovan)

5\. Fetch state data for any of all the states you are interested (52 states = 50 + D.C. + US). [See the exact list of states here.](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/src/all-states.js)

6\. Still having issues?&#x20;

1. [Refer to our example repo](https://github.com/EveripediaNetwork/everipedia-ap-2020/tree/master/ethereum/contracts)
2. Learn more about Chainlink Oracles at <https://docs.chain.link/docs>
3. Tweet to [@dawsonbotsford](https://twitter.com/dawsonbotsford) and [@everipedia](https://twitter.com/Everipedia) any engineering questions (or send a DM on Twitter to [@dawsonbotsford](https://twitter.com/dawsonbotsford))


# Fetch election calls with web3

If you want to connect to the AP Election results in JavaScript using web3, learn how here.

### 🚀  Want a shortcut? 🚀&#x20;

[**Start with our boilerplate "Mission Control" App on GitHub**](https://github.com/EveripediaNetwork/everipedia-ap-2020). This shows how to connect to both mainnet and Kovan testnet using web3.&#x20;

### Walkthrough&#x20;

1. Begin by installing web3

```
npm install web3
```

2\. Instantiate a web3 provider

```
const Web3 = require("web3");
export const web3 = new Web3(
  new Web3.providers.HttpProvider(
    "YOUR_INFURA_URL_OR_SIMILAR_PROVIDER"
  )
);
```

3\. Connect to the contract (the "abi" variable below is a JavaScript array. Find [the mainnet abi here](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/src/mainnet/election-contract.js) and the [kovan abi here](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/src/kovan/election-contract.js))

// Mainnet

```
export const mainnetAddress = "0x0792724900B551d200D954a5Ed709d9514d73A9F";
export const mainnetContract = new web3.eth.Contract(abi, mainnetAddress);
```

// Kovan

```
export const kovanAddress = "0x12B7B8Dea45AF31b6303E00C735332A8b6752856";
export const kovanContract = new web3.eth.Contract(abi, kovanAddress);
```

4\. Fetch the election results!

// Mainnet

```
const allWinners = await mainnetContract.methods
      .presidentialWinners(state)
      .call()
```

// Kovan

```
const allWinners = await kovanContract.methods
      .presidentialWinners(state)
      .call()
```

5\. Make use of your verified election data!

```
/** 
This is the shape of the data
{
  [state]: {
    winner: "Biden" | "Trump" | ...,
    resultNow: "1604003431", // string unix time that winner was called
    resultBlock: "11153856", // string etherum block where call was mined in
  }
}

you can find an array of all states (52 = 50 states + D.C. + US) here:
https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/src/all-states.js
*/
```

You may find this screenshot from Remix easier to understand. This is example data returned for the state "TEST" in production.

![Function screenshot from remix.ethereum.org](https://4237340628-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKpcvqHmxdH4lqjGSp7%2F-MKvEgvc-Ohztn0tL51x%2F-MKvTIUP35LLH3eZgd4h%2Fimage.png?alt=media\&token=942a2603-9d68-40d9-8a3c-5029aed11840)

6\. Still having issues?&#x20;

1. [Refer to our example repo](https://github.com/EveripediaNetwork/everipedia-ap-2020)
2. Learn more about Chainlink Oracles at <https://docs.chain.link/docs>
3. Tweet to [@dawsonbotsford](https://twitter.com/dawsonbotsford) and [@everipedia](https://twitter.com/Everipedia) any engineering questions (or send a DM on Twitter to [@dawsonbotsford](https://twitter.com/dawsonbotsford))<br>


# Mainnet Oracle Data

Here is relevant data for anyone looking to interact with the mainnet smart contract

The election smart contract can be found at [0x0792724900B551d200D954a5Ed709d9514d73A9F](https://etherscan.io/address/0x0792724900B551d200D954a5Ed709d9514d73A9F).

The Associated Press uses wallet [0x436ee8cb3a351893b77f8b57c9772daec3a96445](https://etherscan.io/address/0x436ee8cb3a351893b77f8b57c9772daec3a96445).&#x20;

[Mainnet Oracle Solidity File](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/ethereum/contracts/TestnetConsumer.sol)

[Mainnet Oracle ABI](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/src/mainnet/election-contract.js)

[#poweredByChainlink](https://docs.chain.link/docs)


# Kovan Testnet Oracle Data

The election smart contract can be found at <https://kovan.etherscan.io/address/0x12B7B8Dea45AF31b6303E00C735332A8b6752856>

[Testnet oracle Solidity file ](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/ethereum/contracts/kovan/TestnetConsumer.sol)

[Testnet oracle ABI](https://github.com/EveripediaNetwork/everipedia-ap-2020/blob/master/src/kovan/election-contract.js)

[#poweredByChainlink](https://docs.chain.link/docs)


# 2020 US Presidential Election - EOS

If you want to connect to the full AP Election results in any language over HTTP, learn how here.

Note that the EOS race calls contain more than just the presidential results. This smart contract contains presidential, house, senate, and governor race calls.

### Walkthrough

1. Fetching EOS Oracle data is a simple HTTP request. Use `fetch` or your favorite library to make the request

```
    // in JavaScript
    const allWinners = await fetch('https://eos.hyperion.eosrio.io/v2/history/get_actions?limit=1&account=associapress&filter=associapress%3Aelection&sort=desc')
        .then((res) => res.json())
        .then((res) => {
            return res?.actions?.[0]?.act?.data?.data;
        })
        .then((res) => JSON.parse(res));
```

2\. View the raw JSON response here to ensure you're accessing the data you're interested in:<br>

{% embed url="<https://eos.hyperion.eosrio.io/v2/history/get_actions?limit=1&account=associapress&filter=associapress%3Aelection&sort=desc>" %}

![JSON Response from EOS table](https://4237340628-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MKpcvqHmxdH4lqjGSp7%2F-MLEfMINLwWncDp7rLdv%2F-MLEg3kMYJ-P2HkvGfbz%2Fimage.png?alt=media\&token=e8281b2e-25a2-488e-88b9-42bc6300224d)

\
3\. Still having issues?‌

1. ​Ensure you're accessing the exact part of the JSON object you're interested in. If you want to use the `data` field as JSON, you **have to stringify it first** (the code example in #1 above already does this properly)
2. Tweet to [@dawsonbotsford](https://twitter.com/dawsonbotsford) and [@everipedia](https://twitter.com/Everipedia) any engineering questions (or send a DM on Twitter to [@dawsonbotsford](https://twitter.com/dawsonbotsford))


