Skip to content

Proof-of-Work Mining

XPower uses proof-of-work not for consensus (Avalanche handles that), but for token distribution — a provably fair mechanism where every XPOW token originates from computational work.

Hash Function

Miners compute Keccak-256 over a structured input:

hash=Keccak256(addressbeneficiaryblockHashdata)

Where:

  • address — the contract address (msg.sender)
  • beneficiary — the recipient address chosen by the miner
  • blockHash — a recently-initialized Avalanche block hash
  • data — a 32-byte field containing a 256-bit nonce

The XOR operation between the contract address and the beneficiary address ties the hash to both the contract and the intended recipient, preventing cross-contract nonce reuse.

Difficulty

Difficulty is measured by the number of leading zero nibbles (4-bit hex digits) in the 256-bit hash output. Let z be the count of consecutive zero nibbles from the start.

The probability of finding a valid hash with z leading zeros is:

P(z)=116z
zProbabilityExpected HashesReward (XPOW)
11/16161×1018
21/2562563×1018
31/4,096~4K7×1018
41/65,536~66K15×1018
51/1,048,576~1M31×1018
61/16,777,216~17M63×1018
71/268,435,456~268M127×1018
81/4,294,967,296~4.3B255×1018

Reward Formula

The XPOW reward for difficulty z is:

R(z)=(2z1)×1018

This creates an exponential reward curve: doubling the difficulty doubles the number of expected hashes but slightly more than doubles the reward.

Treasury Split

Every successful mint splits the reward:

  • 50% to the miner's beneficiary — the address specified in the mint call
  • 50% to the MoeTreasury — funds the staking reward pool

This split ensures that even non-miners (staking participants) benefit from mining activity, aligning incentives across the ecosystem.

Expected Yield

For a uniform random nonce search, the expected XPOW per hash attempt is:

E[R]=z=1116z×(2z1)×10180.076×1018 per hash

This means approximately 13 hash attempts per token on average, though the distribution is heavily skewed — most rewards come from low-difficulty solutions, while high-difficulty solutions are rare but lucrative.

Block Hash Intervals

Mining operates within 1-hour windows tied to Avalanche block hashes:

  1. The miner calls XPower.init(blockHash) to register a block hash for mining
  2. Solutions must be submitted within 3,600 seconds of init()
  3. Each (beneficiary, blockHash, pairIndex) tuple can only be used once

This 1-hour window prevents pre-computation attacks — if a miner could compute nonces against arbitrary future block hashes, the proof-of-work would be meaningless. By requiring a recent on-chain block hash, every computation is tied to a specific, verified point in Avalanche's history.

Duplicate Prevention

The pairIndex field prevents replay of the same solution:

pairIndex=keccak(nonce)blockHash

This XOR-based encoding creates a one-to-one mapping between nonces and block hashes per beneficiary. Once a pair is used, it's marked in contract storage and cannot be reused.