Mining Guide
Learn how to participate in cAIToken mining through PoW mining or Flex Mining to earn cAI rewards
Mining Guide
cAIToken offers two mining methods: PoW Mining (Proof of Work) and Flex Mining (authorized mining). All 80,000,000 cAI tokens are released through the single mining pool with no pre-mining, no private sale, and no team allocation.
⛏️ PoW Mining
Mining Basics
| Parameter | Value | Description |
|---|---|---|
| Initial Reward | 80 cAI | Initial reward per successful mining |
| Difficulty Adjustment | 2,048 blocks | Difficulty adjusts every 2048 blocks |
| Target ETH Blocks | 81,920 | Target Ethereum blocks per adjustment period |
| Min Difficulty Target | 2^16 | Highest difficulty (lower target = higher difficulty) |
| Max Difficulty Target | 2^234 | Lowest difficulty (initial value) |
| Halving Cycle | 8 Eras | Era 0-7, reward halves each Era |
Era Distribution
| Era | Reward (cAI) | Cumulative | Percentage |
|---|---|---|---|
| Era 0 | 80 | 40,000,000 | 50% |
| Era 1 | 40 | 60,000,000 | 75% |
| Era 2 | 20 | 70,000,000 | 87.5% |
| Era 3 | 10 | 75,000,000 | 93.75% |
| Era 4 | 5 | 77,500,000 | 96.875% |
| Era 5 | 2.5 | 78,750,000 | 98.4375% |
| Era 6 | 1.25 | 79,375,000 | 99.21875% |
| Era 7 | 0.625 | ~80,000,000 | ~100% |
System Requirements
Operating System: Linux / macOS / Windows
Node.js: >= 16.x
Memory: >= 4GB RAM
Network: Stable Ethereum RPC connection
Install Dependencies
npm install ethers@6
PoW Hash Calculation
cAIMiner uses double Keccak256 hash algorithm (Bitcoin-style):
digest = keccak256(keccak256(challengeNumber + minerAddress + nonce))
Mining success condition:
uint256(digest) <= miningTarget
Basic Mining Script
const { ethers, keccak256, solidityPacked } = require("ethers");
const CONFIG = {
RPC_URL: "https://your-ethereum-rpc-url",
MINER_CONTRACT: "0x9B62c1f9236781e5049AF69817E033508f461274",
PRIVATE_KEY: "0x...", // Keep your private key secure
};
const MINER_ABI = [
"function mint(uint256 nonce) external returns (bool)",
"function getChallengeNumber() external view returns (bytes32)",
"function getMiningTarget() external view returns (uint256)",
"function getMiningReward() external view returns (uint256)",
"function checkMintSolution(uint256 nonce, address miner) external view returns (bool)",
];
class CAIMiner {
constructor() {
this.provider = new ethers.JsonRpcProvider(CONFIG.RPC_URL);
this.wallet = new ethers.Wallet(CONFIG.PRIVATE_KEY, this.provider);
this.contract = new ethers.Contract(
CONFIG.MINER_CONTRACT,
MINER_ABI,
this.wallet
);
this.minerAddress = this.wallet.address;
}
async initialize() {
this.challengeNumber = await this.contract.getChallengeNumber();
this.miningTarget = await this.contract.getMiningTarget();
const reward = await this.contract.getMiningReward();
console.log(`Current Reward: ${ethers.formatEther(reward)} cAI`);
}
calculateHash(nonce) {
const innerHash = keccak256(
solidityPacked(
["bytes32", "address", "uint256"],
[this.challengeNumber, this.minerAddress, nonce]
)
);
return BigInt(keccak256(solidityPacked(["bytes32"], [innerHash])));
}
checkSolution(nonce) {
const digest = this.calculateHash(nonce);
return digest <= this.miningTarget;
}
async mine() {
let nonce = BigInt(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER));
while (true) {
if (this.checkSolution(nonce)) {
console.log(`Found valid solution! Nonce: ${nonce}`);
const tx = await this.contract.mint(nonce);
await tx.wait();
console.log("Mining successful!");
await this.initialize(); // Refresh for next round
}
nonce++;
}
}
}
async function main() {
const miner = new CAIMiner();
await miner.initialize();
await miner.mine();
}
main().catch(console.error);
🔐 Flex Mining
Flex Mining is an authorized mining mechanism that allows registered Flex users to obtain mining pool tokens through platform signature authorization without traditional PoW computation.
Use Cases
- AI training task reward distribution
- Computing contribution verification rewards
- Ecosystem incentive distribution
- Staking validator node rewards
Comparison with PoW Mining
| Feature | PoW Mining | Flex Mining |
|---|---|---|
| Mining Method | Hash computation competition | Signature authorization |
| Reward Amount | Fixed (current Era reward) | Flexible (signature specified) |
| Entry Barrier | Anyone | Requires Flex user registration |
| Computation | High | None |
| Use Case | Computing mining | Task rewards, ecosystem incentives |
| Block Limit | Once per block | No limit |
Becoming a Flex User
Prerequisites:
- Ethereum wallet address
- ETH for gas fees
- Apply for Flex user registration with cAI official
Registration Process:
- Contact cAI official channels
- Submit wallet address and use case (AI training node, validator node, etc.)
- Complete KYB/KYC (if applicable)
- Receive EIP-712 registration signature
- Call registration function
Flex Mining Code
const { ethers } = require("ethers");
const MINER_ABI = [
"function registerFlexUser(address user, uint256 deadline, bytes32 nonce, uint8 v, bytes32 r, bytes32 s) external",
"function mintFlex(address miner, uint256 amount, uint256 deadline, bytes32 signatureNonce, uint8 v, bytes32 r, bytes32 s) external returns (bool)",
"function isFlexUser(address user) external view returns (bool)",
];
class FlexMinerClient {
constructor(config) {
this.provider = new ethers.JsonRpcProvider(config.rpcUrl);
this.wallet = new ethers.Wallet(config.privateKey, this.provider);
this.contract = new ethers.Contract(
config.minerAddress,
MINER_ABI,
this.wallet
);
}
async checkFlexUserStatus() {
return await this.contract.isFlexUser(this.wallet.address);
}
async register(signature) {
const { user, deadline, nonce, v, r, s } = signature;
const tx = await this.contract.registerFlexUser(
user,
deadline,
nonce,
v,
r,
s
);
return await tx.wait();
}
async mint(signature) {
const { miner, amount, deadline, nonce, v, r, s } = signature;
if (Date.now() / 1000 > deadline) {
throw new Error("Signature expired");
}
const tx = await this.contract.mintFlex(
miner,
amount,
deadline,
nonce,
v,
r,
s
);
return await tx.wait();
}
}
📊 Mining Statistics
async function getMiningStats(contract) {
const stats = await contract.getMiningStats();
return {
currentReward: ethers.formatEther(stats[0]),
difficulty: stats[1].toString(),
epochCount: stats[3].toString(),
rewardEra: stats[5].toString(),
tokensDistributed: ethers.formatEther(stats[6]),
poolBalance: ethers.formatEther(stats[12]),
};
}
⚠️ Common Errors
| Error | Description | Solution |
|---|---|---|
NotFlexUser | Caller is not a Flex user | Complete registration first |
AlreadyMinedInBlock | Block already mined | Wait for next block |
InvalidProofOfWork | Invalid PoW proof | Refresh challenge and retry |
SignatureExpired | Signature expired | Request new signature |
NonceAlreadyUsed | Nonce already used | Request new signature |
InsufficientPoolBalance | Insufficient pool balance | Reduce amount or wait |
📞 Technical Support
- Website: https://caitoken.tech
- Flex User Application: team@caitoken.tech
- GitHub: https://github.com/caitokentech
- Community: https://x.com/token_cai