Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
martineckardt committed Sep 23, 2024
2 parents 31f832d + b6ba651 commit bd791b4
Show file tree
Hide file tree
Showing 47 changed files with 2,564 additions and 130 deletions.
4 changes: 2 additions & 2 deletions .github/linkChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { readFileSync } from 'fs';
import { load } from 'cheerio';
import { sync as globSync } from 'glob';

const baseUrl = 'https://academy.avax.network';
const baseUrl = 'http://localhost:3000'; // base url of the website

const whitelist = [] // some websites return 404 for head requests, so we need to whitelist them, (fix: pass header -H 'Accept: text/html' and parse text/html)
// see https://github.com/rust-lang/crates.io/issues/788
Expand Down Expand Up @@ -34,7 +34,7 @@ function isValidURLOrPath(url: string): boolean {
async function checkLink(url: string): Promise<boolean> {
try {
const response = await get(url, {
timeout: 10000, // timeout to 10 seconds
timeout: 20000, // timeout to 20 seconds
maxRedirects: 5, // handle up to 5 redirects
validateStatus: function (status) {
return status >= 200 && status < 400; // resolve only if the status code is less than 400
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/checklinks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
paths:
- '**/*.mdx'
branches: [dev]

jobs:
check-links:
Expand All @@ -16,6 +17,14 @@ jobs:
- name: Install dependencies
run: |
yarn install --frozen-lockfile
yarn global add tsx
yarn global add tsx wait-on
- name: Start Dev Server in Background
run: |
yarn dev &
- name: Wait for Dev Server to be Ready
run: |
wait-on http://localhost:3000
- name: Check links
run: yarn check-links
- name: Stop Dev Server
run: kill $(jobs -p) || true
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Features
description: Learn about the features of the AvaCloud API.
updated: 2024-09-03
authors: [owenwahlgren]
icon: Book
---

## What is the Data API?

The Data API provides web3 application developers with multi-chain data related to Avalanche’s primary network, Avalanche L1s, and Ethereum. With the Data API, you can easily build products that leverage real-time and historical transaction and transfer history, native and token balances, and various types of token metadata.

### Data API Features
- **Extensive L1 Support**: Gain access to data from over 100+ L1s across both mainnet and testnet. If an L1 is listed on the [Avalanche Explorer](https://subnets.avax.network/stats/), you can query its data using the Data API.
- **Transactions and UTXOs**: Easily retrieve details related to transactions, UTXOs, and token transfers from Avalanche EVMs, Ethereum, and Avalanche’s Primary Network (P-Chain, X-Chain and C-Chain).
- **Blocks**: Retrieve latest blocks and block details
- **Balances**: Fetch balances of native, ERC-20, ERC-721, and ERC-1155 tokens along with relevant metadata.
- **Tokens**: Augment your user experience with asset details.
- **Staking**: Get staking related data for active and historical validations.

## What is the Metrics API?
The Metrics API equips web3 developers with a robust suite of tools to access and analyze on-chain activity across Avalanche’s primary network, Avalanche L1s, and other supported EVM chains. This API delivers comprehensive metrics and analytics, enabling you to seamlessly integrate historical data on transactions, gas consumption, throughput, staking, and more into your applications.

The Metrics API, along with the Data API are the driving force behind every graph you see on the [Avalanche Explorer](https://subnets.avax.network/stats/). From transaction trends to staking insights, the visualizations and data presented are all powered by these APIs, offering real-time and historical insights that are essential for building sophisticated, data-driven blockchain products.

### Metrics API Features
- **Chain Throughput**: Retrieve detailed metrics on gas consumption, Transactions Per Second (TPS), and gas prices, including rolling windows of data for granular analysis.
- **Cumulative Metrics**: Access cumulative data on addresses, contracts, deployers, and transaction counts, providing insights into network growth over time.
- **Staking Information**: Obtain staking-related data, including the number of validators and delegators, along with their respective weights, across different subnets.
- **Blockchains and Subnets**: Get information about supported blockchains, including EVM Chain IDs, blockchain IDs, and subnet associations, facilitating multi-chain analytics.
- **Composite Queries**: Perform advanced queries by combining different metric types and conditions, enabling detailed and customizable data retrieval.

## What is the AvaCloudSDK?

The [AvaCloud SDK](https://developers.avacloud.io/avacloud-sdk/getting-started) provides web3 application developers with multi-chain data related to Avalanche’s primary network, Avalanche L1s, and Ethereum. With the Data API, you can easily build products that leverage real-time and historical transaction and transfer history, native and token balances, and various types of token metadata.

The SDK is currently available in TypeScript, with more languages coming soon. If you are interested in a language that is not listed, please reach out to us in the [`#dev-tools`](https://discord.com/login?redirect_to=%2Flogin%3Fredirect_to%3D%252Fchannels%252F578992315641626624%252F1280920394236297257) channel in the [Avalanche Discord](https://discord.com/invite/avax).
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: APIs vs RPCs
description: Learn how the AvaCloud Data API differs from RPC calls
updated: 2024-09-03
authors: [owenwahlgren]
icon: Book
---

Blockchain RPCs and APIs both facilitate interactions with a network, but they differ significantly in how they operate.

### RPCs
**Blockchain RPCs** allow you to communicate directly with a blockchain node, performing tasks like querying data or submitting transactions. These are low-level, synchronous calls, requiring a deep understanding of the blockchain's structure and specific commands.

To get a more comprehensive understanding of Ethereum's JSON-RPC API, you can refer to the [official Ethereum documentation](https://ethereum.org/en/developers/docs/apis/json-rpc/).

### APIs
**Blockchain APIs**, like the AvaCloud Data API, abstract away much of the complexity. They offer higher-level, user-friendly endpoints that streamline interactions, making it easier to build and manage blockchain applications without needing in-depth knowledge of the underlying blockchain protocols.

To get a more comprehensive understanding of the AvaCloud Data API, you can refer to the [official AvaCloud Data API documentation](https://developers.avacloud.io/data-api/overview).

### Example Use Case
For example, querying a user's ERC-20 portfolio using an RPC involves a series of complex calls to retrieve and parse raw blockchain data.
Using just RPCs, you would need to:

1. Query every block on the network for transaction logs.
2. Parse each transaction log to identify ERC-20 token transfers.
3. Extract the ERC-20 token contract address.
4. For each ERC-20 token contract, query the user's address to get the balance.
5. Parse and aggregate the data to present the user's portfolio.

While it may seem simple in theory, this process can be time-consuming and error-prone, especially when dealing with multiple blockchains.

With the AvaCloud Data API, you could simply use a dedicated endpoint such as:
```bash
curl --request GET \
--url https://glacier-api.avax.network/v1/chains/{chainId}/addresses/{address}/balances:listErc20 \
--header 'x-glacier-api-key: <api-key>'
```

to get a neatly formatted response with the user's ERC-20 portfolio, significantly reducing development time and complexity.

```json
{
"nextPageToken": "<string>",
"erc20TokenBalances": [
{
"address": "0x71C7656EC7ab88b098defB751B7401B5f6d8976F",
"name": "Wrapped AVAX",
"symbol": "WAVAX",
"decimals": 18,
"logoUri": "https://images.ctfassets.net/gcj8jwzm6086/5VHupNKwnDYJvqMENeV7iJ/fdd6326b7a82c8388e4ee9d4be7062d4/avalanche-avax-logo.svg",
"ercType": "ERC-20",
"price": {
"currencyCode": "usd",
"value": "42.42"
},
"chainId": "43114",
"balance": "2000000000000000000",
"balanceValue": {
"currencyCode": "usd",
"value": "42.42"
}
}
]
}
```
Loading

0 comments on commit bd791b4

Please sign in to comment.