> ## 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.

> [!NOTE]
>
> HyperPaxeer Chain ID: **125**

## 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

**1. 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

**2. Configure Network**

Add HyperPaxeer to your configuration:

> [tab] 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] 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}" }
> ```

**3. 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;
    }
}
```

**4. Test Locally**

Test with your framework's local network:

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

# Foundry
forge test
```

**5. 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
```

**6. 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
```

## 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] [Hardhat Documentation](https://hardhat.org/docs)
>
> Complete Hardhat guides and reference

***

### 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] [Foundry Documentation](https://book.getfoundry.sh)
>
> The Foundry Book

***

### 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

> [accordion] Use Provided EVM for Development
>
> 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] Test Thoroughly Before Deploying
>
> 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] Verify Your Contracts
>
> 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] Gas Optimization
>
> 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] Error Handling
>
> 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);
>   }
> }
> ```

## Differences from Ethereum

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

> [accordion] Block Time
>
> * **Ethereum:** \~12 seconds
> * **HyperPaxeer:** 277 ms average
>
> Impact: Faster confirmations, more frequent events

> [accordion] Gas Costs
>
> * **Ethereum:** High (varies widely)
> * **HyperPaxeer:** Very low (99%+ cheaper)
>
> Impact: More economical to run complex operations

> [accordion] Opcodes
>
> All standard EVM opcodes are supported. HyperPaxeer is fully EVM equivalent.

## 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

> [card] [Hardhat](https://hardhat.org)
>
> Most popular Ethereum development framework

> [card] [Foundry](https://getfoundry.sh)
>
> Fast, modern Ethereum toolkit

> [card] [Remix](https://remix.ethereum.org)
>
> Browser-based Solidity IDE

> [card] [OpenZeppelin](https://openzeppelin.com/contracts)
>
> Secure contract libraries

## 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

> [tab] 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] 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] 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);
>   });
> });
> ```

## 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

### Common Vulnerabilities

> [accordion] Reentrancy
>
> 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] Integer Overflow
>
> 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] Access Control
>
> 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
>     }
> }
> ```

## Resources & Tools

> [card] [Block Explorer](https://paxscan.io)
>
> Verify contracts and track transactions

> [card] [Faucet](https://faucet.paxeer.app)
>
> Get test HPX tokens

> [card] [Gas Tracker](https://paxscan.io/gas-tracker)
>
> Monitor current gas prices

## Example Projects

> [card] [Starter Kit](https://github.com/paxeer/starter-kit)
>
> Complete dApp starter template

> [card] [Token Example](https://github.com/paxeer/token-example)
>
> ERC-20 token implementation

> [card] [NFT Example](https://github.com/paxeer/nft-example)
>
> ERC-721 NFT implementation

> [card] [DeFi Example](https://github.com/paxeer/defi-example)
>
> DeFi protocol integration

## Next Steps

> [card] [Testing Apps](https://sidiorresearchlabs.mintlify.site/app-developers/guides/testing-apps.md)
>
> Learn testing best practices

> [card] [Transaction Guides](https://sidiorresearchlabs.mintlify.site/app-developers/guides/transactions/fees.md)
>
> Master transaction handling

> [card] [Examples](https://sidiorresearchlabs.mintlify.site/examples.md)
>
> View complete code examples

> [card] [Tools](https://sidiorresearchlabs.mintlify.site/tools.md)
>
> Explore development tools


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.