Viction
  • Getting Started
  • General
    • Overview
    • Viction Blockchain
      • PoSV Consensus
      • Comparison
    • Staking
      • Staking Requirements
      • Staking Rewards
      • How to stake on Viction Wallet
    • Network Information
      • Viction Mainnet
      • Viction Testnet
    • Viction RPC API
  • Smart Contract Development
    • Solidity
      • A Simple Smart Contract
      • Solidity by Example
    • Standards & Specification
      • VRC25 Specification
      • VRC725 Specification
    • IDEs and Tools
      • Remix
      • Ethers.js
      • web3.js
      • thirdweb CLI
    • Deployment & Verification
      • Hardhat
      • Foundry
  • DApp Development
    • Integration
      • Exchange/Wallet integration
      • VRC25 Exchange/Wallet integration
      • Viction Staking Governance
      • VIC ZeroGas
      • VRRF
    • Data and analytics
    • Embedded Wallet (MPC)
    • Walkthrough: Build a Dapp on Viction
      • Setup Environment
      • Write the Smart Contract
      • Interacting with the Dapp in a browser
  • Masternode
    • Requirements
    • Run a Full Node
      • Binary
      • Create a Viction Masternode
      • Tmn
      • Docker
    • Apply Your Node
    • Slashing Mechanism
    • Chain Data Snapshots
    • Troubleshooting
  • Viction Wallet
    • User Guide
      • Authentication
      • How to create a new wallet
      • How to restore a wallet?
      • Wallet settings
      • Send & Receive Tokens
      • Add custom token
      • Manage Tokens
      • Send NFT
      • General settings
    • Developer Guide
    • Privacy Policy
    • Term and Services
  • Viction Bridge
    • Spacegate
    • Arken Bridge
    • Hyperlane
  • Viction Data Availability
    • Viction DA RPC API
    • DA Integration Use cases
      • Simple Guide for Integrating OP Stack Rollup with Viction DA Layer
  • How to
    • How to Connect to Viction Blockchain
      • Coin98 Super Wallet
      • Metamask
      • Ledger
    • How to troubleshoot when the node is up but couldn't begin to sync block
    • How to Vote for Viction Saigon Network Upgrade Proposal
    • How to issue a token via VICIssuer
    • How to verify if a contract has been issued via VICIssuer
    • How to deploy the VRC725 contract
    • How to apply ZeroGas for VRC725 contract
    • How to Migrate Dapps from Ethereum
    • How to register Token or NFT logo on Vicscan
    • How to verify a contract on Vicscan
    • How to confirm a project on Vicscan
    • How to check if a token is gas sponsored on Viction
    • How to verify gas sponsored transactions
    • How to create Telegram Mini Apps
    • How to use VictionSafe (Multisig)
  • FAQ
    • APIs
    • General
      • Viction
      • Ecosystem
      • VIC - Economics
      • Contact & Support
    • Masternodes and Voting
      • Masternodes
      • Voter
    • Products
      • VicScan (Explorer)
      • VicMaster
      • VicStats
      • VicIssuer
        • How to Verify & Publish Contract Source Code on VicScan
      • Viction Wallet
      • Viction Data Availability Network
  • Legal
    • Terms of Use
    • Privacy Policy
  • Whitepaper and Research
  • Archive
    • TOMOE
    • How to Deploy a VRC25 Token on Viction
    • How to deploy an ICO smart contract on Viction
    • How to deploy an NFT token
    • An Example of Building a Dapp on Viction
    • Migrate Ethereum Dapp to Viction
    • TomoMasterDAO
      • Introduction
      • Governance model
        • On-Chain vs Off-Chain Voting
        • Board
        • Proposals
        • Voting and Outcome
      • Tokenomics
      • How to utilize and trade tDAO
      • Proposal guidelines for TomoMasterDAO
    • Old Viction Testnet
    • Deploy on Viction
      • CLI Commands
      • Viction Private Testnet Setup
Powered by GitBook
On this page
  • Introduction
  • Prerequisites
  • SubQuery Network
  • Goldsky Subgraph
  • The Graph
  • Quick Start​
  • 1. Initialize your subgraph project​
  • 2. Deploy & Publish​
  • 3. Query your Subgraph​
  • Appendix​
  1. DApp Development

Data and analytics

PreviousVRRFNextEmbedded Wallet (MPC)

Last updated 3 months ago

Introduction

As the network usage expands, the volume of valuable on-chain data will significantly increase. With this rapid data growth, the task of calculating and aggregating this information to generate reports or power a decentralized application (dApp) can become increasingly time-consuming and resource-intensive.

By utilizing established data providers, developers can accelerate their development processes, achieve more accurate results, and minimize the efforts required for ongoing maintenance. This approach allows development teams to focus on delivering the core functionalities of their projects, rather than getting bogged down by the complexities of data management. Leveraging these external data solutions ensures that teams can efficiently harness the wealth of on-chain data, driving innovation and enhancing the performance and reliability of their dApps.

Prerequisites

To effectively use block explorers within the context of data analytics, it is essential to grasp their basic concepts. Block explorers provide a user-friendly interface for accessing and navigating blockchain data, which is crucial for extracting meaningful insights.

Additionally, gaining a solid understanding of indexing is important, as indexes significantly enhance system design by optimizing data retrieval processes. Indexes allow for faster and more efficient queries, which is particularly beneficial in handling large volumes of blockchain data.

From an architectural standpoint, it is also beneficial to understand the fundamentals of APIs (Application Programming Interfaces) and REST (Representational State Transfer). Even a theoretical knowledge of these concepts can be invaluable. APIs enable different software applications to communicate with each other, while REST is a widely-used architectural style for designing networked applications. Together, they play a crucial role in developing robust and scalable systems for blockchain data analytics. Familiarity with these concepts will provide a solid foundation for leveraging block explorers and data indexing effectively in your projects.

SubQuery Network

SubQuery is a premier data indexing service that provides developers with fast, reliable, decentralized, and customizable APIs tailored for their Web3 projects. By leveraging SubQuery, developers gain access to rich, indexed data from over 100+ ecosystems, including Viction. This enables them to create intuitive and immersive user experiences. The SubQuery Network ensures the resilience and decentralization of your applications by offering a robust infrastructure network. With SubQuery's comprehensive blockchain developer toolkit, you can focus on building the next generation of Web3 applications without the need to invest time and resources into developing a custom backend for data processing activities. This empowers developers to innovate and deploy unstoppable applications efficiently and effectively.

One of SubQuery's significant competitive advantages is its capability to aggregate data not only within a single blockchain but also across multiple blockchains, all within a single project. This cross-chain data aggregation enables developers to create advanced, feature-rich analytics dashboards and multi-chain block explorers. By consolidating data from various blockchains, SubQuery allows for comprehensive insights and real-time analytics, providing a unified view of blockchain activities. This functionality is particularly valuable for developers looking to build sophisticated tools and applications that require seamless integration and analysis of data from multiple blockchain networks, thereby enhancing the overall user experience and utility of their Web3 projects.

To get started, use the and begin indexing Viction blockchain data in minutes. It is advised to first start with the . Otherwise, further information may be obtained .

Goldsky Subgraph

Goldsky is the go-to data indexer for web3 builders, offering high-performance subgraph hosting and realtime data replication pipelines.

Goldsky provides a completely backwards-compatible subgraph indexing solution. The core of the indexing uses exactly the same WASM processing layer, but in addition, Goldsky offers:

  • a rewritten RPC layer, autoscaling query layer, and storage optimizations to improve reliability (99.9%+ uptime) and performance (up to 6x faster)

  • webhooks support out-the-box to enable notifications, messaging, and other push-based use cases

  • support for custom EVM chains so you can index your own rollup or private blockchain seamlessly

You can query Viction blocks easily using this endpoint

The Graph

These subgraphs only take a few minutes to set up and get running. To get started, follow these three steps:

  1. Initialize your subgraph project

  2. Deploy & Publish

  3. Query from your dapp

Pricing: All developers receive 100,000 free queries per month on the decentralized network. After these free queries, you only pay based on usage at $2 for every 100,000 queries.

Here’s a step-by-step walkthrough:

You will then land on your subgraph’s page. All the CLI commands you need will be visible on the right side of the page:

On your local machine run the following:

npm install -g @graphprotocol/graph-cli

You can copy this directly from your subgraph page to include your specific subgraph slug:

graph init <SUBGRAPH_SLUG>// Some code

You’ll be prompted to provide some info on your subgraph like this:

Simply have your contract verified on the block explorer and the CLI will automatically obtain the ABI and set up your subgraph. The default settings will generate an entity for each event.

First run these commands:

$ graph codegen
$ graph build

Then run these to authenticate and deploy your subgraph. You can copy these commands directly from your subgraph’s page in Studio to include your specific deploy key and subgraph slug:

$ graph auth <DEPLOY_KEY>
$ graph deploy <SUBGRAPH_SLUG>

You will be asked for a version label. You can enter something like v0.0.1, but you’re free to choose the format.

You can test your subgraph by making a sample query in the playground section. The Details tab will show you an API endpoint. You can use that endpoint to test from your dapp.

Once your subgraph is ready to be put into production, you can publish it to the decentralized network. On your subgraph’s page in Subgraph Studio, click on the Publish button:

Before you can query your subgraph, Indexers need to begin serving queries on it. In order to streamline this process, you can curate your own subgraph using GRT.

When publishing, you’ll see the option to curate your subgraph. As of May 2024, it is recommended that you curate your own subgraph with at least 3,000 GRT to ensure that it is indexed and available for querying as soon as possible.

Congratulations! You can now query your subgraph on the decentralized network!

For any subgraph on the decentralized network, you can start querying it by passing a GraphQL query into the subgraph’s query URL which can be found at the top of its Explorer page.

The query URL for this subgraph is:

Now, you simply need to fill in your own API Key to start sending GraphQL queries to this endpoint.

In Subgraph Studio, you’ll see the “API Keys” menu at the top of the page. Here you can create API Keys.

This query shows the most expensive CryptoPunks sold.

{
 trades(orderBy: priceETH, orderDirection: desc) {
   priceETH
   tokenId
 }
}
Passing this into the query URL returns this result:
{
 "data": {
   "trades": [
     {
       "priceETH": "124457.067524886018255505",
       "tokenId": "9998"
     },
     {
       "priceETH": "8000",
       "tokenId": "5822"
     },
//      ...
const axios = require("axios");

const graphqlQuery = `{
 trades(orderBy: priceETH, orderDirection: desc) {
   priceETH
   tokenId
 }
}`;
const queryUrl =
 "https://gateway-arbitrum.network.thegraph.com/api/[api-key]/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK";

const graphQLRequest = {
 method: "post",
 url: queryUrl,
 data: {
   query: graphqlQuery,
 },
};

// Send the GraphQL query
axios(graphQLRequest)
 .then((response) => {
   // Handle the response here
   const data = response.data.data;
   console.log(data);
 })
 .catch((error) => {
   // Handle any errors
   console.error(error);
 });

Getting historical data on a smart contract can be frustrating when you’re building a dApp. provides an easy way to query smart contract data through APIs known as subgraphs. The Graph’s infrastructure relies on a decentralized network of indexers, enabling your dapp to become truly decentralized.

Quick Start

1. Initialize your subgraph project

Create a subgraph on Subgraph Studio⁠

Go to the and connect your wallet. Once your wallet is connected, you can begin by clicking “Create a Subgraph”. It is recommended to use Title Case: “Subgraph Name Chain Name.”

Install the Graph CLI⁠

Initialize your Subgraph⁠

2. Deploy & Publish

Deploy to Subgraph Studio⁠

Test your subgraph⁠

Publish Your Subgraph to The Graph’s Decentralized Network

Note: The Graph's smart contracts are all on Arbitrum One, even though your subgraph is indexing data from Ethereum, BSC or any other .

3. Query your Subgraph

Here’s an example from the by Messari:

Getting your own API Key

Appendix

Sample Query

💡 Trivia: Looking at the top sales on it looks like the top sale is Punk #5822, not #9998. Why? Because they censor the flash-loan sale that happened.

Sample code

Additional resources:

To explore all the ways you can optimize & customize your subgraph for a better performance, read more about .

For more information about querying data from your subgraph, read more .

Viction starter
quick start guide
here
https://api.goldsky.com/api/public/project_cld6kdj9u539w0htd50sbeqyz/subgraphs/viction-blocks/1.0/gn
The Graph
​
​
​
Subgraph Studio
​
​
​
​
​
​
supported chain
​
CryptoPunks Ethereum subgraph
https://gateway-arbitrum.network.thegraph.com/api/**[api-key]**/subgraphs/id/HdVdERFUe8h61vm2fDyycHgxjsde5PbB832NHgJfZNqK
​
​
​
CryptoPunks website
​
​
creating a subgraph here
here