Quick Start Guide for Developers at XFI Hackathon

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.

Authorization

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.

FAQ and Support

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

Last updated