Code Monkey home page Code Monkey logo

blockchain_indexers's Introduction

indexer-database

main.rs

fn main()

returns -> Result which can be - empty result, programming successful exit of the program - error

Description - THe main function is the starting point of the indexer. It takes no parameters and is responsible for initializing the indexer data environment and calling other functions.

Initializing Data Environment - Before calling the functions which actually indexes the transactions we need to set some data which are required for these functions to work properly.

List of required data -

1. contract_metadata

The contract_metadata is a struct of type ContractMetaData which contains the basic data fetched from our Mongodb collection contracts.

The ContractMetaData type:

pub struct ContractMetaData {
    pub contract_address: String,
    pub read_abi_from: String,
    pub chain_id: String,
    pub function_of_interest: String,
    pub contract_name: String,
    pub contract_description: String,
    pub contract_slug: String,
    pub method_of_interest:std::collections::HashSet<String>,
    pub methods:Document,
}

Key points

  • contract_address: Address of the contract that we will index
  • read_abi_from: Address of the contract from where we get the Application Binary Interface (ABI) of the project smart contract. This is usually required if the above contract_address is a proxy contract, then we cannot use that ABI, instead we get it from read_abi_from, which will be given by the user.
  • chain_id: Id of the chain where the contract is deployed
  • function_of_interest: A list of functions which will be indexed if a transaction happens on anyone of them
2. contract_result

This is tuple of contract_metadata, contract_fetched_abi, and contract_abi. The function that returns the data for this comes from utils.rs -> utils_contract_data(contract_slug)????.

3. contract_abi

This contains the ABI of the contract that is on the second index position of contract_result. At first the smart contract ABI is a String type, stored in contract_fetched_abi variable. We convert the String type to

utils.rs

blockchain_indexers's People

Contributors

aditya172926 avatar varun-doshi avatar chirag0002 avatar

Stargazers

Aleksandr Volkov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.