> ## Documentation Index
> Fetch the complete documentation index at: https://sidiorresearchlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Building Apps on HyperPaxeer

> Learn the basics of building applications on HyperPaxeer

## Overview

This guide explains the basics of HyperPaxeer development. HyperPaxeer is [EVM equivalent](https://web.archive.org/web/20231127160757/https://medium.com/ethereum-optimism/introducing-evm-equivalence-5c2021deb306), meaning it runs the same EVM as Ethereum. Therefore, the differences between Paxeer development and Ethereum development are minimal.

<Info>
  HyperPaxeer Chain ID: **125**
</Info>

## HyperPaxeer Endpoints

To access HyperPaxeer, you need an RPC endpoint:

```
https://public-rpc.paxeer.app/rpc
```

### Network Information

| Parameter      | Value                                                                  |
| -------------- | ---------------------------------------------------------------------- |
| Network Name   | HyperPaxeer                                                            |
| Chain ID       | 125                                                                    |
| Currency       | HPX                                                                    |
| RPC URL        | [https://public-rpc.paxeer.app/rpc](https://public-rpc.paxeer.app/rpc) |
| Block Explorer | [https://paxscan.io](https://paxscan.io)                               |

## Development Workflow

<Steps>
  <Step title="Set Up Your Environment">
    Choose your development framework:

    * [Hardhat](https://hardhat.org/) - Most popular, great for testing
    * [Foundry](https://getfoundry.sh/) - Fast, Solidity-native testing
    * [Remix](https://remix.ethereum.org/) - Browser-based, no setup
  </Step>

  <Step title="Configure Network">
    Add HyperPaxeer to your configuration:

    <Tabs>
      <Tab title="Hardhat">
        ```javascript hardhat.config.js theme={null}
        require("@nomicfoundation/hardhat-toolbox");
        require('dotenv').config();

        module.exports = {
          solidity: "0.8.20",
          networks: {
            paxeer: {
              url: "https://public-rpc.paxeer.app/rpc",
              chainId: 125,
              accounts: [process.env.PRIVATE_KEY],
            },
          },
        };
        ```
      </Tab>

      <Tab title="Foundry">
        ```toml foundry.toml theme={null}
        [profile.default]
        src = "src"
        out = "out"
        libs = ["lib"]
        solc_version = "0.8.20"

        [rpc_endpoints]
        paxeer = "https://public-rpc.paxeer.app/rpc"

        [etherscan]
        paxeer = { key = "${ETHERSCAN_API_KEY}" }
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Write Smart Contracts">
    Write Solidity contracts as you would for Ethereum:

    ```solidity contracts/MyContract.sol theme={null}
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.20;

    contract MyContract {
        uint256 public value;
        
        event ValueChanged(uint256 newValue);
        
        function setValue(uint256 _value) external {
            value = _value;
            emit ValueChanged(_value);
        }
        
        function getValue() external view returns (uint256) {
            return value;
        }
    }
    ```
  </Step>

  <Step title="Test Locally">
    Test with your framework's local network:

    ```bash theme={null}
    # Hardhat
    npx hardhat test

    # Foundry
    forge test
    ```
  </Step>

  <Step title="Deploy to Paxeer">
    Deploy to HyperPaxeer:

    ```bash theme={null}
    # Hardhat
    npx hardhat run scripts/deploy.js --network paxeer

    # Foundry
    forge create src/MyContract.sol:MyContract \
      --rpc-url https://public-rpc.paxeer.app/rpc \
      --private-key $PRIVATE_KEY
    ```
  </Step>

  <Step title="Verify Contract">
    Verify your contract on PaxScan:

    ```bash theme={null}
    # Hardhat
    npx hardhat verify --network paxeer DEPLOYED_ADDRESS

    # Foundry
    forge verify-contract DEPLOYED_ADDRESS \
      src/MyContract.sol:MyContract \
      --chain-id 125 \
      --watch
    ```
  </Step>
</Steps>

## Development Frameworks

### Hardhat

Industry-standard Ethereum development environment with excellent testing framework.

```bash Installation theme={null}
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init
```

**Key Features:**

* Built-in testing with Mocha & Chai
* Console.log debugging in Solidity
* Mainnet forking
* TypeScript support
* Plugin ecosystem

<Card title="Hardhat Documentation" icon="book" href="https://hardhat.org/docs">
  Complete Hardhat guides and reference
</Card>

***

### Foundry

Blazing fast Ethereum toolkit written in Rust with Solidity-based testing.

```bash Installation theme={null}
curl -L https://foundry.paradigm.xyz | bash
foundryup
```

**Key Features:**

* Extremely fast test execution
* Solidity-native tests
* Fuzzing support
* Gas snapshots
* Fork testing

<Card title="Foundry Documentation" icon="book" href="https://book.getfoundry.sh">
  The Foundry Book
</Card>

***

### Remix IDE

Browser-based IDE for quick prototyping and learning.

**Access:** [remix.ethereum.org](https://remix.ethereum.org)

**Key Features:**

* No installation required
* Visual debugger
* Built-in compiler
* Direct MetaMask integration
* Plugin support

## Interacting with Contracts

### Using ethers.js

```javascript theme={null}
import { ethers } from 'ethers';

const provider = new ethers.JsonRpcProvider('https://public-rpc.paxeer.app/rpc');
const signer = await provider.getSigner();

// Deploy contract
const MyContract = await ethers.getContractFactory('MyContract');
const contract = await MyContract.deploy();
await contract.waitForDeployment();
console.log('Deployed to:', await contract.getAddress());

// Interact with deployed contract
const contractAddress = '0x...';
const myContract = new ethers.Contract(contractAddress, ABI, signer);

// Read
const value = await myContract.getValue();

// Write
const tx = await myContract.setValue(42);
await tx.wait();
```

### Using wagmi (React)

```typescript theme={null}
import { useReadContract, useWriteContract } from 'wagmi';

function MyComponent() {
  // Read contract
  const { data: value } = useReadContract({
    address: '0x...',
    abi: contractABI,
    functionName: 'getValue',
  });

  // Write contract
  const { writeContract } = useWriteContract();

  function setValue(newValue: number) {
    writeContract({
      address: '0x...',
      abi: contractABI,
      functionName: 'setValue',
      args: [newValue],
    });
  }

  return (
    <div>
      <p>Current value: {value?.toString()}</p>
      <button onClick={() => setValue(42)}>Set Value</button>
    </div>
  );
}
```

## Best Practices

<AccordionGroup>
  <Accordion title="Use Provided EVM for Development" icon="laptop-code">
    Start with your framework's local network for fastest iteration:

    ```bash theme={null}
    # Hardhat local network
    npx hardhat node

    # Foundry local network
    anvil
    ```

    Benefits:

    * Instant mining
    * Console logging
    * Easy debugging
    * Free testing
  </Accordion>

  <Accordion title="Test Thoroughly Before Deploying" icon="flask">
    Follow this testing progression:

    1. **Local network** - Fast iteration, rich debugging
    2. **Private fork or staging stack** - Realistic integration conditions
    3. **Mainnet** - Production deployment

    ```javascript theme={null}
    // Example test
    describe("MyContract", function () {
      it("Should set and get value", async function () {
        const MyContract = await ethers.getContractFactory("MyContract");
        const contract = await MyContract.deploy();
        
        await contract.setValue(42);
        expect(await contract.getValue()).to.equal(42);
      });
    });
    ```
  </Accordion>

  <Accordion title="Verify Your Contracts" icon="badge-check">
    Always verify contracts on PaxScan:

    Benefits:

    * Users can read contract source
    * Direct interaction from explorer
    * Builds trust
    * Easier debugging

    ```bash theme={null}
    npx hardhat verify --network paxeer DEPLOYED_ADDRESS [CONSTRUCTOR_ARGS]
    ```
  </Accordion>

  <Accordion title="Gas Optimization" icon="gauge">
    Optimize contract gas usage:

    ```solidity theme={null}
    // Use appropriate data types
    uint128 instead of uint256 when possible

    // Pack storage variables
    struct Packed {
        uint128 a;  // 16 bytes
        uint128 b;  // 16 bytes
    }               // = 1 storage slot

    // Use events for data storage
    emit DataStored(data); // Cheaper than storage

    // Cache storage reads
    uint256 cached = storageVar; // Read once
    // Use cached value multiple times
    ```
  </Accordion>

  <Accordion title="Error Handling" icon="triangle-exclamation">
    Implement comprehensive error handling:

    ```javascript theme={null}
    try {
      const tx = await contract.setValue(42);
      const receipt = await tx.wait();
      
      if (receipt.status === 0) {
        console.error('Transaction failed');
        // Handle failure
      }
    } catch (error) {
      if (error.code === 'ACTION_REJECTED') {
        console.log('User rejected transaction');
      } else if (error.code === 'INSUFFICIENT_FUNDS') {
        console.log('Insufficient balance');
      } else {
        console.error('Transaction error:', error);
      }
    }
    ```
  </Accordion>
</AccordionGroup>

## Differences from Ethereum

While HyperPaxeer is EVM equivalent, there are a few minor differences:

<AccordionGroup>
  <Accordion title="Block Time" icon="clock">
    * **Ethereum:** \~12 seconds
    * **HyperPaxeer:** 277 ms average

    Impact: Faster confirmations, more frequent events
  </Accordion>

  <Accordion title="Gas Costs" icon="gas-pump">
    * **Ethereum:** High (varies widely)
    * **HyperPaxeer:** Very low (99%+ cheaper)

    Impact: More economical to run complex operations
  </Accordion>

  <Accordion title="Opcodes" icon="code">
    All standard EVM opcodes are supported. HyperPaxeer is fully EVM equivalent.
  </Accordion>
</AccordionGroup>

## Contract Examples

### Simple Storage

```solidity SimpleStorage.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract SimpleStorage {
    mapping(address => uint256) private values;
    
    event ValueStored(address indexed user, uint256 value);
    
    function store(uint256 value) external {
        values[msg.sender] = value;
        emit ValueStored(msg.sender, value);
    }
    
    function retrieve() external view returns (uint256) {
        return values[msg.sender];
    }
}
```

### ERC-20 Token

```solidity MyToken.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyToken is ERC20, Ownable {
    constructor() ERC20("MyToken", "MTK") Ownable(msg.sender) {
        _mint(msg.sender, 1000000 * 10 ** decimals());
    }
    
    function mint(address to, uint256 amount) external onlyOwner {
        _mint(to, amount);
    }
}
```

### NFT Contract

```solidity MyNFT.sol theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract MyNFT is ERC721, Ownable {
    uint256 private _tokenIdCounter;
    
    constructor() ERC721("MyNFT", "MNFT") Ownable(msg.sender) {}
    
    function mint(address to) external onlyOwner {
        uint256 tokenId = _tokenIdCounter++;
        _safeMint(to, tokenId);
    }
}
```

## Development Tools

<CardGroup cols={2}>
  <Card title="Hardhat" icon="hammer" href="https://hardhat.org">
    Most popular Ethereum development framework
  </Card>

  <Card title="Foundry" icon="anvil" href="https://getfoundry.sh">
    Fast, modern Ethereum toolkit
  </Card>

  <Card title="Remix" icon="browser" href="https://remix.ethereum.org">
    Browser-based Solidity IDE
  </Card>

  <Card title="OpenZeppelin" icon="shield" href="https://openzeppelin.com/contracts">
    Secure contract libraries
  </Card>
</CardGroup>

## Frontend Integration

### Next.js + wagmi Template

```typescript app/page.tsx theme={null}
'use client'

import { useAccount, useConnect, useReadContract } from 'wagmi'

export default function Home() {
  const { address, isConnected } = useAccount()
  const { connect, connectors } = useConnect()

  const { data: value } = useReadContract({
    address: '0xYourContractAddress',
    abi: contractABI,
    functionName: 'getValue',
  })

  if (!isConnected) {
    return (
      <div>
        {connectors.map((connector) => (
          <button
            key={connector.id}
            onClick={() => connect({ connector })}
          >
            Connect {connector.name}
          </button>
        ))}
      </div>
    )
  }

  return (
    <div>
      <p>Connected: {address}</p>
      <p>Contract Value: {value?.toString()}</p>
    </div>
  )
}
```

## Testing Strategies

<Tabs>
  <Tab title="Unit Tests">
    Test individual contract functions:

    ```javascript test/MyContract.test.js theme={null}
    const { expect } = require("chai");
    const { ethers } = require("hardhat");

    describe("MyContract", function () {
      let contract;
      let owner;

      beforeEach(async function () {
        [owner] = await ethers.getSigners();
        const MyContract = await ethers.getContractFactory("MyContract");
        contract = await MyContract.deploy();
      });

      it("Should set and get value", async function () {
        await contract.setValue(42);
        expect(await contract.getValue()).to.equal(42);
      });

      it("Should emit event", async function () {
        await expect(contract.setValue(42))
          .to.emit(contract, "ValueChanged")
          .withArgs(42);
      });
    });
    ```
  </Tab>

  <Tab title="Integration Tests">
    Test interactions between contracts:

    ```javascript theme={null}
    describe("Token Integration", function () {
      let token, vault;

      beforeEach(async function () {
        // Deploy contracts
        const Token = await ethers.getContractFactory("MyToken");
        token = await Token.deploy();
        
        const Vault = await ethers.getContractFactory("Vault");
        vault = await Vault.deploy(await token.getAddress());
      });

      it("Should deposit tokens to vault", async function () {
        const amount = ethers.parseEther("100");
        
        // Approve
        await token.approve(await vault.getAddress(), amount);
        
        // Deposit
        await vault.deposit(amount);
        
        // Verify
        expect(await vault.balances(owner.address)).to.equal(amount);
      });
    });
    ```
  </Tab>

  <Tab title="Mainnet Fork">
    Test against real deployed contracts:

    ```javascript hardhat.config.js theme={null}
    networks: {
      hardhat: {
        forking: {
          url: "https://public-rpc.paxeer.app/rpc",
          blockNumber: 1000000, // Optional: pin to specific block
        },
      },
    }
    ```

    ```javascript theme={null}
    // Test against real contracts
    describe("Mainnet Fork Tests", function () {
      it("Should interact with deployed PaxDex", async function () {
        const vault = await ethers.getContractAt(
          "PaxDexVault",
          "0x49B0f9a0554da1A7243A9C8ac5B45245A66D90ff"
        );
        
        // Test interaction
        const price = await vault.getPrice(tokenAddress);
        console.log("Token price:", price);
      });
    });
    ```
  </Tab>
</Tabs>

## Security Considerations

<Warning>
  **Security Checklist:**

  * [ ] Use latest Solidity version (0.8.20+)
  * [ ] Import from OpenZeppelin for standards
  * [ ] Implement access control
  * [ ] Validate all inputs
  * [ ] Use SafeMath (built-in 0.8+)
  * [ ] Check for reentrancy vulnerabilities
  * [ ] Test edge cases
  * [ ] Get professional audit for high-value contracts
</Warning>

### Common Vulnerabilities

<AccordionGroup>
  <Accordion title="Reentrancy" icon="arrows-rotate">
    Use checks-effects-interactions pattern:

    ```solidity theme={null}
    function withdraw(uint256 amount) external {
        // Checks
        require(balances[msg.sender] >= amount, "Insufficient balance");
        
        // Effects
        balances[msg.sender] -= amount;
        
        // Interactions
        (bool success, ) = msg.sender.call{value: amount}("");
        require(success, "Transfer failed");
    }
    ```

    Or use OpenZeppelin's ReentrancyGuard:

    ```solidity theme={null}
    import "@openzeppelin/contracts/security/ReentrancyGuard.sol";

    contract Safe is ReentrancyGuard {
        function withdraw() external nonReentrant {
            // Protected from reentrancy
        }
    }
    ```
  </Accordion>

  <Accordion title="Integer Overflow" icon="infinity">
    Solidity 0.8+ has built-in overflow protection:

    ```solidity theme={null}
    // Automatically safe in 0.8+
    uint256 a = 100;
    uint256 b = 200;
    uint256 c = a + b; // Can't overflow
    ```

    For unchecked operations:

    ```solidity theme={null}
    unchecked {
        // Only use when you're certain it's safe
        counter++;
    }
    ```
  </Accordion>

  <Accordion title="Access Control" icon="lock">
    Properly restrict sensitive functions:

    ```solidity theme={null}
    import "@openzeppelin/contracts/access/Ownable.sol";

    contract MyContract is Ownable {
        constructor() Ownable(msg.sender) {}
        
        function adminFunction() external onlyOwner {
            // Only owner can call
        }
    }
    ```
  </Accordion>
</AccordionGroup>

## Resources & Tools

<CardGroup cols={3}>
  <Card title="Block Explorer" icon="magnifying-glass" href="https://paxscan.io">
    Verify contracts and track transactions
  </Card>

  <Card title="Faucet" icon="faucet" href="https://faucet.paxeer.app">
    Get test HPX tokens
  </Card>

  <Card title="Gas Tracker" icon="gas-pump" href="https://paxscan.io/gas-tracker">
    Monitor current gas prices
  </Card>
</CardGroup>

## Example Projects

<CardGroup cols={2}>
  <Card title="Starter Kit" icon="rocket" href="https://github.com/paxeer/starter-kit">
    Complete dApp starter template
  </Card>

  <Card title="Token Example" icon="coins" href="https://github.com/paxeer/token-example">
    ERC-20 token implementation
  </Card>

  <Card title="NFT Example" icon="image" href="https://github.com/paxeer/nft-example">
    ERC-721 NFT implementation
  </Card>

  <Card title="DeFi Example" icon="chart-line" href="https://github.com/paxeer/defi-example">
    DeFi protocol integration
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Testing Apps" icon="flask" href="/app-developers/guides/testing-apps">
    Learn testing best practices
  </Card>

  <Card title="Transaction Guides" icon="book" href="/app-developers/guides/transactions/fees">
    Master transaction handling
  </Card>

  <Card title="Examples" icon="code" href="/examples">
    View complete code examples
  </Card>

  <Card title="Tools" icon="toolbox" href="/tools">
    Explore development tools
  </Card>
</CardGroup>
