# Setting Up

#### **Setting Up Your Development Environment**

To start developing on the **XSPACE Protocol**, you need to set up a development environment tailored to interact with the blockchain, deploy smart contracts, and build decentralized applications (dApps). This guide covers the prerequisites, installation steps, and how to connect to the **XSPACE Testnet** for development.

***

### **Prerequisites**

#### **1. Tools and Technologies**

* **Operating System:** Windows, macOS, or Linux.
* **Programming Languages:**
  * **Solidity**: For smart contract development.
  * **JavaScript/TypeScript**: For dApp frontends and blockchain interactions.
* **Development Frameworks:**
  * **Hardhat** (Recommended): A popular Ethereum-compatible development environment.
  * **Truffle**: An alternative for contract compilation, testing, and deployment.
* **Node.js and npm:** Required for managing dependencies and running JavaScript-based tools.

#### **2. Knowledge Requirements**

* Basic understanding of blockchain concepts (e.g., transactions, wallets, smart contracts).
* Familiarity with Ethereum-compatible development tools like Web3.js or Ethers.js.

***

### **Installation Guide**

#### **Step 1: Install Node.js and npm**

Node.js is essential for running JavaScript tools and interacting with blockchain APIs.

1. Check if Node.js is installed:

   ```bash
   node -v
   npm -v
   ```
2. If not installed, download and install Node.js:
   * Visit the [Node.js website](https://nodejs.org/) and download the **LTS version**.
3. Verify installation:

   ```bash
   node -v
   npm -v
   ```

***

#### **Step 2: Install Hardhat**

Hardhat is the recommended tool for developing, testing, and deploying smart contracts on XSPACE.

1. Create a project directory:

   ```bash
   mkdir xspace-dev && cd xspace-dev
   ```
2. Initialize a new Node.js project:

   ```bash
   npm init -y
   ```
3. Install Hardhat:

   ```bash
   npm install --save-dev hardhat
   ```
4. Create a new Hardhat project:

   ```bash
   npx hardhat
   ```

   * Choose **"Create a basic sample project"** when prompted.

***

#### **Step 3: Install XSPACE CLI**

The **XSPACE CLI** is a command-line tool for interacting with the blockchain, managing accounts, and deploying smart contracts.

1. Install globally using npm:

   ```bash
   npm install -g xspace-cli
   ```
2. Verify the installation:

   ```bash
   xspace --version
   ```

***

#### **Step 4: Install Wallet**

You’ll need a wallet to manage GLXYC tokens and interact with smart contracts:

* Recommended: **Metamask** (browser extension or mobile app).

1. Install Metamask from [https://metamask.io](https://metamask.io/).
2. Configure Metamask to connect to the **XSPACE Testnet** (details below).

***

### **Connecting to the XSPACE Testnet**

The **XSPACE Testnet** allows developers to test smart contracts, transactions, and applications in a sandbox environment without using real GLXYC tokens.

#### **Testnet Configuration**

1. **RPC URL:** `https://testnet.xspaceprotocol.io/rpc`
2. **Chain ID:** `80001`
3. **Currency Symbol:** `GLXYC`
4. **Explorer URL:** [https://testnet-explorer.xspaceprotocol.io](https://testnet-explorer.xspace.io/)

***

#### **Step 1: Add the Testnet to Metamask**

1. Open Metamask and go to **Settings > Networks > Add Network**.
2. Enter the following details:
   * **Network Name:** XSPACE Testnet
   * **RPC URL:** `https://testnet.xspaceprotocol.io/rpc`
   * **Chain ID:** `80001`
   * **Symbol:** `GLXYC`
   * **Explorer:** [https://testnet-explorer.xspaceprotocol.io](https://testnet-explorer.xspace.io/)

***

#### **Step 2: Get Testnet GLXYC Tokens**

1. Visit the **Testnet Faucet** to request free GLXYC tokens for testing:\
   [https://testnet-faucet.xspaceprotocol.io](https://testnet-faucet.xspace.io/).
2. Enter your wallet address and request tokens.

***

#### **Step 3: Configure Hardhat for XSPACE Testnet**

Update the `hardhat.config.js` file to include the XSPACE Testnet configuration:

```javascript
require("@nomiclabs/hardhat-waffle");

module.exports = {
  solidity: "0.8.0",
  networks: {
    xspaceTestnet: {
      url: "https://testnet.xspaceprotocol.io/rpc",
      chainId: 80001,
      accounts: ["YOUR_PRIVATE_KEY"]
    }
  }
};
```

Replace `"YOUR_PRIVATE_KEY"` with the private key of your wallet.

***

#### **Step 4: Deploy a Smart Contract**

1. Create a new Solidity contract in the `contracts` folder, e.g., `HelloXSPACE.sol`:

   ```solidity
   pragma solidity ^0.8.0;

   contract HelloXSPACE {
       string public message = "Hello, XSPACE!";
   }
   ```
2. Write a deployment script in the `scripts` folder, e.g., `deploy.js`:

   ```javascript
   async function main() {
       const HelloXSPACE = await ethers.getContractFactory("HelloXSPACE");
       const contract = await HelloXSPACE.deploy();
       console.log("Contract deployed to:", contract.address);
   }
   main().catch((error) => {
       console.error(error);
       process.exitCode = 1;
   });
   ```
3. Deploy the contract:

   ```bash
   npx hardhat run scripts/deploy.js --network xspaceTestnet
   ```
4. Verify deployment:
   * Check the contract address in the **XSPACE Testnet Explorer**.

***

#### **Step 5: Interact with the Contract**

Use Hardhat to call functions in your deployed contract:

1. Open a Node.js REPL:

   ```bash
   npx hardhat console --network xspaceTestnet
   ```
2. Load your contract:

   ```javascript
   const contract = await ethers.getContractAt("HelloXSPACE", "DEPLOYED_CONTRACT_ADDRESS");
   const message = await contract.message();
   console.log(message); // Outputs: Hello, XSPACE!
   ```

***

#### **Next Steps**

* Experiment with deploying and interacting with more complex smart contracts.
* Build dApps using Web3.js or Ethers.js to connect to the XSPACE blockchain.
* Explore staking, tokenization, and DeFi integrations using the XSPACE CLI and SDK.

This comprehensive setup ensures you’re ready to start building on XSPACE.&#x20;


---

# 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/setting-up.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.
