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

# Smart Contracts

> Deploy, verify, and interact with Solidity contracts on HyperPaxeer

> [!NOTE]
>
> HyperPaxeer is fully EVM-compatible. Running on the **Alexandria Fork** with **Hyperpax-OS Cronos**, all standard Ethereum tooling works — Foundry, Hardhat, Remix, ethers.js, wagmi, and viem. Use `--legacy --slow` flags with Foundry for reliable transaction inclusion.

## Overview

Deploy and interact with smart contracts on HyperPaxeer (Chain ID `125`). Foundry is the recommended framework; Hardhat and Remix are also supported.

## Deployment Options

> [tab] Hardhat
>
> ### Deploy with Hardhat
>
> Configure Hardhat to deploy on HyperPaxeer.
>
> #### 1. Install dependencies
>
> ```bash theme={null}
> npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
> ```
>
> #### 2. Configure hardhat.config.js
>
> ```javascript hardhat.config.js theme={null}
> require("@nomicfoundation/hardhat-toolbox");
>
> module.exports = {
>   solidity: "0.8.20",
>   networks: {
>     paxeer: {
>       url: "https://public-rpc.paxeer.app/rpc",
>       chainId: 125,
>       accounts: [process.env.PRIVATE_KEY]
>     }
>   },
>   etherscan: {
>     apiKey: {
>       hyperpaxeer: "any-string"
>     },
>     customChains: [
>       {
>         network: "hyperpaxeer",
>         chainId: 125,
>         urls: {
>           apiURL: "https://paxscan.io/api",
>           browserURL: "https://paxscan.io"
>         }
>       }
>     ]
>   }
> };
> ```
>
> #### 3. Deploy
>
> ```bash theme={null}
> npx hardhat run scripts/deploy.js --network hyperpaxeer
> ```
>
> > [!TIP]
> >
> > Store your private key in a `.env` file and never commit it to version control.

> [tab] Foundry
>
> ### Deploy with Foundry
>
> Use Foundry to deploy contracts on HyperPaxeer.
>
> #### 1. Install Foundry
>
> ```bash theme={null}
> curl -L https://foundry.paradigm.xyz | bash
> foundryup
> ```
>
> #### 2. Create project
>
> ```bash theme={null}
> forge init my-project
> cd my-project
> ```
>
> #### 3. Deploy
>
> ```bash theme={null}
> forge create src/MyContract.sol:MyContract \
>   --rpc-url https://public-rpc.paxeer.app/rpc \
>   --private-key $PRIVATE_KEY \
>   --legacy --slow
> ```
>
> > [!TIP]
> >
> > Use `--verify` flag to verify your contract on PaxScan after deployment.

> [tab] Remix
>
> ### Deploy with Remix
>
> Use Remix IDE to deploy contracts via MetaMask.
>
> **1. Open Remix**
>
> Go to [remix.ethereum.org](https://remix.ethereum.org)
>
> **2. Write or Import Contract**
>
> Write or import your Solidity contract in the file explorer
>
> **3. Compile Contract**
>
> Use the Solidity compiler to compile your contract
>
> **4. Connect MetaMask**
>
> Connect MetaMask to HyperPaxeer (Chain ID: 125)
>
> **5. Select Environment**
>
> In the Deploy & Run tab, select "Injected Provider - MetaMask"
>
> **6. Deploy**
>
> Click "Deploy" and confirm the transaction in MetaMask
>
> > [!NOTE]
> >
> > Make sure your MetaMask is connected to HyperPaxeer (Chain ID 125) before deploying.

## Example Contract

Here's a simple ERC-20 token contract example:

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

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

contract MyToken is ERC20 {
    constructor() ERC20("MyToken", "MTK") {
        _mint(msg.sender, 1000000 * 10 ** decimals());
    }
}
```

### Deploying the Example

> [tab] Hardhat
>
> ```javascript scripts/deploy.js theme={null}
> const hre = require("hardhat");
>
> async function main() {
>   const MyToken = await hre.ethers.getContractFactory("MyToken");
>   const token = await MyToken.deploy();
>   await token.waitForDeployment();
>
>   console.log("MyToken deployed to:", await token.getAddress());
> }
>
> main().catch((error) => {
>   console.error(error);
>   process.exitCode = 1;
> });
> ```
>
> Run the deployment:
>
> ```bash theme={null}
> npx hardhat run scripts/deploy.js --network paxeer
> ```

> [tab] Foundry
>
> ```bash theme={null}
> forge create src/MyToken.sol:MyToken \
>   --rpc-url https://public-rpc.paxeer.app/rpc \
>   --private-key $PRIVATE_KEY \
>   --chain-id 125
> ```

## Verifying Contracts

After deployment, verify your contract on PaxScan for transparency and easier interaction.

### Using Hardhat

```bash theme={null}
npx hardhat verify --network paxeer DEPLOYED_CONTRACT_ADDRESS
```

### Using Foundry

```bash theme={null}
forge verify-contract \
  --chain-id 125 \
  --compiler-version v0.8.20 \
  DEPLOYED_CONTRACT_ADDRESS \
  src/MyToken.sol:MyToken \
  --etherscan-api-key YOUR_API_KEY
```

## 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 contract = new ethers.Contract(
  contractAddress,
  contractABI,
  provider
);

// Read contract data
const balance = await contract.balanceOf(address);

// Write contract data (requires signer)
const signer = await provider.getSigner();
const contractWithSigner = contract.connect(signer);
await contractWithSigner.transfer(recipientAddress, amount);
```

### Using wagmi

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

// Read contract
const { data: balance } = useReadContract({
  address: '0x...',
  abi: tokenABI,
  functionName: 'balanceOf',
  args: [userAddress],
});

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

function transfer() {
  writeContract({
    address: '0x...',
    abi: tokenABI,
    functionName: 'transfer',
    args: [recipientAddress, amount],
  });
}
```

## Best Practices

> [accordion] Gas Optimization
>
> * Use appropriate data types (uint256 vs uint8)
> * Minimize storage writes
> * Use events for logging instead of storage
> * Batch operations when possible

> [accordion] Security
>
> * Use OpenZeppelin contracts for standards
> * Implement access control
> * Validate all inputs
> * Test thoroughly before mainnet deployment
> * Consider getting an audit for critical contracts

> [accordion] Testing
>
> * Write comprehensive unit tests
> * Test locally or on private networks before mainnet
> * Test edge cases and failure scenarios
> * Use fuzzing for complex contracts

## Network Information

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

## Next Steps

> [card] [Configuration](https://sidiorresearchlabs.mintlify.site/configuration.md)
>
> Configure different libraries for HyperPaxeer

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

> [card] [API Reference](https://sidiorresearchlabs.mintlify.site/api-reference)
>
> Explore all available RPC methods

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


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