Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed token-list pages #326

Merged
merged 3 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Result(3) [
rentEpoch: 18446744073709552000,
space: 165
} getAccountInfo SenderAccount
Minting SPLTokens to SenderAccount and transfering them to ReceiverAccount ...
Minting SPLTokens to SenderAccount and transferring them to ReceiverAccount ...
Executing batchExecuteComposabilityMethod ...
ContractTransactionResponse {
provider: HardhatEthersProvider {
Expand Down
196 changes: 196 additions & 0 deletions docs/developing/integrate/oracles/integrating_api3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
---
title: API3
proofedDate: 20240717
iterationBy: na
includedInSite: false
approvedBy: na
comment:
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import mm_p_key from '@site/static/img/doc-images/developing/deploy_facilities/foundry-metamask.png';

## Introduction

API3 dAPIs (decentralized APIs) offer a state-of-the-art solution for connecting off-chain data sources with on-chain applications. They use first-party oracles managed directly by API providers, ensuring reliable and continuously updated data feeds. These oracles provide cryptographically signed data, which is then aggregated on-chain into a secure and tamper-proof data feed known as a beacon set.

Developers can easily integrate dAPIs into their decentralized applications (dApps), enabling real-time access to off-chain data, such as price feeds, without requiring extensive technical implementation. The integration process is simplified through a proxy address that represents the dAPI requester, facilitating the interaction between the dApp and the data feed. API3 has made it straightforward for dApp owners to read on-chain values from these beacons, enhancing the functionality and reliability of their applications.

Each API3 data feed is available via its own proxy contract. To use a feed, you create a "hybrid" smart contract, i.e. you build the integration with the feed proxy contract into your own smart contract and deploy that. Learn more from [API3's documentation](https://docs.api3.org/explore/dapis/what-are-dapis.html), or examine the [boilerplate provided](#boilerplate-contract).

## Deployed feeds

:::important
Activation of API3 price feeds is permissionless and anyone can activate the price feeds with a transaction on Neon EVM Mainnet and Devnet.
:::

The proxy contract addresses of the price feeds are available both on Neon EVM Mainnet and Devnet.

<Tabs>

<TabItem value="Mainnet" label="Mainnet">

| Currency pair | API3 proxy contract feed address |
| :-----------: | :----------------------------------------: |
| USDT/USD | 0xF00249f594f11c3F98F2D73433274D10098906B6 |

</TabItem>

<TabItem value="Devnet" label="Devnet">

| Currency pair | API3 proxy contract feed address |
| :-----------: | :----------------------------------------: |
| BTC/USD | 0x81A64473D102b38eDcf35A7675654768D11d7e24 |
| ETH/USD | 0xa47Fd122b11CdD7aad7c3e8B740FB91D83Ce43D1 |
| SOL/USD | 0xCa81409D8dF6d34a21d93B5c0EF79557Bc5fb4be |
| USDC/USD | 0xa790a882bB695D0286C391C0935a05c347290bdB |
| USDT/USD | 0xF00249f594f11c3F98F2D73433274D10098906B6 |
| NEON/USD | 0x383CC331Cd5669b7B6460a24b1B45cD9220B28a8 |
| LINK/USD | 0xB102ec41347F26E8493B8C98cA1c10b69903Dc57 |

</TabItem>

</Tabs>

## Boilerplate contract

[View GitHub example](https://github.com/neonlabsorg/neon-tutorials/blob/main/hardhat/contracts/TestAPI3/TestAPI3.sol)

```
// SPDX-License-Identifier: MIT
pragma solidity 0.8.21;

import "@api3/contracts/api3-server-v1/proxies/interfaces/IProxy.sol";

contract TestAPI3 {
// Use your proxy address as the argument
function readDataFeed(address proxy) public view returns (int224 value, uint32 timestamp) {
(value, timestamp) = IProxy(proxy).read();
// If you have any assumptions about `value` and `timestamp`, make sure
// to validate them right after reading from the proxy. For example,
// if the value you are reading is the spot price of an asset, you may
// want to reject non-positive values...
require(value > 0, "Value not positive");
// ...and if the data feed is being updated with a one day-heartbeat
// interval, you may want to check for that.
require(
timestamp + 1 days > block.timestamp,
"Timestamp older than one day"
);
}
}
```

## How to integrate with the API3 contract

:::important
Before trying out the tutorial in the next steps, please make sure that the price feeds are activated for **[Neon EVM Mainnet](https://market.api3.org/neon-evm)** and **[Neon EVM Devnet](https://market.api3.org/neon-evm-testnet)**.
:::

The example this tutorial is based on is located in [this repository](https://github.com/neonlabsorg/neon-tutorials/tree/main/hardhat).

By the end of this tutorial, you will deploy a contract which reads API3 price feeds.

### Step 1: Installation

> **Note:** This page is just a quickstart based on a specific example program. For more details on installing Hardhat, refer to the _[Hardhat documentation](https://hardhat.org/hardhat-runner/docs/getting-started#overview)_.

Using Git, clone the example Hardhat project from the remote repository and navigate to it:

```sh
git clone https://github.com/neonlabsorg/neon-tutorials
cd neon-tutorials/hardhat
```

Then, run the following command:

```sh
npm install
```

This will install all the necessary packages to continue with the example. These packages include the `Hardhat` library.

If the above command results in an error, run:

```sh
npm cache clear --force
npm install
```

### Step 2: Set Up MetaMask Accounts

:::info
This step requires an EVM-compatible wallet such as MetaMask, connected to Neon Devnet, with a balance in Devnet NEON available from [NeonFaucet](https://neonfaucet.org/).

The following tutorials assist you to meet these prerequisites:

- Learn how to [install a MetaMask wallet and connect it to Devnet](/docs/wallet/metamask_setup)

> Or [connect an existing wallet to Devnet](/docs/developing/connect_rpc#connect-via-chainlist)
> :::

2.1 Obtain the private key for your wallet account.

> To obtain the private key from MetaMask, from the hamburger menu, click **Account Details** > **Show Private Key**, enter your password, and click **Confirm** for access to the private key for that account.
> <img src={mm_p_key} width="250" />

2.2 Create a .env file and add these lines:

```
PRIVATE_KEY_OWNER=`YOUR_PRIVATE_KEY`
```

:::important
Replace `YOUR_PRIVATE_KEY` with your data.
:::

### Step 3: Compile Contracts

All of the contracts are located in the project's `contracts/` directory. Before these contracts can be run, they must first be compiled. To compile the project's contracts, run the following command:

```sh
npx hardhat compile
```

After running this step, you should see output similar to the following:

```
Compiled 23 Solidity files successfully
```

### Step 4: Deploy Contract

`NEON_CONFIG` contains the proxy price feed addresses on Neon EVM Mainnet and Devnet for reading API3 price feeds.

To deploy the project's hybrid contract, simply run the command below to run the deployment script in the `scripts/` directory:

```sh
npx hardhat run scripts/TestAPI3/deploy.js --network neondevnet
```

The output should look like:

```
TestAPI3 deployed to 0xB8747279e8029108720BcB5386511D70B9129D68
BTC_USD Result(2) [ 64547812100000000000000n, 1721241637n ]
ETH_USD Result(2) [ 3431460000000000000000n, 1721274476n ]
SOL_USD Result(2) [ 159776804400000000000n, 1721284955n ]
USDC_USD Result(2) [ 999900024820969500n, 1721220644n ]
USDT_USD Result(2) [ 1000188700000000000n, 1721220738n ]
NEON_USD Result(2) [ 392570000000000000n, 1721270758n ]
LINK_USD Result(2) [ 13807707000000000000n, 1721291017n ]
```

> The result represents an array with the following parameters:
>
> - 1st parameter - Price
> - 2nd parameter - Timestamp of the last price push

:::info
To deploy on Neon EVM Mainnet, change `--network neondevnet` to `--network neonmainnet` in the command line.
:::

:::important
If a dApp wants to recapture OEV (https://api3.org/oev/), they can contact us, and API3 will assist them in obtaining a unique proxy for their dApp. You can join their [Discord](https://discord.com/invite/qnRrcfnm5W) and reach out to the API3 team in the OEV section.
:::
1 change: 1 addition & 0 deletions docs/tokens/token_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/jitosol-token-logo.svg" className="coin-icon" /> | JitoSOL | `0xFA8fB7e3bd299B2A9693B1BFDCf5DD13Ab57007E` | `J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/marinade-staked-sol-logo.svg" className="coin-icon" /> | mSOL | `0x6EFFb385713f22df4846d8156451a5efEC22a4c8` | `mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/bonk-token-logo.svg" className="coin-icon" /> | Bonk | `0xD4B6520f7Fb78E1EE75639F3376c581a71bcdb0E` | `DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/Mellivora-token-logo.svg" className="coin-icon" /> | MELL | `0x26320e7ffd9be68ca61c1C75b3Be4aAb0AA98E1f` | `MELLd8PyFoeNW3D5VaUe7L96eZeihtrzgLWrbKz5DR2` |

Check warning on line 47 in docs/tokens/token_list.md

View workflow job for this annotation

GitHub Actions / runner / chore

"Ue" should be "Use" or "Due".
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/mango-token-logo.svg" className="coin-icon" /> | MNGO | `0x6d12eAA69f8e4902D3F83d546B31F7318717014C` | `MangoCzJ36AjZyKwVj3VnYU4GTonjfVEnJmvvWaxLac` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/fidelion-token-logo.svg" className="coin-icon" /> | 2080 | `0x96e636d3Ef60ee9745945120010c73619144632C` | `Dwri1iuy5pDFf2u2GwwsH2MxjR6dATyDv9En9Jk8Fkof` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/pyth-token-logo.svg" className="coin-icon" /> | PYTH | `0x0575dD4AFD93B7522fEE4e0179f243ecA3856137` | `HZ1JovNiVvGrGNiiYvEozEVgZ58xaU3RKwX8eACQBCt3` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/blaze-token-logo.svg" className="coin-icon" /> | BLZE | `0x09F8A075D6fca984EA0bAda25A64326DF00691A4` | `BLZEEuZUBVqFhj8adcCFPJvPVCiCyVmh3hkJMrU8KuJA` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/jsol-logo.svg" className="coin-icon" /> | JSOL | `0x7b9f9033afcf602b556a7aeac5871a52b56a06ee` | `7Q2afV64in6N6SeZsAAB81TJzwDoD6zpqmHkzi9Dcavn` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/cgt-token-logo.svg" className="coin-icon" /> | CGT | `0x9950ef047D87599EB28bF5E9Fc7F63cEd1b5F4AE` | `5qkTJu3hVd3SYToWpyHUmGfiLR48jj9oSz1WniV1UcgS` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/jupiter-logo.svg" className="coin-icon" /> | JUP | `0x9F0fCE2AB962984b1EE50108A8510eA190BeEb8d` | `JUPyiwrYJFskUPiHa7hkeR8VUtAeFoSYbKedZNsDvCN` |

Check warning on line 54 in docs/tokens/token_list.md

View workflow job for this annotation

GitHub Actions / runner / chore

"Fo" should be "Of" or "For" or "Do" or "Go" or "To".
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/dogwifhat-logo.png" className="coin-icon" /> | $WIF | `0xF86934c2b05c31f3bBE3BCd6E3a8aA7790cAd9c1` | `EKpQGSJtjMFqKZ9KQanSqYXRcF8fBopzLHYxdM65zcjm` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/wen-logo.png" className="coin-icon" /> | WEN | `0xc61e8aB62666D25F0854C5723587507A7E92E289` | `WENWENvqqNya429ubCdR81ZmD69brwQaaBYY6p3LCpk` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/popcat-logo.svg" className="coin-icon" /> | POPCAT | `0xb89c62e960457d1d2c5f20135bedfd215d2466de` | `7GCihgDB8fe6KNjn2MYtkzZcRjQy3t9GHdC8uHYmW2hr` |
| <img src="https://raw.githubusercontent.com/neonlabsorg/token-list/master/assets/whale-token-logo.svg" className="coin-icon" /> | WHALE | `0x663572b924db12e0e3822c6160df29154630c8e3` | `9uhHjyfc5tKdaZnjstLLKoLGcF889ub8zX9wtwhtzgK6` |

</TabItem>
<TabItem value="devnet" label="Devnet">
Expand Down
5 changes: 2 additions & 3 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ const sidebars = {
{
type: 'category',
label: 'Dev Recommendations',
items: [
'developing/dev_recommendations/global_variables'
]
items: ['developing/dev_recommendations/global_variables']
},
{
type: 'category',
Expand All @@ -82,6 +80,7 @@ const sidebars = {
'developing/integrate/wallets/integrating_web3auth',
'developing/integrate/oracles/integrating_chainlink',
'developing/integrate/oracles/integrating_pyth',
'developing/integrate/oracles/integrating_api3',
'developing/integrate/middleware/the-graph',
'developing/integrate/indexer/flair',
'developing/integrate/indexer/envio',
Expand Down
Loading