# Developer Docs

#### **XSPACE Protocol Developer Documentation**

This comprehensive guide provides developers with everything they need to build on the **XSPACE Protocol**, from understanding the architecture to deploying and interacting with smart contracts. This document is structured to be hosted on **GitBook** for accessibility and ongoing updates.

***

### **Table of Contents**

1. **Introduction**
   * Overview of XSPACE Protocol
   * Key Features for Developers
   * Getting Started
2. **Architecture Overview**
   * Blockchain Design and Consensus (DPoS 2.0 + Sharding)
   * Scalability Features
   * Cross-Chain Interoperability
3. **Setting Up Your Development Environment**
   * Prerequisites
   * Installation Guide
   * Connecting to the Testnet
4. **Smart Contract Development**
   * Overview of XSPACE Smart Contracts
   * Deploying Contracts
   * Interacting with Contracts
5. **Tokenization Framework**
   * XATS (XSPACE Asset Tokenization Standard)
   * Creating and Managing Tokenized Assets
6. **Staking and Validator Setup**
   * Setting Up a Validator Node
   * Delegating GLXYC Tokens
7. **Decentralized Finance (DeFi) Development**
   * Launching dApps on XSPACE
   * Integrating with VALDA DEX and Liquidity Pools
8. **Galaxy City Integration**
   * Developing Applications for Galaxy City
   * Integrating Urban Infrastructure
9. **API and SDK Documentation**
   * REST APIs
   * Web3 Integration
   * XSPACE SDK
10. **Governance and DAO Development**
    * Building Governance dApps
    * Voting Mechanisms and Proposals
11. **Advanced Topics**
    * zk-SNARKs and Privacy Features
    * Optimizing Gas Fees
    * Cross-Chain Interactions
12. **FAQs and Troubleshooting**
13. **Community and Support**
    * Developer Grants
    * Contribution Guidelines
    * Getting Help

***

### **1. Introduction**

#### **What is XSPACE Protocol?**

The **XSPACE Protocol** is a blockchain designed for **real-world asset (RWA) tokenization**, decentralized finance (DeFi), and smart city integration. It uses a sharded architecture and **Delegated Proof-of-Stake 2.0 (DPoS 2.0)** to provide high scalability, low transaction costs, and energy efficiency.

#### **Key Features for Developers**

* **Sharded Architecture:** Supports up to 50,000 TPS, enabling high-throughput applications.
* **EVM Compatibility:** Deploy Ethereum-compatible smart contracts with minimal modifications.
* **Cross-Chain Bridges:** Interact with other blockchains like Ethereum and Solana.
* **XATS Framework:** Standardized tools for creating and managing tokenized real-world assets.

***

### **2. Architecture Overview**

#### **Blockchain Design**

* **Consensus Mechanism:**\
  XSPACE uses **Delegated Proof-of-Stake 2.0 (DPoS 2.0)**, combining validator staking and Byzantine Fault Tolerance (BFT) for fast and secure transactions.
* **Sharded Network:**\
  The network is divided into **shards**, each processing transactions independently. A **Beacon Chain** ensures cross-shard communication and consistency.

#### **Cross-Chain Interoperability**

* **Bridges:**\
  Bridges enable seamless interaction between XSPACE and external chains like Ethereum and Binance Smart Chain.
* **Use Cases:**
  * Transfer GLXYC and tokenized assets across chains.
  * Access liquidity from other DeFi ecosystems.

***

### **3. Setting Up Your Development Environment**

#### **Prerequisites**

* **Languages:** Solidity for smart contracts; JavaScript/TypeScript for dApp development.
* **Tools:** Node.js, Hardhat, or Truffle.

#### **Installation Steps**

1. **Install Node.js:**

   ```bash
   sudo apt install nodejs
   ```
2. **Install XSPACE CLI:**

   ```bash
   npm install -g xspace-cli
   ```
3. **Connect to Testnet:**\
   Configure your environment to connect to the Testnet RPC endpoint.

#### **Testnet Configuration**

* **RPC Endpoint:** `https://testnet.xspace.io/rpc`
* **Chain ID:** `80001`

***

### **4. Smart Contract Development**

#### **Deploying Smart Contracts**

1. **Create a Contract:**\
   Use Solidity to write a basic contract:

   ```solidity
   pragma solidity ^0.8.0;

   contract HelloXSPACE {
       string public message = "Hello, XSPACE!";
   }
   ```
2. **Deploy Using Hardhat:**

   ```bash
   npx hardhat run scripts/deploy.js --network testnet
   ```
3. **Verify Deployment:**\
   Use the XSPACE block explorer to verify your contract.

***

### **5. Tokenization Framework**

#### **XATS Overview**

The **XSPACE Asset Tokenization Standard (XATS)** is a framework for creating and managing tokenized real-world assets.

#### **Creating a Tokenized Asset**

1. **Mint Asset Tokens:**\
   Use the XATS factory contract to tokenize an asset (e.g., property or gold).

   ```solidity
   function mintAsset(string memory metadataURI) public returns (uint256);
   ```
2. **Asset Metadata:**\
   Attach metadata (e.g., asset ownership, value, and location) using IPFS.

***

### **6. Staking and Validator Setup**

#### **Setting Up a Validator Node**

1. **Install the Validator Software:**

   ```bash
   wget https://xspace.io/validator-node
   ```
2. **Stake GLXYC Tokens:**\
   Validators must stake a minimum of **10,000 GLXYC** to activate their node.

***

### **7. Decentralized Finance (DeFi) Development**

#### **Integrating VALDA DEX**

* **Liquidity Pools:** Create or join pools to provide liquidity for GLXYC and tokenized assets.
* **Trading:** Use the VALDA DEX SDK to integrate trading functionalities into your dApp.

***

### **8. Galaxy City Integration**

#### **Developing for Galaxy City**

* Build dApps for urban services like utility payments, smart parking, and energy trading.
* Example:\
  Use GLXYC tokens for electricity billing in Galaxy City.

***

### **9. API and SDK Documentation**

#### **REST API**

* **Endpoint:** `https://api.xspace.io`
* **Functions:**
  * Get account balance: `GET /account/{address}`
  * Query transactions: `GET /transactions/{txHash}`

#### **SDK**

* Install SDK:

  ```bash
  npm install @xspace/sdk
  ```
* Example Usage:

  ```javascript
  const xspace = require('@xspace/sdk');
  const balance = await xspace.getBalance('0xYourAddress');
  ```

***

### **10. Governance and DAO Development**

#### **Voting Mechanisms**

* Use pre-built DAO frameworks to enable token-based voting for proposals.
* Example: Deploy a governance dApp using the XSPACE SDK.

***

### **11. Advanced Topics**

#### **zk-SNARKs and Privacy**

Leverage zk-SNARKs for privacy-preserving transactions and proof generation.

***

### **12. Community and Support**

#### **Developer Grants**

Apply for grants to fund innovative dApps and integrations.

#### **Contribution Guidelines**

Open-source contributions are welcome. Submit pull requests on GitHub for review.

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xspaceprotocol.io/getting-started/developer-docs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
