# Tokenization Framework

#### **Tokenization Framework**

The **XSPACE Asset Tokenization Standard (XATS)** is a powerful framework designed to simplify the process of tokenizing real-world assets (RWAs) on the **XSPACE Protocol**. It enables developers, businesses, and asset owners to create, manage, and trade tokenized representations of physical and financial assets, providing transparency, liquidity, and fractional ownership.

***

### **XATS: XSPACE Asset Tokenization Standard**

#### **Overview of XATS**

XATS is the backbone of tokenization on the XSPACE Protocol. It ensures uniformity and interoperability for all tokenized assets within the ecosystem.

**Key Features**

1. **Compliance-Ready**:
   * Built-in support for Know Your Customer (KYC) and Anti-Money Laundering (AML) compliance.
   * Customizable token rules to comply with jurisdiction-specific regulations.
2. **Metadata Standards**:
   * Integrates detailed metadata, including ownership, valuation, and asset-specific attributes.
   * Supports off-chain metadata storage using IPFS for large datasets.
3. **Interoperability**:
   * Compatible with Ethereum standards like ERC-20, ERC-721, and ERC-1155.
   * Facilitates cross-chain trading via XSPACE bridges.
4. **Fractional Ownership**:
   * Tokenize large assets (e.g., real estate) into smaller units, enabling fractional investment and ownership.
5. **Automated Income Distribution**:
   * Smart contracts automate dividend and rental income payouts to token holders.

***

#### **Token Standards in XATS**

XATS supports multiple token standards based on asset type and use case:

**1. XATS-20 (Fungible Tokens)**

* Designed for commodities, currencies, and divisible financial instruments.
* Example: Tokenizing 1 kilogram of gold into 1,000 fungible tokens.

**2. XATS-721 (Non-Fungible Tokens)**

* For unique assets such as real estate, luxury items, and art.
* Example: Tokenizing a specific property deed or a rare diamond.

**3. XATS-1155 (Hybrid Tokens)**

* Combines fungible and non-fungible attributes, ideal for tokenizing assets like portfolios or bundles.
* Example: Tokenizing a real estate fund with unique properties and shared investment pools.

***

### **Creating Tokenized Assets**

#### **Step 1: Deploy the XATS Factory Contract**

The XATS framework includes a pre-built factory contract to streamline token creation.

**Factory Contract Features**

* **Minting Tokens**: Create fungible or non-fungible tokens linked to real-world assets.
* **Metadata Attachment**: Add descriptive information (e.g., location, valuation) via IPFS.
* **Ownership Management**: Define initial ownership and transfer rights.

**Deployment Example (Solidity)**

```solidity
pragma solidity ^0.8.0;

contract XATSFactory {
    event TokenCreated(address indexed owner, address tokenAddress);

    function createFungibleToken(string memory name, string memory symbol, uint256 supply) public returns (address) {
        address token = address(new FungibleToken(name, symbol, supply, msg.sender));
        emit TokenCreated(msg.sender, token);
        return token;
    }
}

contract FungibleToken {
    string public name;
    string public symbol;
    uint256 public totalSupply;
    mapping(address => uint256) public balanceOf;

    constructor(string memory _name, string memory _symbol, uint256 _supply, address _owner) {
        name = _name;
        symbol = _symbol;
        totalSupply = _supply;
        balanceOf[_owner] = _supply;
    }
}
```

***

#### **Step 2: Attach Metadata**

Use **IPFS** to store off-chain metadata for tokenized assets, such as property details, certifications, or appraisal reports.

**Upload Metadata to IPFS**

1. Install IPFS:

   ```bash
   npm install ipfs-http-client
   ```
2. Upload metadata:

   ```javascript
   const IPFS = require('ipfs-http-client');
   const ipfs = IPFS.create({ host: 'ipfs.infura.io', port: 5001, protocol: 'https' });

   const metadata = {
       name: "Luxury Apartment",
       location: "123 Blockchain Street",
       valuation: "$500,000"
   };

   const result = await ipfs.add(JSON.stringify(metadata));
   console.log("IPFS Hash:", result.path);
   ```
3. Store the returned **IPFS hash** in your smart contract for asset reference.

***

#### **Step 3: Mint and Distribute Tokens**

Mint tokens representing fractional ownership or other rights related to the asset.

**Minting Example (Solidity)**

```solidity
function mint(address to, uint256 amount) public {
    require(msg.sender == owner, "Only owner can mint tokens");
    balanceOf[to] += amount;
    totalSupply += amount;
}
```

***

#### **Step 4: Enable Automated Income Distribution**

Automate revenue distribution (e.g., rental income or dividends) to token holders using smart contracts.

**Example Distribution Logic**

```solidity
function distributeIncome() public payable {
    uint256 total = address(this).balance;
    for (uint256 i = 0; i < tokenHolders.length; i++) {
        address holder = tokenHolders[i];
        uint256 share = (balanceOf[holder] * total) / totalSupply;
        payable(holder).transfer(share);
    }
}
```

***

### **Managing Tokenized Assets**

#### **Ownership Transfers**

Use smart contracts to enable secure and transparent ownership transfers.

**Transfer Example**

```solidity
function transfer(address to, uint256 amount) public {
    require(balanceOf[msg.sender] >= amount, "Insufficient balance");
    balanceOf[msg.sender] -= amount;
    balanceOf[to] += amount;
}
```

#### **Compliance Enforcement**

XATS includes built-in compliance checks:

* **KYC/AML Enforcement**: Restrict transfers to whitelisted addresses.
* **Geofencing**: Restrict token access based on geographic rules.

**Whitelist Example**

```solidity
mapping(address => bool) public whitelist;

function addToWhitelist(address account) public {
    require(msg.sender == owner, "Only owner can whitelist");
    whitelist[account] = true;
}
function transfer(address to, uint256 amount) public {
    require(whitelist[to], "Recipient is not whitelisted");
    // Transfer logic here
}
```

***

### **API and SDK Integration for Tokenized Assets**

XSPACE provides an SDK and REST APIs to simplify interaction with tokenized assets.

#### **SDK Example**

Install the XSPACE SDK:

```bash
npm install @xspace/sdk
```

Use the SDK to query tokenized asset details:

```javascript
const XSPACE = require('@xspace/sdk');
const asset = await XSPACE.getTokenDetails("TOKEN_ADDRESS");
console.log(asset);
```

#### **REST API**

* **Endpoint:** `https://api.xspaceprotocol.io`
* **Functions:**
  * Query asset details: `GET /assets/{tokenAddress}`
  * Retrieve metadata: `GET /assets/{tokenAddress}/metadata`

***

This tokenization framework provides the foundation for developers to create, manage, and trade tokenized assets seamlessly on the XSPACE Protocol. With compliance-ready tools and high interoperability, XATS ensures that real-world assets are securely and transparently brought on-chain.


---

# 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/tokenization-framework.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.
