Skip to content

Mining XPOW ​

Mining XPOW is how new tokens enter circulation — by finding a Keccak-256 nonce that satisfies the protocol's difficulty requirement and submitting it on-chain for verification and reward.

Prerequisites ​

  • A Web3 wallet (MetaMask or WalletConnect-compatible) with ~0.1 AVAX on Avalanche C-Chain for gas
  • For testnet: Fuji network (Chain ID 43113) with test AVAX from the Avalanche faucet
  • Access to the XPower app at app.xpowermine.com, or a direct connection to the XPower contract

How Mining Works ​

The miner computes Keccak-256 over a structured input:

h=keccak256(contractAddr⊕beneficiaryAddr∥blockHash∥nonce)

A valid solution is one where h has z≥1 leading zero nibbles (4-bit hex digits). The reward is:

R(z)=(2z−1)×1018 XPOW

Half goes to the miner's beneficiary address, half to the MoeTreasury to fund staking rewards.

Difficulty zExpected HashesTotal Reward (XPOW)Miner's Share
11610.5
225631.5
3~4,09673.5
4~65,536157.5
5~1,048,5763115.5

Step-by-Step: Browser Mining ​

1. Connect Your Wallet ​

Navigate to app.xpowermine.com and click Connect Wallet. Approve the connection request in MetaMask or your wallet of choice. The app will detect your network — switch to Avalanche C-Chain if prompted.

2. Initialize a Block Hash ​

Before searching for nonces, you must register a recent Avalanche block hash on-chain:

XPower.init()

This call costs gas (~50,000) and starts a 1-hour mining window. The returned block hash becomes the blockHash input for every nonce you test during this window. You only need to call init() once per hour — all nonces within that window hash against the same block hash.

Expired Block Hash

If more than 1 hour passes since your last init(), any submission using that block hash will revert with ExpiredBlockHash. Call init() again to start a fresh window.

3. Find a Valid Nonce ​

The browser miner runs Keccak-256 in a Web Worker, iterating through nonces until it finds one where the hash has at least one leading zero nibble. At ~10,000 hashes/second in a modern browser:

  • A z=1 solution is found in under 2 milliseconds on average
  • A z=4 solution takes ~4–13 seconds
  • A z=5 solution takes ~1–2 minutes

The app shows your hash rate, elapsed time, and expected time to solution. You can stop mining at any time — no state is lost.

4. Submit Your Solution ​

When a valid nonce is found, the app prompts you to submit:

XPower.mint(beneficiary, blockHash, nonceData)

Where:

  • beneficiary is your wallet address (or any address you choose)
  • blockHash is the hash from step 2
  • nonceData is the 32-byte nonce that produced the valid hash

The contract verifies the nonce on-chain, checks that the block hash is still fresh, confirms the (beneficiary, blockHash, pairIndex) tuple hasn't been used before, and mints the reward.

Gas cost for submission: ~150,000 gas (~0.001–0.005 AVAX depending on network conditions).

5. Verify Your Receipt ​

After the transaction confirms:

  1. Check your XPOW balance — you should see reward / 2 XPOW added
  2. View the transaction on SnowTrace (mainnet) or the Fuji explorer
  3. The Mint event in the transaction logs confirms the amount and beneficiary

Alternative Mining Strategies ​

CLI Mining (Node.js) ​

For higher hash rates, run a Node.js miner locally:

bash
# Install dependencies
npm install ethers @noble/hashes

# Run the miner
node mine.js --provider YOUR_RPC_URL --private-key YOUR_KEY

Node.js (V8 engine) achieves ~20,000–50,000 hashes/second, roughly 3–5× faster than browser mining. This is ideal for targeting z=4 or higher solutions.

Native Mining (Rust/C++) ​

For maximum throughput, a native Keccak-256 implementation can reach 500,000+ hashes/second using multi-threading. This is suitable for targeting z=5 or z=6 solutions, where expected hash counts reach into the millions.

Strategy Considerations ​

StrategyBest ForTradeoff
Browser, z=1Casual miners, low gasFrequent transactions eat into profit
Browser, z=3–4Balanced approachModerate wait, good reward/gas ratio
CLI, z=4–5Dedicated minersHigher setup effort, better efficiency
Native, z=6+High-power setupsLarge expected hashes, rare but large rewards

Each (beneficiary, blockHash, nonce) tuple can only be used once — the contract prevents replay attacks. If you find a solution at z=1 but wanted higher, submit it anyway; you can always mine again.

Gas Costs and Profitability ​

ActionGasApprox. AVAX Cost
XPower.init()~50,0000.001–0.002
XPower.mint()~150,0000.003–0.005
Total per solution~200,000~0.004–0.007

Gas Strategy

On Avalanche C-Chain, gas prices are typically 25–50 nAVAX. At 25 nAVAX, a mint() costs ~0.00375 AVAX. The miner's share of a z=1 solution is 0.5 XPOW — profitable when XPOW > 0.0075 AVAX. At z=4, the miner receives 7.5 XPOW with the same gas cost, dramatically improving the reward-to-gas ratio.

What Happens Internally ​

When you call XPower.mint(to, blockHash, data), the contract executes the following sequence:

  1. Freshness check: _recent(blockHash) verifies that the block hash was initialized within the last hour via init(). If the block hash has expired, the call reverts with ExpiredBlockHash.

  2. Nonce reconstruction: The contract recomputes the hash from (address(this) ^ to, blockHash, data). It does not trust your submitted hash — it re-derives it deterministically using the same Keccak-256 formula.

  3. Uniqueness check: The contract computes a pairIndex from your nonce and block hash (keccak(nonce) ^ blockHash). If this pair index was already used, the call reverts with DuplicatePairIndex. This prevents replay attacks — no solution can be submitted twice.

  4. Difficulty check: _zerosOf(nonceHash) counts the leading zero nibbles. If z=0, the call reverts with EmptyNonceHash. The reward is computed as (2^z - 1) * 10^18.

  5. Minting: Two _mint calls create XPOW — _mint(owner(), amount) sends 50% to the MoeTreasury (the contract owner), and _mint(to, amount) sends 50% to the beneficiary. The _hashes[pairIndex] = true storage write permanently marks this solution as used.