$GOURDES

$GOURDES

GOURDES mining spec

Everything you need to write your own $GOURDES miner, a pool, a dashboard or a bot, taken from the deployed contract. Every number on this page was read from Base, and the test vector is a real solution from the chain.

The contract

ChainBase, chain id 8453
Miner contract0xdfaBce24c8C1fbEc42327fb336A229606810b497 (explorer)
Coin it mints0xB614b287dA2BD9574181cF9CCA8D049d26AF22d0. The coin's MINER() returns the miner contract. The coin's mint() accepts calls only from the miner contract and never past the 500,000,000 mining budget. (Coins bridged in from another chain are also minted on arrival, but that moves existing coins between chains rather than creating new ones.)
OwnerNone. Every parameter below is fixed at deploy. The only one-time switch, start(), was used at launch and cannot be used again.
ABIgourdes-miner.abi.json (compiled from the deployed source; every function in it is present in the deployed bytecode)

The solution rule

A transaction mine(nonce) is accepted when:

uint256(keccak256(abi.encodePacked(challenge, msg.sender, nonce))) <= effectiveTarget()

Test vector (solution 615, Base block 65,295,917)

Check your hashing code against this before you spend any gas. It is a real accepted solution; the transaction is 0x082cde20…3562d15.

challenge  f4c8a9c1bc41be098103aefba6824168d2ad956c58b8ec57d2a89704b877d7a6
sender     57bb6acece1c50cda20b7963399a44c741370d22
nonce      8dfd9ca4eeff2074f8de3b4ce798e84507000000881cb1377476944b34289e2a
digest     00000000051ab79e66dc5fd218c96970a4937f6ddb781c8c5f6f1ec24980b64d
target     0000000005253335afcc44578256ce9b45e339ae4e4a3873ecbfeb74537f6731
digest <= target: yes

The same check in Python, with the eth-hash package (pip install "eth-hash[pycryptodome]"):

from eth_hash.auto import keccak
msg = bytes.fromhex("f4c8a9c1bc41be098103aefba6824168d2ad956c58b8ec57d2a89704b877d7a6"
                    "57bb6acece1c50cda20b7963399a44c741370d22"
                    "8dfd9ca4eeff2074f8de3b4ce798e84507000000881cb1377476944b34289e2a")
print(keccak(msg).hex())  # 00000000051ab79e66dc5fd218c9...

Parameters, read from the chain

GetterValueMeaning
MINING_BUDGET()500,000,000Most coins this contract can ever mint.
INITIAL_REWARD()475Reward per solution before the first halving.
Coin amounts are shown in whole coins. The getters return base units with 18 decimals, so INITIAL_REWARD() returns 475 × 10^18.
HALVING_INTERVAL()525,600Solutions per halving.
TARGET_SOLUTION_TIME()60Seconds per solution the difficulty aims for.
RETARGET_INTERVAL()64Solutions per difficulty adjustment.
EASING_K()4Silence, in multiples of 60 seconds, per doubling of the effective target.
MAX_TARGET()2^248 - 1Easiest possible target.
MIN_TARGET()2^32Hardest possible target.

Live state: challenge(), target(), effectiveTarget(), currentReward(), solutionCount(), totalMined(), epochStart(), lastSolutionTime(), lastMineBlock() and started(). digestFor(address, uint256) returns the digest mine would compute for that address and nonce right now. The mining page shows the live values.

Difficulty, easing and rewards

Expected work

The average number of hashes per solution is 2^256 / (target + 1). Smaller target, more work.

Retarget, every 64 solutions

When solutionCount reaches a multiple of 64, the contract measures the time since the epoch started and sets

newTarget = target × elapsed / (64 × 60)

with elapsed first clamped to between 960 and 15,360 seconds, so the target moves by at most 4 times per epoch in either direction. The result is clamped to [MIN_TARGET, MAX_TARGET]. The contract emits Retargeted(oldTarget, newTarget, epochSeconds).

Easing when nobody finds a solution

The target a solution is judged against is effectiveTarget(): the base target, doubled once for every full 240 seconds (4 × 60) since the last accepted solution, capped at MAX_TARGET. The base target itself is not changed by easing, and the next accepted solution resets the clock. So if large miners leave, mining gets easier within minutes instead of stalling. Always read effectiveTarget(), not target(), when deciding whether a hash qualifies.

Reward

currentReward() = min((475 × 10^18) >> (solutionCount / 525,600), budget left), in base units of 18 decimals: 475 coins per solution, then 237.5 after the first halving, then 118.75, and so on. The full halving series adds up to just under 2 × 475 × 525,600 = 499,320,000 coins, below the 500,000,000 budget, and every reward is also capped by what is left. When the reward reaches zero, mine reverts with MiningFinished forever.

Events

Eventtopic0
Mined(address indexed miner, uint256 reward, uint256 indexed solutionNumber, bytes32 newChallenge, uint256 target)0x3b1c1610e120c855f14c1cb881749872196a8764e4ca4d0bbf6916e93a6c0dfc
Retargeted(uint256 oldTarget, uint256 newTarget, uint256 epochSeconds)0x71998d7b4a30c995c89a1f0d703f3ec529d067251b6967e50ba1b18bd89533f3
MiningStarted(uint256 timestamp, bytes32 challenge)0x994f36af7f81eb1185a1e2ec4a202b09e2a0753583e518b5324b1355e7c8f94b

Mined carries the new challenge and the base target after any retarget, so a miner that follows these events can switch to new work without polling. The leaderboard is built from Mined events only.

Errors

ErrorSelectorWhen
InvalidSolution()0xd9c1988fThe digest is above the effective target. Usually someone else's solution landed first and changed the challenge.
OneSolutionPerBlock()0x93ac53ccAnother solution was already accepted in this block.
MiningFinished()0x8a7d2016The reward is zero; mining is over.
NotStarted()0x6f312cbdMining had not opened yet (it opened at launch).
NotStarter(), AlreadyStarted()0x4102967c, 0x1fbde445Only from start(), which was used once at launch.

A failed mine still costs its gas. Before sending, check the hit with digestFor or an eth_call of mine(nonce) from your own address, and drop any work as soon as a Mined event shows a new challenge.

Writing a pool

The sender's address is inside the hash, so all hashing for a pool has to use the address that will send mine: the pool's own address, or the pool contract if a contract makes the call. A pool works like this:

  1. The pool gives its miners the current challenge, the pool's address and a share target easier than effectiveTarget().
  2. Miners hash keccak256(challenge ‖ pool address ‖ nonce) and send in every nonce below the share target. The pool checks each share with one hash and credits the miner.
  3. When a share is also below effectiveTarget(), the pool sends mine(nonce). The reward is minted to the pool's address, and the pool pays its miners by its own rules.
  4. On every Mined event the challenge changes, so the pool sends out new work at once; shares for the old challenge are stale.

Miners in a pool trust the pool to pay them; the contract knows only the address that sent the solution. There is no pool run by the project today, and anyone is free to build one.

Source and limits

The contract is under 250 lines of Solidity, an EIP-918-style design: no owner, no upgrade path and no admin functions beyond the one-shot start(). It has not had a paid third-party audit. Report bugs to hello@gourdes.finance; the bug bounty pays in GOURDES.