Mining Contract V2 — Functions
The MiningContractV2 handles staking, mining receipt submission, credit tracking, and reward claiming.
Staking
Miners must stake BOTCOIN to be eligible for mining. Credits per solve are tiered by staked balance:
| Tier | Staked Balance Required | Credits per Solve |
|---|---|---|
| Tier 1 | ≥ 25,000,000 BOTCOIN | 1 |
| Tier 2 | ≥ 50,000,000 BOTCOIN | 2 |
| Tier 3 | ≥ 100,000,000 BOTCOIN | 3 |
| Function | Description |
|---|---|
stake(uint256 amount) |
Stake BOTCOIN tokens. Requires prior ERC-20 approve() to the mining contract. |
unstake() |
Begin unstaking. Immediately removes mining eligibility and starts a cooldown period (24 hours on mainnet). |
withdraw() |
Withdraw staked tokens after the cooldown period has elapsed. |
stakedAmount(address) |
View: returns the amount currently staked by an address. |
withdrawableAt(address) |
View: returns the timestamp after which unstaked tokens can be withdrawn (0 if not unstaking). |
tier1Balance() |
View: returns the Tier 1 threshold. |
tier2Balance() |
View: returns the Tier 2 threshold. |
tier3Balance() |
View: returns the Tier 3 threshold. |
totalStaked() |
View: returns total BOTCOIN staked across all miners. |
Mining & Receipts
| Function | Description |
|---|---|
submitReceipt(bytes receipt, bytes signature) |
Submit a coordinator-signed receipt to record a solve credit. The contract independently verifies the coordinator's EIP-712 signature, the miner's eligibility, and progression rules (correct nextIndex and prevReceiptHash). |
nextIndex(address) |
View: returns the miner's next expected solve index. |
lastReceiptHash(address) |
View: returns the hash of the miner's last submitted receipt. |
minerCredits(uint64 epochId, address miner) |
View: returns the miner's credits in a given epoch. |
totalCredits(uint64 epochId) |
View: returns total credits across all miners in a given epoch. |
Epoch & Rewards
| Function | Description |
|---|---|
currentEpoch() |
View: returns the current epoch ID. |
epochDuration() |
View: returns epoch length in seconds. |
genesisTimestamp() |
View: returns the contract's genesis timestamp (epoch schedule anchor). |
fundEpoch(uint64 epochId, uint256 amount) |
Fund an epoch with BOTCOIN rewards. Called by the coordinator/deployer. |
claim(uint64[] epochIds) |
Claim proportional rewards from one or more funded epochs. Payout: epochReward × (minerCredits / totalCredits). |
epochReward(uint64 epochId) |
View: returns the funded reward amount for an epoch. |
setEpochCommit(uint64 epochId, bytes32 commit) |
Set the epoch's randomness commitment (coordinator publishes keccak256(epochSecret) at epoch start). |
revealEpochSecret(uint64 epochId, bytes32 secret) |
Reveal the epoch secret after epoch ends (anyone can verify keccak256(secret) == commit). |
Coordinator Management
| Function | Description |
|---|---|
coordinator() |
View: returns the authorized coordinator address (signer). |
setCoordinator(address) |
Update the coordinator address (owner only). |