Partner Workshop: DEX Guru

Quick Start Guide for Developers at XFI Hackathon

Evengy from Dex Guru will present GURU developers toolset products and dApp framework allowing developers to build full stack dApps on CrossFi Chain

Introduction

Welcome to the XFI Hackathon! This guide will help you get started with the XFI Data Warehouse, Block Explorer, XFI Swap and Status providing you with the tools and knowledge needed to build powerful applications on the XFI Chain.

If you are into watching videos more than reading: https://www.loom.com/share/b096b03cf7884312a9bf347a0ee30607

Block Explorer

The Block Explorer provides real-time visibility into transactions, blocks, and wallet addresses, facilitating easy tracking and analysis.

Key Features

  • Real-Time Tracking: Monitor transactions, blocks, and wallet addresses.

  • Developer Console: Access data API and verify contracts.

  • Warehouse Integration: Utilize the warehouse for data queries and dashboard creation.

Exploring Blocks and Transactions

The Block Explorer offers basic features similar to well-known explorer services, such as:

  • Block Info: View details about individual blocks.

  • Transaction Info: Track transaction statuses and details.

  • Chain Info: Get information about the XFI Chain.

Visit the Block Explorer at XFI Block Explorer.

Top ERC-20 Tokens and Transactions

The Block Explorer also provides insights into top ERC-20 tokens and their transactions (TBA).

Contract Verification Interface

Contract verification on XFI Chain is streamlined through the integration with Sourcify, ensuring transparency and trust in smart contracts.

How to Verify Your Contract

  1. Prepare Source Code: Ensure your smart contract source code and related metadata are ready.

  2. Submit to Sourcify:

    • Via Block Explorer: Follow the instructions on the XFI Block Explorer Contract Verification page.

    • Via Sourcify Portal: Submit your contract directly on the Sourcify Verification Portal.

  3. Verification Process: Sourcify will match the submitted source code with the on-chain bytecode. If they match, the contract is successfully verified.

Example Verification Command

curlCopy codecurl -X POST https://sourcify.dev/server/verify -F "contract=@path/to/contract.sol" -F "metadata=@path/to/metadata.json"

Accessing Verified Contracts

Once verified, your contract's source code and metadata will be accessible through the XFI Chain Block Explorer, promoting transparency and trust.

Data Warehouse Overview

The XFI Data Warehouse is designed to store large volumes of historical data and enable fast, complex queries across various data types. It provides meaningful business insights, embeddable charts, and a data API.

Key Features

  • Analysis: Optimized for read access, making it efficient for analytical queries which help in reporting, data mining, and predictive analytics.

  • Historical Intelligence: Maintains historical data to analyze trends over time, providing a valuable resource for longitudinal studies and forecasting.

  • Scalability: Designed to scale out to handle terabytes to petabytes of data, accommodating growth seamlessly.

  • Performance: Built with performance optimization mechanisms such as indexing, partitioning, and caching to ensure quick retrieval of data.

Video Explainer

For a comprehensive overview, watch this video explainer.

Creating Queries and Dashboards

You can create queries, build dashboards by combining queries and visualizations, tag them, and publish them for public usage.

Steps to Create a Dashboard

  1. Create Queries: Define your SQL queries to fetch data.

  2. Create Dashboards: Combine multiple queries and visualizations.

  3. Tag and Publish: Tag your dashboards and publish them for public access.

Example: XFI Pools Activity Dashboard

  1. Query Dashboards: Select the query dashboard from the dropdown.

  2. Global Parameters: Set the global parameters for the dashboard.

  3. Refresh Rate: Define the refresh rate for the dashboard data.

  4. SQL Query: Write your SQL query with necessary parameters.

  5. Visualization: Configure the visualization type and parameters.

SQL Query Example

sqlCopy codeWITH
    toUnixTimestamp(toString('{{dates.start}}')) AS dateStart,
    toUnixTimestamp(toString('{{dates.end}}')) AS dateEnd
SELECT 
    pool_address,
    wallet_address,
    DATE(block_timestamp) as timestamp,
    CAST(token_addresses[1] as CHAR) as tokenFrom,
    CAST(token_addresses[2] as CHAR) as tokenTo,
    amounts[1] as tokenFromAmount,
    amounts[2] as tokenToAmount,
    transaction_type
FROM xfi_test.dex_trades

Visualization Configuration

  1. Visualization Config: Select the chart type and configure the axes and parameters.

  2. Publish: Publish your dashboard to make it available externally.

API Access and Integration

The Data Warehouse API allows you to access and manipulate data programmatically.

Using the API

Example API Request

curlCopy codecurl -X POST 'http://warehouse-api.xfi.ms/wh/xfi_addresses_interaction?api_key=YOUR_API_KEY' -H 'Content-Type: application/json' --data '{"parameters": {"dates":"d_last_month"}}'
javascriptCopy codefetch("http://warehouse-api.xfi.ms/wh/xfi_addresses_interaction?api_key=YOUR_API_KEY", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: '{"parameters": {"dates":"d_last_month"}}'
});

Warehouse API

The Warehouse API provides developers with a robust and scalable solution for managing warehouse operations efficiently.

Key Benefits

  • Scalability: Easily handle increasing data volumes and transaction loads.

  • Efficiency: Automate and optimize warehouse processes.

  • Real-Time Data: Access up-to-date information on inventory levels, order status, and more.

  • Integration: Seamlessly connect with other systems for a unified workflow.

Functionalities

  • Inventory Management: Track and manage stock levels, locations, and movements.

  • Order Processing: Handle order creation, picking, packing, and shipping.

  • Real-Time Updates: Receive real-time notifications and updates.

  • Reporting and Analytics: Generate comprehensive reports and analytics.

To start using the Warehouse API, obtain your API key from developers.warehouseapi.com.

Example Authorization

curlCopy codecurl http://warehouse-api.xfi.ms/v1/inventory?api-key=YOUR_API_KEY
curlCopy codecurl http://warehouse-api.xfi.ms/v1/inventory -H 'api-key: YOUR_API_KEY'

Swap Interface

XFI Swap is a Uniswap V2 fork tailored to support the XFI DeFi ecosystem, designed to enhance liquidity and trading efficiency.

Key Features

  • Token Swaps: Seamlessly swap between different tokens.

  • Pair Creation and Liquidity Adding: Create new trading pairs and add liquidity.

  • Charts and Analytics: Access dedicated charts for trading insights.

Using the Swap Interface

  1. Basic Swap: Perform simple token swaps.

  2. Pair Creation: Create new token pairs and provide liquidity.

  3. Dex.guru Charts: Access charts and analytics for better trading decisions.

Explore the Swap Interface at XFI Swap.

Service Status

Developers can check the status of the XFI services and get fundamental information about the chain at status.xfi.ms.

Key Information

  • Service Status: Real-time updates on the status of various XFI services.

  • Chain Fundamentals: Access fundamental information about the XFI Chain.

Guru Framework

https://github.com/dex-guru/guru-framework

The Guru Framework is an advanced toolkit designed to facilitate the orchestration of complex Web3, Web2, and off-chain processes. It enables developers and startups to build applications that integrate seamlessly across various technological environments. The framework encompasses a Blockchain Business Process Automation (BBPA) Engine, Smart Contracts, a Landing and GUI page, and a unified Telegram bot composer, along with specialized External Workers for non-custodial execution and compute.

Components

BBPA Engine

Located in the engine directory, the BBPA Engine is the cornerstone of the framework, managing the automation and orchestration of blockchain business processes. It allows for efficient integration and management of workflows across Web3 and Web2 infrastructures.

Smart Contracts

The contracts directory houses all the smart contracts used within the Guru Framework. These contracts are crucial for handling operations such as transactions, interactions, and protocol-specific functions, ensuring secure and efficient decentralized application operations.

Landing and GUI Page

Found under the gui directory, this component offers the user interface for the Guru Framework. It provides an intuitive graphical interface for users to easily interact with the underlying systems, facilitating the management and orchestration of complex processes.

External Workers

External Workers are defined in the external_workers directory. These are individual agents that provide non-custodial execution and compute services, enabling secure and decentralized processing without requiring custody of user data or assets.

Telegram Bot Unified Composer

This tool, integrated into the framework, allows developers to create Telegram bots that can control and manage processes within the Guru Framework. It simplifies the development and integration of Telegram as an interactive layer for applications, enhancing user engagement and process management.

Project Structure

guru-framework/ │ ├── contracts/ # Smart contracts for blockchain interactions ├── engine/ # Core BBPA engine for process automation ├── external_workers/ # Individual agents for non-custodial execution and compute ├── gui/ # User interface components └── README.md # This file

Getting Started

To begin using the Guru Framework, clone the repository and follow the setup instructions provided in each component's directory.

git clone https://github.com/your-guru-framework-repo.git
cd guru-framework

Prerequisites

Make sure you have dependencies installed run the framework.

Running the Framework

Each component within the Guru Framework can be operated independently according to the setup instructions provided in their respective directories.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are highly encouraged! Please consult the CONTRIBUTING.md document for details on our code of conduct, and the process for submitting pull requests to the project.

FAQ and Support

For any questions or support, join our Community Discord Server and head to the #api-questions channel.